NXSL: implemented function trace(); code refactoring
authorVictor Kirhenshtein <victor@netxms.org>
Sat, 16 Jan 2010 17:19:34 +0000 (17:19 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Sat, 16 Jan 2010 17:19:34 +0000 (17:19 +0000)
34 files changed:
ChangeLog
include/nxsl_classes.h
src/libnxsl/array.cpp
src/libnxsl/class.cpp
src/libnxsl/compiler.cpp
src/libnxsl/env.cpp
src/libnxsl/functions.cpp
src/libnxsl/lexer.cpp
src/libnxsl/libnxsl.h
src/libnxsl/library.cpp
src/libnxsl/main.cpp
src/libnxsl/parser.l
src/libnxsl/parser.y
src/libnxsl/program.cpp
src/libnxsl/stack.cpp
src/libnxsl/value.cpp
src/libnxsl/variable.cpp
src/nxscript/class.cpp
src/nxscript/nxscript.cpp
src/nxscript/nxscript.h
src/server/core/condition.cpp
src/server/core/container.cpp
src/server/core/dcitem.cpp
src/server/core/epp.cpp
src/server/core/events.cpp
src/server/core/np.cpp
src/server/core/nxsl_classes.cpp
src/server/core/nxslext.cpp
src/server/core/script.cpp
src/server/core/session.cpp
src/server/core/situation.cpp
src/server/core/snmp.cpp
src/server/core/template.cpp
src/server/include/nms_script.h

index 3543d5f..25680ed 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,7 +5,9 @@
 - System configuration (events, SNMP traps, templates, event processing rules)
   can be exported and imported in XML format - this solves various problems
   with old NXMP files
-- New NXSL function: GetInterfaceName
+- NXSL improvements:
+       - New functions: GetInterfaceName, trace
+       - Added built-in constants TRUE and FALSE
 - Added support for encrypted DB passwords in netxmsd.conf
 - Fixed issues: #62, #278
 
index 45ca6e7..d7dcd98 100644 (file)
@@ -62,15 +62,15 @@ private:
    void **m_ppData;
 
 public:
-   NXSL_Stack(void);
+   NXSL_Stack();
    ~NXSL_Stack();
 
-   void Push(void *pData);
-   void *Pop(void);
-   void *Peek(void);
-   void **PeekList(int nLevel) { return &m_ppData[m_nStackPos - nLevel]; }
+   void push(void *pData);
+   void *pop();
+   void *peek();
+   void **peekList(int nLevel) { return &m_ppData[m_nStackPos - nLevel]; }
 
-   int Size(void) { return m_nStackPos; }
+   int getSize() { return m_nStackPos; }
 };
 
 
@@ -84,18 +84,18 @@ class NXSL_Object;
 class LIBNXSL_EXPORTABLE NXSL_Class
 {
 protected:
-   char m_szName[MAX_CLASS_NAME];
+   TCHAR m_szName[MAX_CLASS_NAME];
 
 public:
    NXSL_Class();
    virtual ~NXSL_Class();
 
-   virtual NXSL_Value *GetAttr(NXSL_Object *pObject, char *pszAttr);
-   virtual BOOL SetAttr(NXSL_Object *pObject, char *pszAttr, NXSL_Value *pValue);
+   virtual NXSL_Value *getAttr(NXSL_Object *pObject, char *pszAttr);
+   virtual BOOL setAttr(NXSL_Object *pObject, char *pszAttr, NXSL_Value *pValue);
 
-       virtual void OnObjectDelete(NXSL_Object *object);
+       virtual void onObjectDelete(NXSL_Object *object);
 
-   char *Name(void) { return m_szName; }
+   const TCHAR *getName(void) { return m_szName; }
 };
 
 
@@ -114,8 +114,8 @@ public:
    NXSL_Object(NXSL_Class *pClass, void *pData);
    ~NXSL_Object();
 
-   NXSL_Class *Class() { return m_pClass; }
-   void *Data() { return m_pData; }
+   NXSL_Class *getClass() { return m_pClass; }
+   void *getData() { return m_pData; }
 };
 
 
@@ -142,12 +142,12 @@ public:
        NXSL_Array(NXSL_Array *src);
        ~NXSL_Array();
 
-       void IncRefCount() { m_refCount++; }
-       void DecRefCount() { m_refCount--; }
-       BOOL IsUnused() { return m_refCount < 1; }
+       void incRefCount() { m_refCount++; }
+       void decRefCount() { m_refCount--; }
+       BOOL isUnused() { return m_refCount < 1; }
 
-       void Set(int index, NXSL_Value *value);
-       NXSL_Value *Get(int index);
+       void set(int index, NXSL_Value *value);
+       NXSL_Value *get(int index);
 };
 
 
@@ -173,10 +173,10 @@ protected:
                NXSL_Array *pArray;
    } m_value;
 
-   void UpdateNumber(void);
-   void UpdateString(void);
+   void updateNumber();
+   void updateString();
 
-   void InvalidateString(void)
+   void invalidateString()
    {
       safe_free(m_pszValStr);
       m_pszValStr = NULL;
@@ -184,7 +184,7 @@ protected:
    }
 
 public:
-   NXSL_Value(void);
+   NXSL_Value();
    NXSL_Value(const NXSL_Value *);
    NXSL_Value(NXSL_Object *pObject);
    NXSL_Value(NXSL_Array *pArray);
@@ -197,49 +197,49 @@ public:
    NXSL_Value(const TCHAR *pszValue, DWORD dwLen);
    ~NXSL_Value();
 
-   void Set(LONG nValue);
-
-   BOOL Convert(int nDataType);
-   int DataType(void) { return m_nDataType; }
-
-   BOOL IsNull(void) { return (m_nDataType == NXSL_DT_NULL); }
-   BOOL IsObject(void) { return (m_nDataType == NXSL_DT_OBJECT); }
-   BOOL IsArray(void) { return (m_nDataType == NXSL_DT_ARRAY); }
-   BOOL IsString(void) { return (m_nDataType >= NXSL_DT_STRING); }
-   BOOL IsNumeric(void) { return (m_nDataType > NXSL_DT_STRING); }
-   BOOL IsReal(void) { return (m_nDataType == NXSL_DT_REAL); }
-   BOOL IsInteger(void) { return (m_nDataType > NXSL_DT_REAL); }
-   BOOL IsUnsigned(void) { return (m_nDataType >= NXSL_DT_UINT32); }
-   BOOL IsZero(void);
-   BOOL IsNonZero(void);
-
-   char *GetValueAsString(DWORD *pdwLen);
-   char *GetValueAsCString(void);
-   LONG GetValueAsInt32(void);
-   DWORD GetValueAsUInt32(void);
-   INT64 GetValueAsInt64(void);
-   QWORD GetValueAsUInt64(void);
-   double GetValueAsReal(void);
-   NXSL_Object *GetValueAsObject(void) { return (m_nDataType == NXSL_DT_OBJECT) ? m_value.pObject : NULL; }
-   NXSL_Array *GetValueAsArray(void) { return (m_nDataType == NXSL_DT_ARRAY) ? m_value.pArray : NULL; }
-
-   void Concatenate(char *pszString, DWORD dwLen);
+   void set(LONG nValue);
+
+   bool convert(int nDataType);
+   int getDataType() { return m_nDataType; }
+
+   bool isNull() { return (m_nDataType == NXSL_DT_NULL); }
+   bool isObject() { return (m_nDataType == NXSL_DT_OBJECT); }
+   bool isArray() { return (m_nDataType == NXSL_DT_ARRAY); }
+   bool isString() { return (m_nDataType >= NXSL_DT_STRING); }
+   bool isNumeric() { return (m_nDataType > NXSL_DT_STRING); }
+   bool isReal() { return (m_nDataType == NXSL_DT_REAL); }
+   bool isInteger() { return (m_nDataType > NXSL_DT_REAL); }
+   bool isUnsigned() { return (m_nDataType >= NXSL_DT_UINT32); }
+   bool isZero();
+   bool isNonZero();
+
+   const TCHAR *getValueAsString(DWORD *pdwLen);
+   const TCHAR *getValueAsCString();
+   LONG getValueAsInt32();
+   DWORD getValueAsUInt32();
+   INT64 getValueAsInt64();
+   QWORD getValueAsUInt64();
+   double getValueAsReal();
+   NXSL_Object *getValueAsObject() { return (m_nDataType == NXSL_DT_OBJECT) ? m_value.pObject : NULL; }
+   NXSL_Array *getValueAsArray() { return (m_nDataType == NXSL_DT_ARRAY) ? m_value.pArray : NULL; }
+
+   void concatenate(const TCHAR *pszString, DWORD dwLen);
    
-   void Increment(void);
-   void Decrement(void);
-   void Negate(void);
-   void BitNot(void);
-
-   void Add(NXSL_Value *pVal);
-   void Sub(NXSL_Value *pVal);
-   void Mul(NXSL_Value *pVal);
-   void Div(NXSL_Value *pVal);
-   void Rem(NXSL_Value *pVal);
-   void BitAnd(NXSL_Value *pVal);
-   void BitOr(NXSL_Value *pVal);
-   void BitXor(NXSL_Value *pVal);
-   void LShift(int nBits);
-   void RShift(int nBits);
+   void increment();
+   void decrement();
+   void negate();
+   void bitNot();
+
+   void add(NXSL_Value *pVal);
+   void sub(NXSL_Value *pVal);
+   void mul(NXSL_Value *pVal);
+   void div(NXSL_Value *pVal);
+   void rem(NXSL_Value *pVal);
+   void bitAnd(NXSL_Value *pVal);
+   void bitOr(NXSL_Value *pVal);
+   void bitXor(NXSL_Value *pVal);
+   void lshift(int nBits);
+   void rshift(int nBits);
 
    BOOL EQ(NXSL_Value *pVal);
    BOOL LT(NXSL_Value *pVal);
@@ -264,11 +264,13 @@ struct NXSL_Function
 // External function structure
 //
 
+class NXSL_Program;
+
 struct NXSL_ExtFunction
 {
    char m_szName[MAX_FUNCTION_NAME];
-   int (* m_pfHandler)(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-   int m_iNumArgs;   // Number of arguments or -1 fo variable number
+   int (* m_pfHandler)(int argc, NXSL_Value **argv, NXSL_Value **result, NXSL_Program *program);
+   int m_iNumArgs;   // Number of arguments or -1 for variable number
 };
 
 
@@ -276,7 +278,6 @@ struct NXSL_ExtFunction
 // Environment for NXSL program
 //
 
-class NXSL_Program;
 class NXSL_Library;
 
 class LIBNXSL_EXPORTABLE NXSL_Environment
@@ -294,16 +295,18 @@ public:
    NXSL_Environment();
    ~NXSL_Environment();
 
-   void SetIO(FILE *pIn, FILE *pOut) { m_pStdIn = pIn; m_pStdOut = pOut; }
-   FILE *GetStdIn(void) { return m_pStdIn; }
-   FILE *GetStdOut(void) { return m_pStdOut; }
+       virtual void trace(int level, const TCHAR *text);
+
+   void setIO(FILE *pIn, FILE *pOut) { m_pStdIn = pIn; m_pStdOut = pOut; }
+   FILE *getStdIn() { return m_pStdIn; }
+   FILE *getStdOut() { return m_pStdOut; }
 
-   void SetLibrary(NXSL_Library *pLib) { m_pLibrary = pLib; }
+   void setLibrary(NXSL_Library *pLib) { m_pLibrary = pLib; }
 
-   NXSL_ExtFunction *FindFunction(char *pszName);
-   void RegisterFunctionSet(DWORD dwNumFunctions, NXSL_ExtFunction *pList);
+   NXSL_ExtFunction *findFunction(char *pszName);
+   void registerFunctionSet(DWORD dwNumFunctions, NXSL_ExtFunction *pList);
 
-   BOOL UseModule(NXSL_Program *pMain, char *pszName);
+   BOOL useModule(NXSL_Program *main, const TCHAR *name);
 };
 
 
@@ -323,9 +326,9 @@ public:
    NXSL_Variable(NXSL_Variable *pSrc);
    ~NXSL_Variable();
 
-   const TCHAR *Name(void) { return m_pszName; }
-   NXSL_Value *Value(void) { return m_pValue; }
-   void Set(NXSL_Value *pValue);
+   const TCHAR *getName() { return m_pszName; }
+   NXSL_Value *getValue() { return m_pValue; }
+   void setValue(NXSL_Value *pValue);
 };
 
 
@@ -340,12 +343,12 @@ protected:
    NXSL_Variable **m_ppVariableList;
 
 public:
-   NXSL_VariableSystem(void);
+   NXSL_VariableSystem();
    NXSL_VariableSystem(NXSL_VariableSystem *pSrc);
    ~NXSL_VariableSystem();
 
-   NXSL_Variable *Find(const TCHAR *pszName);
-   NXSL_Variable *Create(const TCHAR *pszName, NXSL_Value *pValue = NULL);
+   NXSL_Variable *find(const TCHAR *pszName);
+   NXSL_Variable *create(const TCHAR *pszName, NXSL_Value *pValue = NULL);
 };
 
 
@@ -429,45 +432,46 @@ protected:
    int m_nErrorCode;
    TCHAR *m_pszErrorText;
 
-   void Execute(void);
-   void CallFunction(int nArgCount);
-   void DoUnaryOperation(int nOpCode);
-   void DoBinaryOperation(int nOpCode);
-   void Error(int nError);
-   NXSL_Value *MatchRegexp(NXSL_Value *pValue, NXSL_Value *pRegexp, BOOL bIgnoreCase);
+   void execute();
+   void callFunction(int nArgCount);
+   void doUnaryOperation(int nOpCode);
+   void doBinaryOperation(int nOpCode);
+   void error(int nError);
+   NXSL_Value *matchRegexp(NXSL_Value *pValue, NXSL_Value *pRegexp, BOOL bIgnoreCase);
 
-   NXSL_Variable *FindOrCreateVariable(TCHAR *pszName);
-       NXSL_Variable *CreateVariable(TCHAR *pszName);
+   NXSL_Variable *findOrCreateVariable(TCHAR *pszName);
+       NXSL_Variable *createVariable(TCHAR *pszName);
 
-   DWORD GetFunctionAddress(char *pszName);
-   void RelocateCode(DWORD dwStartOffset, DWORD dwLen, DWORD dwShift);
-       DWORD FinalJumpDestination(DWORD dwAddr);
+   DWORD getFunctionAddress(char *pszName);
+   void relocateCode(DWORD dwStartOffset, DWORD dwLen, DWORD dwShift);
+       DWORD getFinalJumpDestination(DWORD dwAddr);
 
 public:
    NXSL_Program();
    ~NXSL_Program();
 
-   BOOL AddFunction(const char *pszName, DWORD dwAddr, char *pszError);
-   void ResolveFunctions();
-   void AddInstruction(NXSL_Instruction *pInstruction);
-   void ResolveLastJump(int nOpCode);
-       void CreateJumpAt(DWORD dwOpAddr, DWORD dwJumpAddr);
-   void AddPreload(char *pszName);
-   void UseModule(NXSL_Program *pModule, const char *pszName);
-       void Optimize();
+   BOOL addFunction(const char *pszName, DWORD dwAddr, char *pszError);
+   void resolveFunctions();
+   void addInstruction(NXSL_Instruction *pInstruction);
+   void resolveLastJump(int nOpCode);
+       void createJumpAt(DWORD dwOpAddr, DWORD dwJumpAddr);
+   void addPreload(char *pszName);
+   void useModule(NXSL_Program *pModule, const char *pszName);
+       void optimize();
 
-       void SetGlobalVariable(const TCHAR *pszName, NXSL_Value *pValue);
-       NXSL_Variable *FindGlobalVariable(const TCHAR *pszName) { return m_pGlobals->Find(pszName); }
+       void setGlobalVariable(const TCHAR *pszName, NXSL_Value *pValue);
+       NXSL_Variable *findGlobalVariable(const TCHAR *pszName) { return m_pGlobals->find(pszName); }
 
-   int Run(NXSL_Environment *pEnv = NULL, DWORD argc = 0,
+   int run(NXSL_Environment *pEnv = NULL, DWORD argc = 0,
            NXSL_Value **argv = NULL, NXSL_VariableSystem *pUserLocals = NULL,
            NXSL_VariableSystem **ppGlobals = NULL);
 
-   DWORD CodeSize() { return m_dwCodeSize; }
+   DWORD getCodeSize() { return m_dwCodeSize; }
 
-   void Dump(FILE *pFile);
-   const TCHAR *GetErrorText() { return CHECK_NULL_EX(m_pszErrorText); }
-   NXSL_Value *GetResult() { return m_pRetValue; }
+       void trace(int level, const TCHAR *text);
+   void dump(FILE *pFile);
+   const TCHAR *getErrorText() { return CHECK_NULL_EX(m_pszErrorText); }
+   NXSL_Value *getResult() { return m_pRetValue; }
 };
 
 
@@ -484,21 +488,21 @@ private:
    DWORD *m_pdwIdList;
    MUTEX m_mutex;
 
-   void Delete(int nIndex);
+   void deleteInternal(int nIndex);
 
 public:
-   NXSL_Library(void);
+   NXSL_Library();
    ~NXSL_Library();
 
-   void Lock(void) { MutexLock(m_mutex, INFINITE); }
-   void Unlock(void) { MutexUnlock(m_mutex); }
+   void lock() { MutexLock(m_mutex, INFINITE); }
+   void unlock() { MutexUnlock(m_mutex); }
 
-   BOOL AddScript(DWORD dwId, char *pszName, NXSL_Program *pScript);
-   void DeleteScript(char *pszName);
-   void DeleteScript(DWORD dwId);
-   NXSL_Program *FindScript(char *pszName);
+   BOOL addScript(DWORD dwId, const TCHAR *pszName, NXSL_Program *pScript);
+   void deleteScript(const TCHAR *pszName);
+   void deleteScript(DWORD dwId);
+   NXSL_Program *findScript(const TCHAR *pszName);
 
-   void FillMessage(CSCPMessage *pMsg);
+   void fillMessage(CSCPMessage *pMsg);
 };
 
 
index 64e196d..e572688 100644 (file)
@@ -87,7 +87,7 @@ static int CompareElements(const void *p1, const void *p2)
 // Get element
 //
 
-NXSL_Value *NXSL_Array::Get(int index)
+NXSL_Value *NXSL_Array::get(int index)
 {
        NXSL_ArrayElement *element, key;
 
@@ -101,7 +101,7 @@ NXSL_Value *NXSL_Array::Get(int index)
 // Set element
 //
 
-void NXSL_Array::Set(int index, NXSL_Value *value)
+void NXSL_Array::set(int index, NXSL_Value *value)
 {
        NXSL_ArrayElement *element, key;
 
index 29083c9..e91d695 100644 (file)
@@ -1,7 +1,7 @@
 /* 
 ** NetXMS - Network Management System
 ** NetXMS Scripting Language Interpreter
-** Copyright (C) 2005, 2006 Victor Kirhenshtein
+** Copyright (C) 2005-2010 Victor Kirhenshtein
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
 ** along with this program; if not, write to the Free Software
 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 **
-** $module: class.cpp
+** File: class.cpp
 **
 **/
 
@@ -28,7 +28,7 @@
 // Class constructor
 //
 
-NXSL_Class::NXSL_Class(void)
+NXSL_Class::NXSL_Class()
 {
    strcpy(m_szName, "generic");
 }
@@ -48,7 +48,7 @@ NXSL_Class::~NXSL_Class()
 // Default implementation - always returns error
 //
 
-NXSL_Value *NXSL_Class::GetAttr(NXSL_Object *pObject, char *pszAttr)
+NXSL_Value *NXSL_Class::getAttr(NXSL_Object *pObject, char *pszAttr)
 {
    return NULL;
 }
@@ -59,7 +59,7 @@ NXSL_Value *NXSL_Class::GetAttr(NXSL_Object *pObject, char *pszAttr)
 // Default implementation - always returns error
 //
 
-BOOL NXSL_Class::SetAttr(NXSL_Object *pObject, char *pszAttr, NXSL_Value *pValue)
+BOOL NXSL_Class::setAttr(NXSL_Object *pObject, char *pszAttr, NXSL_Value *pValue)
 {
    return FALSE;
 }
@@ -69,7 +69,7 @@ BOOL NXSL_Class::SetAttr(NXSL_Object *pObject, char *pszAttr, NXSL_Value *pValue
 // Object deletion handler
 //
 
-void NXSL_Class::OnObjectDelete(NXSL_Object *object)
+void NXSL_Class::onObjectDelete(NXSL_Object *object)
 {
 }
 
index c058ca5..300acff 100644 (file)
@@ -39,7 +39,7 @@ int yylex_destroy(yyscan_t);
 // Constructor
 //
 
-NXSL_Compiler::NXSL_Compiler(void)
+NXSL_Compiler::NXSL_Compiler()
 {
    m_pszErrorText = NULL;
    m_pLexer = NULL;
@@ -65,13 +65,13 @@ NXSL_Compiler::~NXSL_Compiler()
 // Error handler
 //
 
-void NXSL_Compiler::Error(const char *pszMsg)
+void NXSL_Compiler::error(const char *pszMsg)
 {
    char szText[1024];
 
    if (m_pszErrorText == NULL)
    {
-      snprintf(szText, 1024, "Error in line %d: %s", m_pLexer->GetCurrLine(), pszMsg);
+      snprintf(szText, 1024, "Error in line %d: %s", m_pLexer->getCurrLine(), pszMsg);
 #ifdef UNICODE
       nLen = strlen(szText) + 1;
       m_pszErrorText = (WCHAR *)malloc(nLen * sizeof(WCHAR));
@@ -88,7 +88,7 @@ void NXSL_Compiler::Error(const char *pszMsg)
 // Compile source code
 //
 
-NXSL_Program *NXSL_Compiler::Compile(const TCHAR *pszSourceCode)
+NXSL_Program *NXSL_Compiler::compile(const TCHAR *pszSourceCode)
 {
    NXSL_Program *pResult;
        yyscan_t scanner;
@@ -100,8 +100,8 @@ NXSL_Program *NXSL_Compiler::Compile(const TCHAR *pszSourceCode)
 //yydebug=1;
    if (yyparse(scanner, m_pLexer, this, pResult) == 0)
    {
-      pResult->ResolveFunctions();
-               pResult->Optimize();
+      pResult->resolveFunctions();
+               pResult->optimize();
    }
    else
    {
@@ -120,7 +120,7 @@ NXSL_Program *NXSL_Compiler::Compile(const TCHAR *pszSourceCode)
 void yyerror(yyscan_t scanner, NXSL_Lexer *pLexer, NXSL_Compiler *pCompiler,
              NXSL_Program *pScript, const char *pszText)
 {
-   pCompiler->Error(pszText);
+   pCompiler->error(pszText);
 }
 
 
@@ -128,11 +128,11 @@ void yyerror(yyscan_t scanner, NXSL_Lexer *pLexer, NXSL_Compiler *pCompiler,
 // Pop address
 //
 
-DWORD NXSL_Compiler::PopAddr(void)
+DWORD NXSL_Compiler::popAddr()
 {
    void *pAddr;
 
-   pAddr = m_pAddrStack->Pop();
+   pAddr = m_pAddrStack->pop();
    return pAddr ? CAST_FROM_POINTER(pAddr, DWORD) : INVALID_ADDRESS;
 }
 
@@ -141,11 +141,11 @@ DWORD NXSL_Compiler::PopAddr(void)
 // Peek address
 //
 
-DWORD NXSL_Compiler::PeekAddr(void)
+DWORD NXSL_Compiler::peekAddr()
 {
    void *pAddr;
 
-   pAddr = m_pAddrStack->Peek();
+   pAddr = m_pAddrStack->peek();
    return pAddr ? CAST_FROM_POINTER(pAddr, DWORD) : INVALID_ADDRESS;
 }
 
@@ -154,11 +154,11 @@ DWORD NXSL_Compiler::PeekAddr(void)
 // Add "break" statement address
 //
 
-void NXSL_Compiler::AddBreakAddr(DWORD dwAddr)
+void NXSL_Compiler::addBreakAddr(DWORD dwAddr)
 {
        Queue *pQueue;
 
-       pQueue = (Queue *)m_pBreakStack->Peek();
+       pQueue = (Queue *)m_pBreakStack->peek();
        if (pQueue != NULL)
        {
                pQueue->Put(CAST_TO_POINTER(dwAddr, void *));
@@ -170,19 +170,19 @@ void NXSL_Compiler::AddBreakAddr(DWORD dwAddr)
 // Resolve all breal statements at current level
 //
 
-void NXSL_Compiler::CloseBreakLevel(NXSL_Program *pScript)
+void NXSL_Compiler::closeBreakLevel(NXSL_Program *pScript)
 {
        Queue *pQueue;
        void *pAddr;
        DWORD dwAddr;
 
-       pQueue = (Queue *)m_pBreakStack->Pop();
+       pQueue = (Queue *)m_pBreakStack->pop();
        if (pQueue != NULL)
        {
                while((pAddr = pQueue->Get()) != NULL)
                {
                        dwAddr = CAST_FROM_POINTER(pAddr, DWORD);
-                       pScript->CreateJumpAt(dwAddr, pScript->CodeSize());
+                       pScript->createJumpAt(dwAddr, pScript->getCodeSize());
                }
                delete pQueue;
        }
index 5f3101f..83cedd7 100644 (file)
 // Externals
 //
 
-int F_abs(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-int F_classof(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-int F_d2x(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-int F_exit(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-int F_gmtime(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-int F_left(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-int F_length(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-int F_localtime(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-int F_lower(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-int F_ltrim(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-int F_max(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-int F_min(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-int F_pow(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-int F_right(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-int F_rtrim(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-int F_strftime(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-int F_substr(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-int F_time(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-int F_trim(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-int F_typeof(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-int F_upper(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-int F_AddrInRange(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-int F_AddrInSubnet(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
-int F_SecondsToUptime(int argc, NXSL_Value **argv, NXSL_Value **ppResult);
+int F_abs(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_classof(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_d2x(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_exit(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_gmtime(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_left(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_length(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_localtime(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_lower(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_ltrim(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_max(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_min(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_pow(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_right(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_rtrim(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_strftime(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_substr(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_time(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_trace(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_trim(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_typeof(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_upper(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_AddrInRange(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_AddrInSubnet(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
+int F_SecondsToUptime(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program);
 
 
 //
@@ -78,6 +79,7 @@ static NXSL_ExtFunction m_builtinFunctions[] =
        { "strftime", F_strftime, -1 },
        { "substr", F_substr, -1 },
        { "time", F_time, 0 },
+   { "trace", F_trace, 2 },
        { "trim", F_trim, 1 },
    { "typeof", F_typeof, 1 },
    { "upper", F_upper, 1 },
@@ -115,7 +117,7 @@ NXSL_Environment::~NXSL_Environment()
 // Find function by name
 //
 
-NXSL_ExtFunction *NXSL_Environment::FindFunction(char *pszName)
+NXSL_ExtFunction *NXSL_Environment::findFunction(char *pszName)
 {
    DWORD i;
 
@@ -130,7 +132,7 @@ NXSL_ExtFunction *NXSL_Environment::FindFunction(char *pszName)
 // Register function set
 //
 
-void NXSL_Environment::RegisterFunctionSet(DWORD dwNumFunctions, NXSL_ExtFunction *pList)
+void NXSL_Environment::registerFunctionSet(DWORD dwNumFunctions, NXSL_ExtFunction *pList)
 {
    m_pFunctionList = (NXSL_ExtFunction *)realloc(m_pFunctionList, sizeof(NXSL_ExtFunction) * (m_dwNumFunctions + dwNumFunctions));
    memcpy(&m_pFunctionList[m_dwNumFunctions], pList, sizeof(NXSL_ExtFunction) * dwNumFunctions);
@@ -142,7 +144,7 @@ void NXSL_Environment::RegisterFunctionSet(DWORD dwNumFunctions, NXSL_ExtFunctio
 // Find module by name
 //
 
-BOOL NXSL_Environment::UseModule(NXSL_Program *pMain, TCHAR *pszName)
+BOOL NXSL_Environment::useModule(NXSL_Program *pMain, const TCHAR *pszName)
 {
    TCHAR *pData, szBuffer[MAX_PATH];
    DWORD dwSize;
@@ -152,10 +154,10 @@ BOOL NXSL_Environment::UseModule(NXSL_Program *pMain, TCHAR *pszName)
    // First, try to find module in library
    if (m_pLibrary != NULL)
    {
-      pScript = m_pLibrary->FindScript(pszName);
+      pScript = m_pLibrary->findScript(pszName);
       if (pScript != NULL)
       {
-         pMain->UseModule(pScript, pszName);
+         pMain->useModule(pScript, pszName);
          bRet = TRUE;
       }
    }
@@ -170,7 +172,7 @@ BOOL NXSL_Environment::UseModule(NXSL_Program *pMain, TCHAR *pszName)
          pScript = (NXSL_Program *)NXSLCompile(pData, NULL, 0);
          if (pScript != NULL)
          {
-            pMain->UseModule(pScript, pszName);
+            pMain->useModule(pScript, pszName);
             delete pScript;
             bRet = TRUE;
          }
@@ -180,3 +182,13 @@ BOOL NXSL_Environment::UseModule(NXSL_Program *pMain, TCHAR *pszName)
 
    return bRet;
 }
+
+
+//
+// Write trace message
+// Default implementation does nothing
+//
+
+void NXSL_Environment::trace(int level, const TCHAR *text)
+{
+}
index 2cb756a..f12b2d4 100644 (file)
@@ -1,7 +1,7 @@
 /* 
 ** NetXMS - Network Management System
 ** NetXMS Scripting Language Interpreter
-** Copyright (C) 2005, 2006, 2007, 2008 Victor Kirhenshtein
+** Copyright (C) 2005-2010 Victor Kirhenshtein
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -38,9 +38,9 @@ const char *g_szTypeNames[] = { "null", "object", "string", "real", "int32",
 // Type of value
 //
 
-int F_typeof(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_typeof(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
-   *ppResult = new NXSL_Value(g_szTypeNames[argv[0]->DataType()]);
+   *ppResult = new NXSL_Value(g_szTypeNames[argv[0]->getDataType()]);
    return 0;
 }
 
@@ -49,12 +49,12 @@ int F_typeof(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 // Class of an object
 //
 
-int F_classof(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_classof(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
-       if (!argv[0]->IsObject())
+       if (!argv[0]->isObject())
                return NXSL_ERR_NOT_OBJECT;
                
-   *ppResult = new NXSL_Value(argv[0]->GetValueAsObject()->Class()->Name());
+   *ppResult = new NXSL_Value(argv[0]->getValueAsObject()->getClass()->getName());
    return 0;
 }
 
@@ -63,22 +63,22 @@ int F_classof(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 // Absolute value
 //
 
-int F_abs(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_abs(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
    int nRet;
 
-   if (argv[0]->IsNumeric())
+   if (argv[0]->isNumeric())
    {
-      if (argv[0]->IsReal())
+      if (argv[0]->isReal())
       {
-         *ppResult = new NXSL_Value(fabs(argv[0]->GetValueAsReal()));
+         *ppResult = new NXSL_Value(fabs(argv[0]->getValueAsReal()));
       }
       else
       {
          *ppResult = new NXSL_Value(argv[0]);
-         if (!argv[0]->IsUnsigned())
-            if ((*ppResult)->GetValueAsInt64() < 0)
-               (*ppResult)->Negate();
+         if (!argv[0]->isUnsigned())
+            if ((*ppResult)->getValueAsInt64() < 0)
+               (*ppResult)->negate();
       }
       nRet = 0;
    }
@@ -94,13 +94,13 @@ int F_abs(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 // Calculates x raised to the power of y
 //
 
-int F_pow(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_pow(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
    int nRet;
 
-   if ((argv[0]->IsNumeric()) && (argv[1]->IsNumeric()))
+   if ((argv[0]->isNumeric()) && (argv[1]->isNumeric()))
    {
-      *ppResult = new NXSL_Value(pow(argv[0]->GetValueAsReal(), argv[1]->GetValueAsReal()));
+      *ppResult = new NXSL_Value(pow(argv[0]->getValueAsReal(), argv[1]->getValueAsReal()));
       nRet = 0;
    }
    else
@@ -115,16 +115,16 @@ int F_pow(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 // Convert string to uppercase
 //
 
-int F_upper(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_upper(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
    int nRet;
    DWORD i, dwLen;
-   char *pStr;
+   TCHAR *pStr;
 
-   if (argv[0]->IsString())
+   if (argv[0]->isString())
    {
       *ppResult = new NXSL_Value(argv[0]);
-      pStr = (*ppResult)->GetValueAsString(&dwLen);
+      pStr = (TCHAR *)(*ppResult)->getValueAsString(&dwLen);
       for(i = 0; i < dwLen; i++, pStr++)
          *pStr = toupper(*pStr);
       nRet = 0;
@@ -141,16 +141,16 @@ int F_upper(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 // Convert string to lowercase
 //
 
-int F_lower(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_lower(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
    int nRet;
    DWORD i, dwLen;
-   char *pStr;
+   TCHAR *pStr;
 
-   if (argv[0]->IsString())
+   if (argv[0]->isString())
    {
       *ppResult = new NXSL_Value(argv[0]);
-      pStr = (*ppResult)->GetValueAsString(&dwLen);
+      pStr = (TCHAR *)(*ppResult)->getValueAsString(&dwLen);
       for(i = 0; i < dwLen; i++, pStr++)
          *pStr = tolower(*pStr);
       nRet = 0;
@@ -167,14 +167,14 @@ int F_lower(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 // String length
 //
 
-int F_length(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_length(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
    int nRet;
    DWORD dwLen;
 
-   if (argv[0]->IsString())
+   if (argv[0]->isString())
    {
-      argv[0]->GetValueAsString(&dwLen);
+      argv[0]->getValueAsString(&dwLen);
       *ppResult = new NXSL_Value(dwLen);
       nRet = 0;
    }
@@ -190,7 +190,7 @@ int F_length(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 // Minimal value from the list of values
 //
 
-int F_min(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_min(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
    int i;
    NXSL_Value *pCurr;
@@ -201,7 +201,7 @@ int F_min(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
    pCurr = argv[0];
    for(i = 1; i < argc; i++)
    {
-      if (!argv[i]->IsNumeric())
+      if (!argv[i]->isNumeric())
          return NXSL_ERR_NOT_NUMBER;
 
       if (argv[i]->LT(pCurr))
@@ -216,7 +216,7 @@ int F_min(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 // Maximal value from the list of values
 //
 
-int F_max(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_max(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
    int i;
    NXSL_Value *pCurr;
@@ -227,7 +227,7 @@ int F_max(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
    pCurr = argv[0];
    for(i = 0; i < argc; i++)
    {
-      if (!argv[i]->IsNumeric())
+      if (!argv[i]->isNumeric())
          return NXSL_ERR_NOT_NUMBER;
 
       if (argv[i]->GT(pCurr))
@@ -242,16 +242,16 @@ int F_max(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 // Check if IP address is within given range
 //
 
-int F_AddrInRange(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_AddrInRange(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
    int nRet;
    DWORD dwAddr, dwStart, dwEnd;
 
-   if (argv[0]->IsString() && argv[1]->IsString() && argv[2]->IsString())
+   if (argv[0]->isString() && argv[1]->isString() && argv[2]->isString())
    {
-      dwAddr = ntohl(inet_addr(argv[0]->GetValueAsCString()));
-      dwStart = ntohl(inet_addr(argv[1]->GetValueAsCString()));
-      dwEnd = ntohl(inet_addr(argv[2]->GetValueAsCString()));
+      dwAddr = ntohl(inet_addr(argv[0]->getValueAsCString()));
+      dwStart = ntohl(inet_addr(argv[1]->getValueAsCString()));
+      dwEnd = ntohl(inet_addr(argv[2]->getValueAsCString()));
       *ppResult = new NXSL_Value((LONG)(((dwAddr >= dwStart) && (dwAddr <= dwEnd)) ? 1 : 0));
       nRet = 0;
    }
@@ -267,16 +267,16 @@ int F_AddrInRange(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 // Check if IP address is within given subnet
 //
 
-int F_AddrInSubnet(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_AddrInSubnet(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
    int nRet;
    DWORD dwAddr, dwSubnet, dwMask;
 
-   if (argv[0]->IsString() && argv[1]->IsString() && argv[2]->IsString())
+   if (argv[0]->isString() && argv[1]->isString() && argv[2]->isString())
    {
-      dwAddr = ntohl(inet_addr(argv[0]->GetValueAsCString()));
-      dwSubnet = ntohl(inet_addr(argv[1]->GetValueAsCString()));
-      dwMask = ntohl(inet_addr(argv[2]->GetValueAsCString()));
+      dwAddr = ntohl(inet_addr(argv[0]->getValueAsCString()));
+      dwSubnet = ntohl(inet_addr(argv[1]->getValueAsCString()));
+      dwMask = ntohl(inet_addr(argv[2]->getValueAsCString()));
       *ppResult = new NXSL_Value((LONG)(((dwAddr & dwMask) == dwSubnet) ? 1 : 0));
       nRet = 0;
    }
@@ -293,7 +293,7 @@ int F_AddrInSubnet(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 // PATCH: by Edgar Chupit
 //
 
-int F_strftime(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_strftime(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {   
    TCHAR buffer[512];
    time_t tTime;
@@ -303,19 +303,19 @@ int F_strftime(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
    if ((argc == 0) || (argc > 3))
       return NXSL_ERR_INVALID_ARGUMENT_COUNT;
 
-   if (!argv[0]->IsString())
+   if (!argv[0]->isString())
       return NXSL_ERR_NOT_STRING;
        if (argc > 1)
        {
-               if (!argv[1]->IsNumeric() && !argv[1]->IsNull())
+               if (!argv[1]->isNumeric() && !argv[1]->isNull())
                        return NXSL_ERR_NOT_NUMBER;
-               tTime = (argv[1]->IsNull()) ? time(NULL) : (time_t)argv[1]->GetValueAsUInt64();
+               tTime = (argv[1]->isNull()) ? time(NULL) : (time_t)argv[1]->getValueAsUInt64();
 
                if (argc > 2)
                {
-                       if (!argv[2]->IsInteger())
+                       if (!argv[2]->isInteger())
                                return NXSL_ERR_BAD_CONDITION;
-                       bLocalTime = argv[2]->GetValueAsInt32() ? TRUE : FALSE;
+                       bLocalTime = argv[2]->getValueAsInt32() ? TRUE : FALSE;
                }
                else
                {
@@ -330,7 +330,7 @@ int F_strftime(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
        }
 
    ptm = bLocalTime ? localtime(&tTime) : gmtime(&tTime);
-   _tcsftime(buffer, 512, argv[0]->GetValueAsCString(), ptm);
+   _tcsftime(buffer, 512, argv[0]->getValueAsCString(), ptm);
    *ppResult = new NXSL_Value(buffer);   
    
    return 0;
@@ -342,14 +342,14 @@ int F_strftime(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 // PATCH: by Edgar Chupit
 //
 
-int F_SecondsToUptime(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_SecondsToUptime(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
    DWORD d, h, n;
 
-   if (!argv[0]->IsNumeric())
+   if (!argv[0]->isNumeric())
       return NXSL_ERR_NOT_NUMBER;
 
-   QWORD arg = argv[0]->GetValueAsUInt64();
+   QWORD arg = argv[0]->getValueAsUInt64();
 
    d = (DWORD)(arg / 86400);
    arg -= d * 86400;
@@ -374,7 +374,7 @@ int F_SecondsToUptime(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 // Get current time
 //
 
-int F_time(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_time(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
    *ppResult = new NXSL_Value((DWORD)time(NULL));
    return 0;
@@ -390,8 +390,8 @@ class NXSL_TimeClass : public NXSL_Class
 public:
    NXSL_TimeClass();
 
-   virtual NXSL_Value *GetAttr(NXSL_Object *pObject, char *pszAttr);
-       virtual void OnObjectDelete(NXSL_Object *object);
+   virtual NXSL_Value *getAttr(NXSL_Object *pObject, char *pszAttr);
+       virtual void onObjectDelete(NXSL_Object *object);
 };
 
 
@@ -405,12 +405,12 @@ NXSL_TimeClass::NXSL_TimeClass()
    strcpy(m_szName, "TIME");
 }
 
-NXSL_Value *NXSL_TimeClass::GetAttr(NXSL_Object *pObject, char *pszAttr)
+NXSL_Value *NXSL_TimeClass::getAttr(NXSL_Object *pObject, char *pszAttr)
 {
    struct tm *st;
    NXSL_Value *value;
 
-   st = (struct tm *)pObject->Data();
+   st = (struct tm *)pObject->getData();
    if (!strcmp(pszAttr, "sec") || !strcmp(pszAttr, "tm_sec"))
    {
       value = new NXSL_Value((LONG)st->tm_sec);
@@ -454,9 +454,9 @@ NXSL_Value *NXSL_TimeClass::GetAttr(NXSL_Object *pObject, char *pszAttr)
    return value;
 }
 
-void NXSL_TimeClass::OnObjectDelete(NXSL_Object *object)
+void NXSL_TimeClass::onObjectDelete(NXSL_Object *object)
 {
-       safe_free(object->Data());
+       safe_free(object->getData());
 }
 
 
@@ -471,7 +471,7 @@ static NXSL_TimeClass m_nxslTimeClass;
 // Return parsed local time
 //
 
-int F_localtime(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_localtime(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
        struct tm *p;
        time_t t;
@@ -482,10 +482,10 @@ int F_localtime(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
        }
        else if (argc == 1)
        {
-               if (!argv[0]->IsInteger())
+               if (!argv[0]->isInteger())
                        return NXSL_ERR_NOT_INTEGER;
 
-               t = argv[0]->GetValueAsUInt32();
+               t = argv[0]->getValueAsUInt32();
        }
        else
        {
@@ -502,7 +502,7 @@ int F_localtime(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 // Return parsed UTC time
 //
 
-int F_gmtime(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_gmtime(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
        struct tm *p;
        time_t t;
@@ -513,10 +513,10 @@ int F_gmtime(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
        }
        else if (argc == 1)
        {
-               if (!argv[0]->IsInteger())
+               if (!argv[0]->isInteger())
                        return NXSL_ERR_NOT_INTEGER;
 
-               t = argv[0]->GetValueAsUInt32();
+               t = argv[0]->getValueAsUInt32();
        }
        else
        {
@@ -537,25 +537,25 @@ int F_gmtime(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 //    substr(string, NULL, n) - first n characters
 //
 
-int F_substr(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_substr(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
        int nStart, nCount;
-       TCHAR *pBase;
+       const TCHAR *pBase;
        DWORD dwLen;
 
    if ((argc < 2) || (argc > 3))
       return NXSL_ERR_INVALID_ARGUMENT_COUNT;
 
-   if (!argv[0]->IsString())
+   if (!argv[0]->isString())
       return NXSL_ERR_NOT_STRING;
 
-       if (argv[1]->IsNull())
+       if (argv[1]->isNull())
        {
                nStart = 0;
        }
-       else if (argv[1]->IsInteger())
+       else if (argv[1]->isInteger())
        {
-               nStart = argv[1]->GetValueAsInt32();
+               nStart = argv[1]->getValueAsInt32();
                if (nStart > 0)
                        nStart--;
                else
@@ -568,9 +568,9 @@ int F_substr(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 
        if (argc == 3)
        {
-               if (!argv[2]->IsInteger())
+               if (!argv[2]->isInteger())
                        return NXSL_ERR_NOT_INTEGER;
-               nCount = argv[2]->GetValueAsInt32();
+               nCount = argv[2]->getValueAsInt32();
                if (nCount < 0)
                        nCount = 0;
        }
@@ -579,7 +579,7 @@ int F_substr(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
                nCount = -1;
        }
 
-       pBase = argv[0]->GetValueAsString(&dwLen);
+       pBase = argv[0]->getValueAsString(&dwLen);
        if ((DWORD)nStart < dwLen)
        {
                pBase += nStart;
@@ -605,17 +605,17 @@ int F_substr(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 //   d2x(value, padding) -> hex value padded vith zeros
 //
 
-int F_d2x(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_d2x(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
        TCHAR buffer[128], format[32];
 
    if ((argc < 1) || (argc > 2))
       return NXSL_ERR_INVALID_ARGUMENT_COUNT;
 
-   if (!argv[0]->IsInteger())
+   if (!argv[0]->isInteger())
       return NXSL_ERR_NOT_INTEGER;
 
-   if ((argc == 2) && (!argv[1]->IsInteger()))
+   if ((argc == 2) && (!argv[1]->isInteger()))
       return NXSL_ERR_NOT_INTEGER;
 
        if (argc == 1)
@@ -624,9 +624,9 @@ int F_d2x(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
        }
        else
        {
-               _sntprintf(format, 32, _T("%%0%dX"), argv[1]->GetValueAsInt32());
+               _sntprintf(format, 32, _T("%%0%dX"), argv[1]->getValueAsInt32());
        }
-       _sntprintf(buffer, 128, format, argv[0]->GetValueAsUInt32());
+       _sntprintf(buffer, 128, format, argv[0]->getValueAsUInt32());
        *ppResult = new NXSL_Value(buffer);
        return 0;
 }
@@ -637,25 +637,26 @@ int F_d2x(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 // Format: left(string, len, [pad])
 //
 
-int F_left(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_left(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
-       TCHAR *str, *newStr, pad;
+       const TCHAR *str;
+       TCHAR *newStr, pad;
        LONG newLen;
        DWORD i, len;
 
    if ((argc < 2) || (argc > 3))
       return NXSL_ERR_INVALID_ARGUMENT_COUNT;
 
-   if (!argv[1]->IsInteger())
+   if (!argv[1]->isInteger())
       return NXSL_ERR_NOT_INTEGER;
 
-   if ((!argv[0]->IsString()) ||
-                ((argc == 3) && (!argv[2]->IsString())))
+   if ((!argv[0]->isString()) ||
+                ((argc == 3) && (!argv[2]->isString())))
                return NXSL_ERR_NOT_STRING;
 
        if (argc == 3)
        {
-               pad = *(argv[2]->GetValueAsCString());
+               pad = *(argv[2]->getValueAsCString());
                if (pad == 0)
                        pad = _T(' ');
        }
@@ -664,11 +665,11 @@ int F_left(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
                pad = _T(' ');
        }
 
-       newLen = argv[1]->GetValueAsInt32();
+       newLen = argv[1]->getValueAsInt32();
        if (newLen < 0)
                newLen = 0;
 
-   str = argv[0]->GetValueAsString(&len);
+   str = argv[0]->getValueAsString(&len);
        if (len > (DWORD)newLen)
                len = (DWORD)newLen;
        newStr = (TCHAR *)malloc(newLen * sizeof(TCHAR));
@@ -686,25 +687,26 @@ int F_left(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 // Format: right(string, len, [pad])
 //
 
-int F_right(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_right(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
-       TCHAR *str, *newStr, pad;
+       const TCHAR *str;
+       TCHAR *newStr, pad;
        LONG newLen;
        DWORD i, len, shift;
 
    if ((argc < 2) || (argc > 3))
       return NXSL_ERR_INVALID_ARGUMENT_COUNT;
 
-   if (!argv[1]->IsInteger())
+   if (!argv[1]->isInteger())
       return NXSL_ERR_NOT_INTEGER;
 
-   if ((!argv[0]->IsString()) ||
-                ((argc == 3) && (!argv[2]->IsString())))
+   if ((!argv[0]->isString()) ||
+                ((argc == 3) && (!argv[2]->isString())))
                return NXSL_ERR_NOT_STRING;
 
        if (argc == 3)
        {
-               pad = *(argv[2]->GetValueAsCString());
+               pad = *(argv[2]->getValueAsCString());
                if (pad == 0)
                        pad = _T(' ');
        }
@@ -713,11 +715,11 @@ int F_right(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
                pad = _T(' ');
        }
 
-       newLen = argv[1]->GetValueAsInt32();
+       newLen = argv[1]->getValueAsInt32();
        if (newLen < 0)
                newLen = 0;
 
-   str = argv[0]->GetValueAsString(&len);
+   str = argv[0]->getValueAsString(&len);
        if (len > (DWORD)newLen)
        {
                shift = len - (DWORD)newLen;
@@ -741,7 +743,7 @@ int F_right(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 // Exit from script
 //
 
-int F_exit(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_exit(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
        if (argc > 1)
                return NXSL_ERR_INVALID_ARGUMENT_COUNT;
@@ -755,13 +757,13 @@ int F_exit(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 // Trim whitespace characters from the string
 //
 
-int F_trim(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_trim(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
-       if (!argv[0]->IsString())
+       if (!argv[0]->isString())
                return NXSL_ERR_NOT_STRING;
 
        DWORD len;
-       const TCHAR *string = argv[0]->GetValueAsString(&len);
+       const TCHAR *string = argv[0]->getValueAsString(&len);
        
        int i;
        for(i = 0; (i < (int)len) && (string[i] == _T(' ') || string[i] == _T('\t')); i++);
@@ -778,13 +780,13 @@ int F_trim(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 // Trim trailing whitespace characters from the string
 //
 
-int F_rtrim(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_rtrim(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
-       if (!argv[0]->IsString())
+       if (!argv[0]->isString())
                return NXSL_ERR_NOT_STRING;
 
        DWORD len;
-       const TCHAR *string = argv[0]->GetValueAsString(&len);
+       const TCHAR *string = argv[0]->getValueAsString(&len);
        
        int i;
        for(i = (int)len - 1; (i >= 0) && (string[i] == _T(' ') || string[i] == _T('\t')); i--);
@@ -798,13 +800,13 @@ int F_rtrim(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 // Trim leading whitespace characters from the string
 //
 
-int F_ltrim(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_ltrim(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
-       if (!argv[0]->IsString())
+       if (!argv[0]->isString())
                return NXSL_ERR_NOT_STRING;
 
        DWORD len;
-       const TCHAR *string = argv[0]->GetValueAsString(&len);
+       const TCHAR *string = argv[0]->getValueAsString(&len);
        
        int i;
        for(i = 0; (i < (int)len) && (string[i] == _T(' ') || string[i] == _T('\t')); i++);
@@ -812,3 +814,21 @@ int F_ltrim(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
        *ppResult = new NXSL_Value(&string[i], (int)len - i);
        return 0;
 }
+
+
+//
+// Trace
+//
+
+int F_trace(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
+{
+       if (!argv[0]->isInteger())
+               return NXSL_ERR_NOT_INTEGER;
+
+       if (!argv[1]->isString())
+               return NXSL_ERR_NOT_STRING;
+
+       program->trace(argv[0]->getValueAsInt32(), argv[1]->getValueAsCString());
+       *ppResult = new NXSL_Value();
+       return 0;
+}
index 1bd1a00..9ffe3c7 100644 (file)
@@ -61,7 +61,7 @@ NXSL_Lexer::~NXSL_Lexer()
 // Alternative input method
 //
 
-int NXSL_Lexer::LexerInput(char *pBuffer, int nMaxSize)
+int NXSL_Lexer::lexerInput(char *pBuffer, int nMaxSize)
 {
    int nBytes;
 
@@ -83,7 +83,7 @@ int NXSL_Lexer::LexerInput(char *pBuffer, int nMaxSize)
 // Report error
 //
 
-void NXSL_Lexer::Error(const char *pszText)
+void NXSL_Lexer::error(const char *pszText)
 {
-       m_pCompiler->Error(pszText);
+       m_pCompiler->error(pszText);
 }
index 7c03fa2..d10eb1a 100644 (file)
@@ -134,13 +134,13 @@ public:
        NXSL_Lexer(NXSL_Compiler *pCompiler, const TCHAR *pszCode);
        virtual ~NXSL_Lexer();
 
-       int LexerInput(char *pBuffer, int nMaxSize);
+       int lexerInput(char *pBuffer, int nMaxSize);
 
-       int GetCurrLine(void) { return m_nCurrLine; }
-       void Error(const char *pszText);
+       int getCurrLine() { return m_nCurrLine; }
+       void error(const char *pszText);
 
-   void SetErrorState(void) { m_bErrorState = TRUE; }
-   BOOL IsErrorState(void) { return m_bErrorState; }
+   void setErrorState() { m_bErrorState = TRUE; }
+   BOOL isErrorState() { return m_bErrorState; }
 };
 
 
@@ -158,25 +158,25 @@ protected:
        int m_idOpCode;
 
 public:
-   NXSL_Compiler(void);
+   NXSL_Compiler();
    ~NXSL_Compiler();
 
-   NXSL_Program *Compile(const TCHAR *pszSourceCode);
-   void Error(const char *pszMsg);
+   NXSL_Program *compile(const TCHAR *pszSourceCode);
+   void error(const char *pszMsg);
 
-   TCHAR *GetErrorText(void) { return CHECK_NULL(m_pszErrorText); }
+   const TCHAR *getErrorText() { return CHECK_NULL(m_pszErrorText); }
 
-   void PushAddr(DWORD dwAddr) { m_pAddrStack->Push(CAST_TO_POINTER(dwAddr, void *)); }
-   DWORD PopAddr(void);
-   DWORD PeekAddr(void);
+   void pushAddr(DWORD dwAddr) { m_pAddrStack->push(CAST_TO_POINTER(dwAddr, void *)); }
+   DWORD popAddr();
+   DWORD peekAddr();
 
-       void AddBreakAddr(DWORD dwAddr);
-       void CloseBreakLevel(NXSL_Program *pScript);
-       BOOL CanUseBreak(void) { return m_pBreakStack->Size() > 0; }
-       void NewBreakLevel(void) { m_pBreakStack->Push(new Queue); }
+       void addBreakAddr(DWORD dwAddr);
+       void closeBreakLevel(NXSL_Program *pScript);
+       BOOL canUseBreak() { return m_pBreakStack->getSize() > 0; }
+       void newBreakLevel() { m_pBreakStack->push(new Queue); }
 
-       void SetIdentifierOperation(int opcode) { m_idOpCode = opcode; }
-       int GetIdentifierOperation(void) { return m_idOpCode; }
+       void setIdentifierOperation(int opcode) { m_idOpCode = opcode; }
+       int getIdentifierOperation() { return m_idOpCode; }
 };
 
 
index 9e699df..f0d0d7b 100644 (file)
@@ -1,7 +1,7 @@
 /* 
 ** NetXMS - Network Management System
 ** NetXMS Scripting Language Interpreter
-** Copyright (C) 2005, 2006 Victor Kirhenshtein
+** Copyright (C) 2005-2010 Victor Kirhenshtein
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
 ** along with this program; if not, write to the Free Software
 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 **
-** $module: library.cpp
+** fILE: library.cpp
 **
 **/
 
@@ -28,7 +28,7 @@
 // Constructor
 //
 
-NXSL_Library::NXSL_Library(void)
+NXSL_Library::NXSL_Library()
 {
    m_mutex = MutexCreate();
    m_dwNumScripts = 0;
@@ -62,7 +62,7 @@ NXSL_Library::~NXSL_Library()
 // Add script to list
 //
 
-BOOL NXSL_Library::AddScript(DWORD dwId, char *pszName, NXSL_Program *pScript)
+BOOL NXSL_Library::addScript(DWORD dwId, const TCHAR *pszName, NXSL_Program *pScript)
 {
    DWORD i;
 
@@ -85,7 +85,7 @@ BOOL NXSL_Library::AddScript(DWORD dwId, char *pszName, NXSL_Program *pScript)
 // Delete script from list
 //
 
-void NXSL_Library::Delete(int nIndex)
+void NXSL_Library::deleteInternal(int nIndex)
 {
    delete m_ppScriptList[nIndex];
    free(m_ppszNames[nIndex]);
@@ -98,26 +98,26 @@ void NXSL_Library::Delete(int nIndex)
            sizeof(DWORD) * (m_dwNumScripts - nIndex));
 }
 
-void NXSL_Library::DeleteScript(char *pszName)
+void NXSL_Library::deleteScript(const TCHAR *pszName)
 {
    DWORD i;
 
    for(i = 0; i < m_dwNumScripts; i++)
       if (!stricmp(m_ppszNames[i], pszName))
       {
-         Delete(i);
+         deleteInternal(i);
          break;
       }
 }
 
-void NXSL_Library::DeleteScript(DWORD dwId)
+void NXSL_Library::deleteScript(DWORD dwId)
 {
    DWORD i;
 
    for(i = 0; i < m_dwNumScripts; i++)
       if (m_pdwIdList[i] == dwId)
       {
-         Delete(i);
+         deleteInternal(i);
          break;
       }
 }
@@ -127,7 +127,7 @@ void NXSL_Library::DeleteScript(DWORD dwId)
 // Find script by name
 //
 
-NXSL_Program *NXSL_Library::FindScript(char *pszName)
+NXSL_Program *NXSL_Library::findScript(const TCHAR *pszName)
 {
    DWORD i;
 
@@ -144,7 +144,7 @@ NXSL_Program *NXSL_Library::FindScript(char *pszName)
 // Fill NXCP message with script data
 //
 
-void NXSL_Library::FillMessage(CSCPMessage *pMsg)
+void NXSL_Library::fillMessage(CSCPMessage *pMsg)
 {
    DWORD i, dwId;
 
index fa1dee6..6ab8f12 100644 (file)
@@ -49,11 +49,11 @@ NXSL_Program LIBNXSL_EXPORTABLE *NXSLCompile(const TCHAR *pszSource,
    NXSL_Compiler compiler;
    NXSL_Program *pResult;
 
-   pResult = compiler.Compile(pszSource);
+   pResult = compiler.compile(pszSource);
    if (pResult == NULL)
    {
       if (pszError != NULL)
-         nx_strncpy(pszError, compiler.GetErrorText(), nBufSize);
+         nx_strncpy(pszError, compiler.getErrorText(), nBufSize);
    }
    return pResult;
 }
index a370493..3262809 100644 (file)
@@ -23,7 +23,7 @@ escape                \\[bnrt0\"]
 #endif\r
 \r
 #define YY_EXTRA_TYPE  NXSL_Lexer*\r
-#define YY_INPUT(buf, result, maxSize) { result = yyextra->LexerInput(buf, maxSize); }\r
+#define YY_INPUT(buf, result, maxSize) { result = yyextra->lexerInput(buf, maxSize); }\r
 \r
 #include "libnxsl.h"\r
 #include "parser.tab.hpp"\r
@@ -42,6 +42,8 @@ static void LexerError(const char *pszMsg, yyscan_t scanner);
 <INITIAL>"do"          return T_DO;\r
 <INITIAL>"else"                return T_ELSE;\r
 <INITIAL>"exit"                return T_EXIT;\r
+<INITIAL>"FALSE"    return T_FALSE;\r
+<INITIAL>"false"    return T_FALSE;\r
 <INITIAL>"for"         return T_FOR;\r
 <INITIAL>"if"          return T_IF;\r
 <INITIAL>"ilike"       return T_ILIKE;\r
@@ -51,6 +53,7 @@ static void LexerError(const char *pszMsg, yyscan_t scanner);
 <INITIAL>"like"                return T_LIKE;\r
 <INITIAL>"match"       return T_MATCH;\r
 <INITIAL>"NULL"                return T_NULL;\r
+<INITIAL>"null"                return T_NULL;\r
 <INITIAL>"print"       return T_PRINT;\r
 <INITIAL>"println"     return T_PRINTLN;\r
 <INITIAL>"real"                return T_TYPE_REAL;\r
@@ -58,6 +61,8 @@ static void LexerError(const char *pszMsg, yyscan_t scanner);
 <INITIAL>"string"      return T_TYPE_STRING;\r
 <INITIAL>"sub"         return T_SUB;\r
 <INITIAL>"switch"      return T_SWITCH;\r
+<INITIAL>"TRUE"                return T_TRUE;\r
+<INITIAL>"true"                return T_TRUE;\r
 <INITIAL>"uint32"      return T_TYPE_UINT32;\r
 <INITIAL>"uint64"      return T_TYPE_UINT64;\r
 <INITIAL>"use"         return T_USE;\r
@@ -227,5 +232,5 @@ static void LexerError(const char *pszMsg, yyscan_t scanner);
 \r
 static void LexerError(const char *pszMsg, yyscan_t scanner)\r
 {\r
-   yyget_extra(scanner)->Error(pszMsg);\r
+   yyget_extra(scanner)->error(pszMsg);\r
 }\r
index 34ed9e0..c15dc34 100644 (file)
@@ -44,6 +44,7 @@ int yylex(YYSTYPE *lvalp, yyscan_t scanner);
 %token T_DO
 %token T_ELSE
 %token T_EXIT
+%token T_FALSE
 %token T_FOR
 %token T_IF
 %token T_NULL
@@ -52,6 +53,7 @@ int yylex(YYSTYPE *lvalp, yyscan_t scanner);
 %token T_RETURN
 %token T_SUB
 %token T_SWITCH
+%token T_TRUE
 %token T_TYPE_INT32
 %token T_TYPE_INT64
 %token T_TYPE_REAL
@@ -106,13 +108,13 @@ Script:
        char szErrorText[256];
 
        // Add implicit return
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_RETURN));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_RETURN));
 
        // Add implicit main() function
-       if (!pScript->AddFunction("main", 0, szErrorText))
+       if (!pScript->addFunction("main", 0, szErrorText))
        {
-               pCompiler->Error(szErrorText);
-               pLexer->SetErrorState();
+               pCompiler->error(szErrorText);
+               pLexer->setErrorState();
        }
 }
 ;
@@ -130,7 +132,7 @@ ModuleComponent:
 UseStatement:
        T_USE AnyIdentifier ';'
 {
-       pScript->AddPreload($2);
+       pScript->addPreload($2);
 }
 ;
 
@@ -144,17 +146,17 @@ Function:
        {
                char szErrorText[256];
 
-               if (!pScript->AddFunction($2, INVALID_ADDRESS, szErrorText))
+               if (!pScript->addFunction($2, INVALID_ADDRESS, szErrorText))
                {
-                       pCompiler->Error(szErrorText);
-                       pLexer->SetErrorState();
+                       pCompiler->error(szErrorText);
+                       pLexer->setErrorState();
                }
                free($2);
-               pCompiler->SetIdentifierOperation(OPCODE_BIND);
+               pCompiler->setIdentifierOperation(OPCODE_BIND);
        }
        ParameterDeclaration Block
        {
-               pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_RET_NULL));
+               pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_RET_NULL));
        }
 ;
 
@@ -166,12 +168,12 @@ ParameterDeclaration:
 IdentifierList:
        T_IDENTIFIER 
        {
-               pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), pCompiler->GetIdentifierOperation(), $1));
+               pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), pCompiler->getIdentifierOperation(), $1));
        }
        ',' IdentifierList
 |      T_IDENTIFIER
        {
-               pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), pCompiler->GetIdentifierOperation(), $1));
+               pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), pCompiler->getIdentifierOperation(), $1));
        }
 ;
 
@@ -192,12 +194,12 @@ StatementOrBlock:
 Statement:
        Expression ';'
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_POP, (int)1));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_POP, (int)1));
 }
 |      BuiltinStatement
 |      ';'
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_NOP));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_NOP));
 }
 ;
 
@@ -205,156 +207,156 @@ Expression:
        '(' Expression ')'
 |      T_IDENTIFIER '=' Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_SET, $1));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_SET, $1));
 }
 |      Expression '[' Expression ']' '=' Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_SET_ELEMENT));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_SET_ELEMENT));
 }
 |      Expression '[' Expression ']'
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_GET_ELEMENT));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_GET_ELEMENT));
 }
 |      Expression T_REF T_IDENTIFIER '=' Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_SET_ATTRIBUTE, $3));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_SET_ATTRIBUTE, $3));
 }
 |      Expression T_REF T_IDENTIFIER
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_GET_ATTRIBUTE, $3));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_GET_ATTRIBUTE, $3));
 }
 |      '-' Expression          %prec NEGATE
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_NEG));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_NEG));
 }
 |      '!' Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_NOT));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_NOT));
 }
 |      '~' Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_BIT_NOT));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_BIT_NOT));
 }
 |      T_INC T_IDENTIFIER
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_INCP, $2));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_INCP, $2));
 }
 |      T_DEC T_IDENTIFIER
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_DECP, $2));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_DECP, $2));
 }
 |      T_IDENTIFIER T_INC      %prec T_POST_INC
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_INC, $1));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_INC, $1));
 }
 |      T_IDENTIFIER T_DEC      %prec T_POST_DEC
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_DEC, $1));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_DEC, $1));
 }
 |      Expression '+' Expression       
 { 
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_ADD));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_ADD));
 }
 |      Expression '-' Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_SUB));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_SUB));
 }
 |      Expression '*' Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_MUL));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_MUL));
 }
 |      Expression '/' Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_DIV));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_DIV));
 }
 |      Expression '%' Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_REM));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_REM));
 }
 |      Expression T_LIKE Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_LIKE));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_LIKE));
 }
 |      Expression T_ILIKE Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_ILIKE));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_ILIKE));
 }
 |      Expression T_MATCH Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_MATCH));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_MATCH));
 }
 |      Expression T_IMATCH Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_IMATCH));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_IMATCH));
 }
 |      Expression T_EQ Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_EQ));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_EQ));
 }
 |      Expression T_NE Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_NE));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_NE));
 }
 |      Expression '<' Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_LT));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_LT));
 }
 |      Expression T_LE Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_LE));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_LE));
 }
 |      Expression '>' Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_GT));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_GT));
 }
 |      Expression T_GE Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_GE));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_GE));
 }
 |      Expression '&' Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_BIT_AND));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_BIT_AND));
 }
 |      Expression '|' Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_BIT_OR));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_BIT_OR));
 }
 |      Expression '^' Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_BIT_XOR));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_BIT_XOR));
 }
 |      Expression T_AND Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_AND));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_AND));
 }
 |      Expression T_OR Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_OR));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_OR));
 }
 |      Expression T_LSHIFT Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_LSHIFT));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_LSHIFT));
 }
 |      Expression T_RSHIFT Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_RSHIFT));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_RSHIFT));
 }
 |      Expression '.' Expression
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_CONCAT));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_CONCAT));
 }
 |      Expression '?'
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_JZ, INVALID_ADDRESS));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_JZ, INVALID_ADDRESS));
 }
        Expression ':'
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_JMP, INVALID_ADDRESS));
-       pScript->ResolveLastJump(OPCODE_JZ);
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_JMP, INVALID_ADDRESS));
+       pScript->resolveLastJump(OPCODE_JZ);
 }       
        Expression
 {
-       pScript->ResolveLastJump(OPCODE_JMP);
+       pScript->resolveLastJump(OPCODE_JMP);
 }
 |      Operand
 ;
@@ -364,18 +366,18 @@ Operand:
 |      TypeCast
 |      T_IDENTIFIER
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_PUSH_VARIABLE, $1));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_PUSH_VARIABLE, $1));
 }
 |      Constant
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_PUSH_CONSTANT, $1));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_PUSH_CONSTANT, $1));
 }
 ;
 
 TypeCast:
        BuiltinType '(' Expression ')'
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(),
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(),
                                OPCODE_CAST, (int)$1));
 }
 ;
@@ -417,28 +419,28 @@ BuiltinStatement:
 |      ArrayStatement
 |      T_BREAK ';'
 {
-       if (pCompiler->CanUseBreak())
+       if (pCompiler->canUseBreak())
        {
-               pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_NOP));
-               pCompiler->AddBreakAddr(pScript->CodeSize() - 1);
+               pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_NOP));
+               pCompiler->addBreakAddr(pScript->getCodeSize() - 1);
        }
        else
        {
-               pCompiler->Error("\"break\" statement can be used only within loops and \"switch\" statements");
-               pLexer->SetErrorState();
+               pCompiler->error("\"break\" statement can be used only within loops and \"switch\" statements");
+               pLexer->setErrorState();
        }
 }
 |      T_CONTINUE ';'
 {
-       DWORD dwAddr = pCompiler->PeekAddr();
+       DWORD dwAddr = pCompiler->peekAddr();
        if (dwAddr != INVALID_ADDRESS)
        {
-               pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_JMP, dwAddr));
+               pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_JMP, dwAddr));
        }
        else
        {
-               pCompiler->Error("\"continue\" statement can be used only within loops");
-               pLexer->SetErrorState();
+               pCompiler->error("\"continue\" statement can be used only within loops");
+               pLexer->setErrorState();
        }
 }
 ;
@@ -446,48 +448,48 @@ BuiltinStatement:
 SimpleStatement:
        SimpleStatementKeyword Expression
 {
-       pScript->AddInstruction($1);
+       pScript->addInstruction($1);
 }
 |      SimpleStatementKeyword
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_PUSH_CONSTANT, new NXSL_Value));
-       pScript->AddInstruction($1);
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_PUSH_CONSTANT, new NXSL_Value));
+       pScript->addInstruction($1);
 }
 ;
 
 SimpleStatementKeyword:
        T_EXIT
 {
-       $$ = new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_EXIT);
+       $$ = new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_EXIT);
 }
 |      T_RETURN
 {
-       $$ = new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_RETURN);
+       $$ = new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_RETURN);
 }
 |      T_PRINT
 {
-       $$ = new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_PRINT);
+       $$ = new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_PRINT);
 }
 ;
 
 PrintlnStatement:
        T_PRINTLN Expression ';'
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_PUSH_CONSTANT, new NXSL_Value(_T("\n"))));
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_CONCAT));
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_PRINT));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_PUSH_CONSTANT, new NXSL_Value(_T("\n"))));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_CONCAT));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_PRINT));
 }
 |      T_PRINTLN ';'
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_PUSH_CONSTANT, new NXSL_Value(_T("\n"))));
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_PRINT));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_PUSH_CONSTANT, new NXSL_Value(_T("\n"))));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_PRINT));
 }
 ;
 
 IfStatement:
        T_IF '(' Expression ')' 
        {
-               pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_JZ, INVALID_ADDRESS));
+               pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_JZ, INVALID_ADDRESS));
        } 
        IfBody
 ;
@@ -495,19 +497,19 @@ IfStatement:
 IfBody:
        StatementOrBlock
 {
-       pScript->ResolveLastJump(OPCODE_JZ);
+       pScript->resolveLastJump(OPCODE_JZ);
 }
 |      StatementOrBlock ElseStatement
 {
-       pScript->ResolveLastJump(OPCODE_JMP);
+       pScript->resolveLastJump(OPCODE_JMP);
 }
 ;
 
 ElseStatement:
        T_ELSE
        {
-               pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_JMP, INVALID_ADDRESS));
-               pScript->ResolveLastJump(OPCODE_JZ);
+               pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_JMP, INVALID_ADDRESS));
+               pScript->resolveLastJump(OPCODE_JZ);
        }
        StatementOrBlock
 ;
@@ -515,66 +517,66 @@ ElseStatement:
 WhileStatement:
        T_WHILE
 {
-       pCompiler->PushAddr(pScript->CodeSize());
-       pCompiler->NewBreakLevel();
+       pCompiler->pushAddr(pScript->getCodeSize());
+       pCompiler->newBreakLevel();
 }
        '(' Expression ')'
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_JZ, INVALID_ADDRESS));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_JZ, INVALID_ADDRESS));
 }
        StatementOrBlock
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), 
-                               OPCODE_JMP, pCompiler->PopAddr()));
-       pScript->ResolveLastJump(OPCODE_JZ);
-       pCompiler->CloseBreakLevel(pScript);
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), 
+                               OPCODE_JMP, pCompiler->popAddr()));
+       pScript->resolveLastJump(OPCODE_JZ);
+       pCompiler->closeBreakLevel(pScript);
 }
 ;
 
 DoStatement:
        T_DO
 {
-       pCompiler->PushAddr(pScript->CodeSize());
-       pCompiler->NewBreakLevel();
+       pCompiler->pushAddr(pScript->getCodeSize());
+       pCompiler->newBreakLevel();
 }
        StatementOrBlock T_WHILE '(' Expression ')' ';'
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(),
-                               OPCODE_JNZ, pCompiler->PopAddr()));
-       pCompiler->CloseBreakLevel(pScript);
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(),
+                               OPCODE_JNZ, pCompiler->popAddr()));
+       pCompiler->closeBreakLevel(pScript);
 }
 ;
 
 SwitchStatement:
        T_SWITCH
 { 
-       pCompiler->NewBreakLevel();
+       pCompiler->newBreakLevel();
 }
        '(' Expression ')' '{' CaseList Default '}'
 {
-       pCompiler->CloseBreakLevel(pScript);
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_POP, (int)1));
+       pCompiler->closeBreakLevel(pScript);
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_POP, (int)1));
 }
 ;
 
 CaseList:
        Case
 { 
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_JMP, pScript->CodeSize() + 3));
-       pScript->ResolveLastJump(OPCODE_JZ);
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_JMP, pScript->getCodeSize() + 3));
+       pScript->resolveLastJump(OPCODE_JZ);
 }
        CaseList
 |      Case
 {
-       pScript->ResolveLastJump(OPCODE_JZ);
+       pScript->resolveLastJump(OPCODE_JZ);
 }
 ;
 
 Case:
        T_CASE Constant
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_CASE, $2));
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_JZ, INVALID_ADDRESS));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_CASE, $2));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_JZ, INVALID_ADDRESS));
 } 
        ':' StatementList
 ;
@@ -585,17 +587,17 @@ Default:
 ;
 
 ArrayStatement:
-       T_ARRAY { pCompiler->SetIdentifierOperation(OPCODE_ARRAY); } IdentifierList ';'
+       T_ARRAY { pCompiler->setIdentifierOperation(OPCODE_ARRAY); } IdentifierList ';'
 ;
 
 FunctionCall:
        FunctionName ParameterList ')'
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_CALL_EXTERNAL, $1, $2));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_CALL_EXTERNAL, $1, $2));
 }
 |      FunctionName ')'
 {
-       pScript->AddInstruction(new NXSL_Instruction(pLexer->GetCurrLine(), OPCODE_CALL_EXTERNAL, $1, 0));
+       pScript->addInstruction(new NXSL_Instruction(pLexer->getCurrLine(), OPCODE_CALL_EXTERNAL, $1, 0));
 }
 ;
 
@@ -637,6 +639,14 @@ Constant:
 {
        $$ = new NXSL_Value($1);
 }
+|      T_TRUE
+{
+       $$ = new NXSL_Value((LONG)1);
+}
+|      T_FALSE
+{
+       $$ = new NXSL_Value((LONG)0);
+}
 |      T_NULL
 {
        $$ = new NXSL_Value;
index 181bc31..34f5cff 100644 (file)
@@ -140,7 +140,7 @@ static int SelectResultType(int nType1, int nType2, int nOp)
 // Constructor
 //
 
-NXSL_Program::NXSL_Program(void)
+NXSL_Program::NXSL_Program()
 {
    m_ppInstructionSet = NULL;
    m_dwCodeSize = 0;
@@ -168,7 +168,7 @@ NXSL_Program::NXSL_Program(void)
 // Destructor
 //
 
-NXSL_Program::~NXSL_Program(void)
+NXSL_Program::~NXSL_Program()
 {
    DWORD i;
 
@@ -201,7 +201,7 @@ NXSL_Program::~NXSL_Program(void)
 // Add new instruction to set
 //
 
-void NXSL_Program::AddInstruction(NXSL_Instruction *pInstruction)
+void NXSL_Program::addInstruction(NXSL_Instruction *pInstruction)
 {
    m_ppInstructionSet = (NXSL_Instruction **)realloc(m_ppInstructionSet,
          sizeof(NXSL_Instruction *) * (m_dwCodeSize + 1));
@@ -213,7 +213,7 @@ void NXSL_Program::AddInstruction(NXSL_Instruction *pInstruction)
 // Resolve last jump with INVALID_ADDRESS to current address
 //
 
-void NXSL_Program::ResolveLastJump(int nOpCode)
+void NXSL_Program::resolveLastJump(int nOpCode)
 {
    DWORD i;
 
@@ -234,7 +234,7 @@ void NXSL_Program::ResolveLastJump(int nOpCode)
 // Create jump at given address replacing another instruction (usually NOP)
 //
 
-void NXSL_Program::CreateJumpAt(DWORD dwOpAddr, DWORD dwJumpAddr)
+void NXSL_Program::createJumpAt(DWORD dwOpAddr, DWORD dwJumpAddr)
 {
        int nLine;
 
@@ -252,7 +252,7 @@ void NXSL_Program::CreateJumpAt(DWORD dwOpAddr, DWORD dwJumpAddr)
 // Will use first free address if dwAddr == INVALID_ADDRESS
 //
 
-BOOL NXSL_Program::AddFunction(const char *pszName, DWORD dwAddr, char *pszError)
+BOOL NXSL_Program::addFunction(const char *pszName, DWORD dwAddr, char *pszError)
 {
    DWORD i;
 
@@ -275,7 +275,7 @@ BOOL NXSL_Program::AddFunction(const char *pszName, DWORD dwAddr, char *pszError
 // Add preload information
 //
 
-void NXSL_Program::AddPreload(char *pszName)
+void NXSL_Program::addPreload(char *pszName)
 {
    m_ppszPreloadList = (char **)realloc(m_ppszPreloadList, sizeof(char *) * (m_dwNumPreloads + 1));
    m_ppszPreloadList[m_dwNumPreloads] = pszName;
@@ -287,7 +287,7 @@ void NXSL_Program::AddPreload(char *pszName)
 // resolve local functions
 //
 
-void NXSL_Program::ResolveFunctions(void)
+void NXSL_Program::resolveFunctions(void)
 {
    DWORD i, j;
 
@@ -315,7 +315,7 @@ void NXSL_Program::ResolveFunctions(void)
 // Dump program to file (as text)
 //
 
-void NXSL_Program::Dump(FILE *pFile)
+void NXSL_Program::dump(FILE *pFile)
 {
    DWORD i;
 
@@ -352,11 +352,11 @@ void NXSL_Program::Dump(FILE *pFile)
             break;
          case OPCODE_PUSH_CONSTANT:
                        case OPCODE_CASE:
-            if (m_ppInstructionSet[i]->m_operand.m_pConstant->IsNull())
+            if (m_ppInstructionSet[i]->m_operand.m_pConstant->isNull())
                fprintf(pFile, "<null>\n");
             else
                fprintf(pFile, "\"%s\"\n", 
-                       m_ppInstructionSet[i]->m_operand.m_pConstant->GetValueAsCString());
+                       m_ppInstructionSet[i]->m_operand.m_pConstant->getValueAsCString());
             break;
          case OPCODE_POP:
             fprintf(pFile, "%d\n", m_ppInstructionSet[i]->m_nStackItems);
@@ -376,7 +376,7 @@ void NXSL_Program::Dump(FILE *pFile)
 // Report error
 //
 
-void NXSL_Program::Error(int nError)
+void NXSL_Program::error(int nError)
 {
    TCHAR szBuffer[1024];
 
@@ -394,7 +394,7 @@ void NXSL_Program::Error(int nError)
 // Returns 0 on success and -1 on error
 //
 
-int NXSL_Program::Run(NXSL_Environment *pEnv, DWORD argc, NXSL_Value **argv,
+int NXSL_Program::run(NXSL_Environment *pEnv, DWORD argc, NXSL_Value **argv,
                       NXSL_VariableSystem *pUserLocals, NXSL_VariableSystem **ppGlobals)
 {
    DWORD i, dwOrigCodeSize, dwOrigNumFn;
@@ -424,7 +424,7 @@ int NXSL_Program::Run(NXSL_Environment *pEnv, DWORD argc, NXSL_Value **argv,
    for(i = 0; i < argc; i++)
    {
       sprintf(szBuffer, "$%d", i + 1);
-      m_pLocals->Create(szBuffer, argv[i]);
+      m_pLocals->create(szBuffer, argv[i]);
    }
 
    // Preserve original global variables
@@ -433,9 +433,9 @@ int NXSL_Program::Run(NXSL_Environment *pEnv, DWORD argc, NXSL_Value **argv,
    // Preload modules
    for(i = 0; i < m_dwNumPreloads; i++)
    {
-      if (!pEnv->UseModule(this, m_ppszPreloadList[i]))
+      if (!pEnv->useModule(this, m_ppszPreloadList[i]))
       {
-         Error(NXSL_ERR_MODULE_NOT_FOUND);
+         error(NXSL_ERR_MODULE_NOT_FOUND);
          break;
       }
    }
@@ -450,13 +450,13 @@ int NXSL_Program::Run(NXSL_Environment *pEnv, DWORD argc, NXSL_Value **argv,
       {
          m_dwCurrPos = m_pFunctionList[i].m_dwAddr;
          while(m_dwCurrPos < m_dwCodeSize)
-            Execute();
+            execute();
          if (m_dwCurrPos != INVALID_ADDRESS)
-            m_pRetValue = (NXSL_Value *)m_pDataStack->Pop();
+            m_pRetValue = (NXSL_Value *)m_pDataStack->pop();
       }
       else
       {
-         Error(NXSL_ERR_NO_MAIN);
+         error(NXSL_ERR_NO_MAIN);
       }
    }
 
@@ -468,13 +468,13 @@ int NXSL_Program::Run(NXSL_Environment *pEnv, DWORD argc, NXSL_Value **argv,
    m_pGlobals = pSavedGlobals;
 
    // Cleanup
-   while((pValue = (NXSL_Value *)m_pDataStack->Pop()) != NULL)
+   while((pValue = (NXSL_Value *)m_pDataStack->pop()) != NULL)
       delete pValue;
    while(m_dwSubLevel > 0)
    {
       m_dwSubLevel--;
-      delete (NXSL_VariableSystem *)m_pCodeStack->Pop();
-      m_pCodeStack->Pop();
+      delete (NXSL_VariableSystem *)m_pCodeStack->pop();
+      m_pCodeStack->pop();
    }
    delete_and_null(m_pEnv);
    delete_and_null(m_pLocals);
@@ -498,15 +498,15 @@ int NXSL_Program::Run(NXSL_Environment *pEnv, DWORD argc, NXSL_Value **argv,
 // Set global variale
 //
 
-void NXSL_Program::SetGlobalVariable(const TCHAR *pszName, NXSL_Value *pValue)
+void NXSL_Program::setGlobalVariable(const TCHAR *pszName, NXSL_Value *pValue)
 {
    NXSL_Variable *pVar;
 
-       pVar = m_pGlobals->Find(pszName);
+       pVar = m_pGlobals->find(pszName);
    if (pVar == NULL)
-               pVar = m_pGlobals->Create(pszName, pValue);
+               pVar = m_pGlobals->create(pszName, pValue);
        else
-               pVar->Set(pValue);
+               pVar->setValue(pValue);
 }
 
 
@@ -514,20 +514,20 @@ void NXSL_Program::SetGlobalVariable(const TCHAR *pszName, NXSL_Value *pValue)
 // Find variable or create if does not exist
 //
 
-NXSL_Variable *NXSL_Program::FindOrCreateVariable(TCHAR *pszName)
+NXSL_Variable *NXSL_Program::findOrCreateVariable(TCHAR *pszName)
 {
    NXSL_Variable *pVar;
 
-   pVar = m_pConstants->Find(pszName);
+   pVar = m_pConstants->find(pszName);
    if (pVar == NULL)
    {
-      pVar = m_pGlobals->Find(pszName);
+      pVar = m_pGlobals->find(pszName);
       if (pVar == NULL)
       {
-         pVar = m_pLocals->Find(pszName);
+         pVar = m_pLocals->find(pszName);
          if (pVar == NULL)
          {
-            pVar = m_pLocals->Create(pszName);
+            pVar = m_pLocals->create(pszName);
          }
       }
    }
@@ -539,17 +539,17 @@ NXSL_Variable *NXSL_Program::FindOrCreateVariable(TCHAR *pszName)
 // Create variable if it does not exist, otherwise return NULL
 //
 
-NXSL_Variable *NXSL_Program::CreateVariable(TCHAR *pszName)
+NXSL_Variable *NXSL_Program::createVariable(TCHAR *pszName)
 {
    NXSL_Variable *pVar = NULL;
 
-   if (m_pConstants->Find(pszName) == NULL)
+   if (m_pConstants->find(pszName) == NULL)
    {
-      if (m_pGlobals->Find(pszName) == NULL)
+      if (m_pGlobals->find(pszName) == NULL)
       {
-         if (m_pLocals->Find(pszName) == NULL)
+         if (m_pLocals->find(pszName) == NULL)
          {
-            pVar = m_pLocals->Create(pszName);
+            pVar = m_pLocals->create(pszName);
          }
       }
    }
@@ -561,7 +561,7 @@ NXSL_Variable *NXSL_Program::CreateVariable(TCHAR *pszName)
 // Execute single instruction
 //
 
-void NXSL_Program::Execute(void)
+void NXSL_Program::execute()
 {
    NXSL_Instruction *cp;
    NXSL_Value *pValue;
@@ -575,77 +575,77 @@ void NXSL_Program::Execute(void)
    switch(cp->m_nOpCode)
    {
       case OPCODE_PUSH_CONSTANT:
-         m_pDataStack->Push(new NXSL_Value(cp->m_operand.m_pConstant));
+         m_pDataStack->push(new NXSL_Value(cp->m_operand.m_pConstant));
          break;
       case OPCODE_PUSH_VARIABLE:
-         pVar = FindOrCreateVariable(cp->m_operand.m_pszString);
-         m_pDataStack->Push(new NXSL_Value(pVar->Value()));
+         pVar = findOrCreateVariable(cp->m_operand.m_pszString);
+         m_pDataStack->push(new NXSL_Value(pVar->getValue()));
          break;
       case OPCODE_SET:
-         pVar = FindOrCreateVariable(cp->m_operand.m_pszString);
-         pValue = (NXSL_Value *)m_pDataStack->Peek();
+         pVar = findOrCreateVariable(cp->m_operand.m_pszString);
+         pValue = (NXSL_Value *)m_pDataStack->peek();
          if (pValue != NULL)
          {
-                               if (pValue->IsArray())
+                               if (pValue->isArray())
                                {
-                                       pVar->Set(new NXSL_Value(new NXSL_Array(pValue->GetValueAsArray())));
+                                       pVar->setValue(new NXSL_Value(new NXSL_Array(pValue->getValueAsArray())));
                                }
                                else
                                {
-                                       pVar->Set(new NXSL_Value(pValue));
+                                       pVar->setValue(new NXSL_Value(pValue));
                                }
          }
          else
          {
-            Error(NXSL_ERR_DATA_STACK_UNDERFLOW);
+            error(NXSL_ERR_DATA_STACK_UNDERFLOW);
          }
          break;
                case OPCODE_ARRAY:
-         pVar = CreateVariable(cp->m_operand.m_pszString);
+         pVar = createVariable(cp->m_operand.m_pszString);
                        if (pVar != NULL)
                        {
-                               pVar->Set(new NXSL_Value(new NXSL_Array));
+                               pVar->setValue(new NXSL_Value(new NXSL_Array));
                        }
                        else
                        {
-                               Error(NXSL_ERR_VARIABLE_ALREADY_EXIST);
+                               error(NXSL_ERR_VARIABLE_ALREADY_EXIST);
                        }
                        break;
                case OPCODE_SET_ELEMENT:        // Set array element; stack should contain: array index value (top)
-                       pValue = (NXSL_Value *)m_pDataStack->Pop();
+                       pValue = (NXSL_Value *)m_pDataStack->pop();
                        if (pValue != NULL)
                        {
                                NXSL_Value *array, *index;
 
-                               index = (NXSL_Value *)m_pDataStack->Pop();
-                               array = (NXSL_Value *)m_pDataStack->Pop();
+                               index = (NXSL_Value *)m_pDataStack->pop();
+                               array = (NXSL_Value *)m_pDataStack->pop();
                                if ((index != NULL) && (array != NULL))
                                {
-                                       if (!index->IsInteger())
+                                       if (!index->isInteger())
                                        {
-                                               Error(NXSL_ERR_INDEX_NOT_INTEGER);
+                                               error(NXSL_ERR_INDEX_NOT_INTEGER);
                                        }
-                                       else if (!array->IsArray())
+                                       else if (!array->isArray())
                                        {
-                                               Error(NXSL_ERR_NOT_ARRAY);
+                                               error(NXSL_ERR_NOT_ARRAY);
                                        }
                                        else
                                        {
-                                               if (pValue->IsArray())
+                                               if (pValue->isArray())
                                                {
-                                                       array->GetValueAsArray()->Set(index->GetValueAsInt32(), new NXSL_Value(new NXSL_Array(pValue->GetValueAsArray())));
+                                                       array->getValueAsArray()->set(index->getValueAsInt32(), new NXSL_Value(new NXSL_Array(pValue->getValueAsArray())));
                                                }
                                                else
                                                {
-                                                       array->GetValueAsArray()->Set(index->GetValueAsInt32(), new NXSL_Value(pValue));
+                                                       array->getValueAsArray()->set(index->getValueAsInt32(), new NXSL_Value(pValue));
                                                }
-                                               m_pDataStack->Push(pValue);
+                                               m_pDataStack->push(pValue);
                                                pValue = NULL;          // Prevent deletion
                                        }
                                }
                                else
                                {
-                                       Error(NXSL_ERR_DATA_STACK_UNDERFLOW);
+                                       error(NXSL_ERR_DATA_STACK_UNDERFLOW);
                                }
                                delete index;
                                delete array;
@@ -653,159 +653,159 @@ void NXSL_Program::Execute(void)
                        }
          else
          {
-            Error(NXSL_ERR_DATA_STACK_UNDERFLOW);
+            error(NXSL_ERR_DATA_STACK_UNDERFLOW);
          }
                        break;
                case OPCODE_GET_ELEMENT:        // Get array element; stack should contain: array index (top)
-                       pValue = (NXSL_Value *)m_pDataStack->Pop();
+                       pValue = (NXSL_Value *)m_pDataStack->pop();
                        if (pValue != NULL)
                        {
                                NXSL_Value *array;
 
-                               array = (NXSL_Value *)m_pDataStack->Pop();
+                               array = (NXSL_Value *)m_pDataStack->pop();
                                if (array != NULL)
                                {
-                                       if (array->IsArray())
+                                       if (array->isArray())
                                        {
-                                               if (pValue->IsInteger())
+                                               if (pValue->isInteger())
                                                {
                                                        NXSL_Value *element;
 
-                                                       element = array->GetValueAsArray()->Get(pValue->GetValueAsInt32());
-                                                       m_pDataStack->Push((element != NULL) ? new NXSL_Value(element) : new NXSL_Value);
+                                                       element = array->getValueAsArray()->get(pValue->getValueAsInt32());
+                                                       m_pDataStack->push((element != NULL) ? new NXSL_Value(element) : new NXSL_Value);
                                                }
                                                else
                                                {
-                                                       Error(NXSL_ERR_INDEX_NOT_INTEGER);
+                                                       error(NXSL_ERR_INDEX_NOT_INTEGER);
                                                }
                                        }
                                        else
                                        {
-                                               Error(NXSL_ERR_NOT_ARRAY);
+                                               error(NXSL_ERR_NOT_ARRAY);
                                        }
                                        delete array;
                                }
                                else
                                {
-                                       Error(NXSL_ERR_DATA_STACK_UNDERFLOW);
+                                       error(NXSL_ERR_DATA_STACK_UNDERFLOW);
                                }
                                delete pValue;
                        }
          else
          {
-            Error(NXSL_ERR_DATA_STACK_UNDERFLOW);
+            error(NXSL_ERR_DATA_STACK_UNDERFLOW);
          }
                        break;
       case OPCODE_CAST:
-         pValue = (NXSL_Value *)m_pDataStack->Peek();
+         pValue = (NXSL_Value *)m_pDataStack->peek();
          if (pValue != NULL)
          {
-            if (!pValue->Convert(cp->m_nStackItems))
+            if (!pValue->convert(cp->m_nStackItems))
             {
-               Error(NXSL_ERR_TYPE_CAST);
+               error(NXSL_ERR_TYPE_CAST);
             }
          }
          else
          {
-            Error(NXSL_ERR_DATA_STACK_UNDERFLOW);
+            error(NXSL_ERR_DATA_STACK_UNDERFLOW);
          }
          break;
       case OPCODE_POP:
          for(i = 0; i < cp->m_nStackItems; i++)
-            delete (NXSL_Value *)m_pDataStack->Pop();
+            delete (NXSL_Value *)m_pDataStack->pop();
          break;
       case OPCODE_JMP:
          dwNext = cp->m_operand.m_dwAddr;
          break;
       case OPCODE_JZ:
       case OPCODE_JNZ:
-         pValue = (NXSL_Value *)m_pDataStack->Pop();
+         pValue = (NXSL_Value *)m_pDataStack->pop();
          if (pValue != NULL)
          {
-            if (pValue->IsNumeric())
+            if (pValue->isNumeric())
             {
-               if (cp->m_nOpCode == OPCODE_JZ ? pValue->IsZero() : pValue->IsNonZero())
+               if (cp->m_nOpCode == OPCODE_JZ ? pValue->isZero() : pValue->isNonZero())
                   dwNext = cp->m_operand.m_dwAddr;
             }
             else
             {
-               Error(3);
+               error(3);
             }
             delete pValue;
          }
          else
          {
-            Error(NXSL_ERR_DATA_STACK_UNDERFLOW);
+            error(NXSL_ERR_DATA_STACK_UNDERFLOW);
          }
          break;
       case OPCODE_CALL:
          dwNext = cp->m_operand.m_dwAddr;
-         CallFunction(cp->m_nStackItems);
+         callFunction(cp->m_nStackItems);
          break;
       case OPCODE_CALL_EXTERNAL:
-         pFunc = m_pEnv->FindFunction(cp->m_operand.m_pszString);
+         pFunc = m_pEnv->findFunction(cp->m_operand.m_pszString);
          if (pFunc != NULL)
          {
             if ((cp->m_nStackItems == pFunc->m_iNumArgs) ||
                 (pFunc->m_iNumArgs == -1))
             {
-               if (m_pDataStack->Size() >= cp->m_nStackItems)
+               if (m_pDataStack->getSize() >= cp->m_nStackItems)
                {
                   nRet = pFunc->m_pfHandler(cp->m_nStackItems,
-                                            (NXSL_Value **)m_pDataStack->PeekList(cp->m_nStackItems),
-                                            &pValue);
+                                            (NXSL_Value **)m_pDataStack->peekList(cp->m_nStackItems),
+                                            &pValue, this);
                   if (nRet == 0)
                   {
                      for(i = 0; i < cp->m_nStackItems; i++)
-                        m_pDataStack->Pop();
-                     m_pDataStack->Push(pValue);
+                        m_pDataStack->pop();
+                     m_pDataStack->push(pValue);
                   }
                   else if (nRet == NXSL_STOP_SCRIPT_EXECUTION)
                                                {
-                     m_pDataStack->Push(pValue);
+                     m_pDataStack->push(pValue);
                                    dwNext = m_dwCodeSize;
                                                }
                                                else
                   {
                      // Execution error inside function
-                     Error(nRet);
+                     error(nRet);
                   }
                }
                else
                {
-                  Error(NXSL_ERR_DATA_STACK_UNDERFLOW);
+                  error(NXSL_ERR_DATA_STACK_UNDERFLOW);
                }
             }
             else
             {
-               Error(NXSL_ERR_INVALID_ARGUMENT_COUNT);
+               error(NXSL_ERR_INVALID_ARGUMENT_COUNT);
             }
          }
          else
          {
             DWORD dwAddr;
 
-            dwAddr = GetFunctionAddress(cp->m_operand.m_pszString);
+            dwAddr = getFunctionAddress(cp->m_operand.m_pszString);
             if (dwAddr != INVALID_ADDRESS)
             {
                dwNext = dwAddr;
-               CallFunction(cp->m_nStackItems);
+               callFunction(cp->m_nStackItems);
             }
             else
             {
-               Error(NXSL_ERR_NO_FUNCTION);
+               error(NXSL_ERR_NO_FUNCTION);
             }
          }
          break;
       case OPCODE_RET_NULL:
-         m_pDataStack->Push(new NXSL_Value);
+         m_pDataStack->push(new NXSL_Value);
       case OPCODE_RETURN:
          if (m_dwSubLevel > 0)
          {
             m_dwSubLevel--;
             delete m_pLocals;
-            m_pLocals = (NXSL_VariableSystem *)m_pCodeStack->Pop();
-            dwNext = CAST_FROM_POINTER(m_pCodeStack->Pop(), DWORD);
+            m_pLocals = (NXSL_VariableSystem *)m_pCodeStack->pop();
+            dwNext = CAST_FROM_POINTER(m_pCodeStack->pop(), DWORD);
          }
          else
          {
@@ -815,44 +815,44 @@ void NXSL_Program::Execute(void)
          break;
       case OPCODE_BIND:
          sprintf(szBuffer, "$%d", m_nBindPos++);
-         pVar = m_pLocals->Find(szBuffer);
-         pValue = (pVar != NULL) ? new NXSL_Value(pVar->Value()) : new NXSL_Value;
-         pVar = m_pLocals->Find(cp->m_operand.m_pszString);
+         pVar = m_pLocals->find(szBuffer);
+         pValue = (pVar != NULL) ? new NXSL_Value(pVar->getValue()) : new NXSL_Value;
+         pVar = m_pLocals->find(cp->m_operand.m_pszString);
          if (pVar == NULL)
-            m_pLocals->Create(cp->m_operand.m_pszString, pValue);
+            m_pLocals->create(cp->m_operand.m_pszString, pValue);
          else
-            pVar->Set(pValue);
+            pVar->setValue(pValue);
          break;
       case OPCODE_PRINT:
-         pValue = (NXSL_Value *)m_pDataStack->Pop();
+         pValue = (NXSL_Value *)m_pDataStack->pop();
          if (pValue != NULL)
          {
-            char *pszText;
+            const TCHAR *pszText;
             DWORD dwLen;
 
-            if (m_pEnv->GetStdOut() != NULL)
+            if (m_pEnv->getStdOut() != NULL)
             {
-               pszText = pValue->GetValueAsString(&dwLen);
+               pszText = pValue->getValueAsString(&dwLen);
                if (pszText != NULL)
-                  fwrite(pszText, dwLen, 1, m_pEnv->GetStdOut());
+                  fwrite(pszText, dwLen, 1, m_pEnv->getStdOut());
                else
-                  fputs("(null)", m_pEnv->GetStdOut());
+                  fputs("(null)", m_pEnv->getStdOut());
             }
             delete pValue;
          }
          else
          {
-            Error(NXSL_ERR_DATA_STACK_UNDERFLOW);
+            error(NXSL_ERR_DATA_STACK_UNDERFLOW);
          }
          break;
       case OPCODE_EXIT:
-                       if (m_pDataStack->Size() > 0)
+                       if (m_pDataStack->getSize() > 0)
          {
             dwNext = m_dwCodeSize;
          }
          else
          {
-            Error(NXSL_ERR_DATA_STACK_UNDERFLOW);
+            error(NXSL_ERR_DATA_STACK_UNDERFLOW);
          }
          break;
       case OPCODE_ADD:
@@ -879,129 +879,129 @@ void NXSL_Program::Execute(void)
       case OPCODE_LSHIFT:
       case OPCODE_RSHIFT:
                case OPCODE_CASE:
-         DoBinaryOperation(cp->m_nOpCode);
+         doBinaryOperation(cp->m_nOpCode);
          break;
       case OPCODE_NEG:
       case OPCODE_NOT:
       case OPCODE_BIT_NOT:
-         DoUnaryOperation(cp->m_nOpCode);
+         doUnaryOperation(cp->m_nOpCode);
          break;
       case OPCODE_INC:  // Post increment/decrement
       case OPCODE_DEC:
-         pVar = FindOrCreateVariable(cp->m_operand.m_pszString);
-         pValue = pVar->Value();
-         if (pValue->IsNumeric())
+         pVar = findOrCreateVariable(cp->m_operand.m_pszString);
+         pValue = pVar->getValue();
+         if (pValue->isNumeric())
          {
-            m_pDataStack->Push(new NXSL_Value(pValue));
+            m_pDataStack->push(new NXSL_Value(pValue));
             if (cp->m_nOpCode == OPCODE_INC)
-               pValue->Increment();
+               pValue->increment();
             else
-               pValue->Decrement();
+               pValue->decrement();
          }
          else
          {
-            Error(NXSL_ERR_NOT_NUMBER);
+            error(NXSL_ERR_NOT_NUMBER);
          }
          break;
       case OPCODE_INCP: // Pre increment/decrement
       case OPCODE_DECP:
-         pVar = FindOrCreateVariable(cp->m_operand.m_pszString);
-         pValue = pVar->Value();
-         if (pValue->IsNumeric())
+         pVar = findOrCreateVariable(cp->m_operand.m_pszString);
+         pValue = pVar->getValue();
+         if (pValue->isNumeric())
          {
             if (cp->m_nOpCode == OPCODE_INC)
-               pValue->Increment();
+               pValue->increment();
             else
-               pValue->Decrement();
-            m_pDataStack->Push(new NXSL_Value(pValue));
+               pValue->decrement();
+            m_pDataStack->push(new NXSL_Value(pValue));
          }
          else
          {
-            Error(NXSL_ERR_NOT_NUMBER);
+            error(NXSL_ERR_NOT_NUMBER);
          }
          break;
       case OPCODE_GET_ATTRIBUTE:
-         pValue = (NXSL_Value *)m_pDataStack->Pop();
+         pValue = (NXSL_Value *)m_pDataStack->pop();
          if (pValue != NULL)
          {
-            if (pValue->DataType() == NXSL_DT_OBJECT)
+            if (pValue->getDataType() == NXSL_DT_OBJECT)
             {
                NXSL_Object *pObj;
                NXSL_Value *pAttr;
 
-               pObj = pValue->GetValueAsObject();
+               pObj = pValue->getValueAsObject();
                if (pObj != NULL)
                {
-                  pAttr = pObj->Class()->GetAttr(pObj, cp->m_operand.m_pszString);
+                  pAttr = pObj->getClass()->getAttr(pObj, cp->m_operand.m_pszString);
                   if (pAttr != NULL)
                   {
-                     m_pDataStack->Push(pAttr);
+                     m_pDataStack->push(pAttr);
                   }
                   else
                   {
-                     Error(NXSL_ERR_NO_SUCH_ATTRIBUTE);
+                     error(NXSL_ERR_NO_SUCH_ATTRIBUTE);
                   }
                }
                else
                {
-                  Error(NXSL_ERR_INTERNAL);
+                  error(NXSL_ERR_INTERNAL);
                }
             }
             else
             {
-               Error(NXSL_ERR_NOT_OBJECT);
+               error(NXSL_ERR_NOT_OBJECT);
             }
             delete pValue;
          }
          else
          {
-            Error(NXSL_ERR_DATA_STACK_UNDERFLOW);
+            error(NXSL_ERR_DATA_STACK_UNDERFLOW);
          }
          break;
       case OPCODE_SET_ATTRIBUTE:
-         pValue = (NXSL_Value *)m_pDataStack->Pop();
+         pValue = (NXSL_Value *)m_pDataStack->pop();
          if (pValue != NULL)
          {
-                               NXSL_Value *pReference = (NXSL_Value *)m_pDataStack->Pop();
+                               NXSL_Value *pReference = (NXSL_Value *)m_pDataStack->pop();
                                if (pReference != NULL)
                                {
-                                       if (pReference->DataType() == NXSL_DT_OBJECT)
+                                       if (pReference->getDataType() == NXSL_DT_OBJECT)
                                        {
                                                NXSL_Object *pObj;
 
-                                               pObj = pReference->GetValueAsObject();
+                                               pObj = pReference->getValueAsObject();
                                                if (pObj != NULL)
                                                {
-                                                       if (pObj->Class()->SetAttr(pObj, cp->m_operand.m_pszString, pValue))
+                                                       if (pObj->getClass()->setAttr(pObj, cp->m_operand.m_pszString, pValue))
                                                        {
-                                                               m_pDataStack->Push(pValue);
+                                                               m_pDataStack->push(pValue);
                                                                pValue = NULL;
                                                        }
                                                        else
                                                        {
-                                                               Error(NXSL_ERR_NO_SUCH_ATTRIBUTE);
+                                                               error(NXSL_ERR_NO_SUCH_ATTRIBUTE);
                                                        }
                                                }
                                                else
                                                {
-                                                       Error(NXSL_ERR_INTERNAL);
+                                                       error(NXSL_ERR_INTERNAL);
                                                }
                                        }
                                        else
                                        {
-                                               Error(NXSL_ERR_NOT_OBJECT);
+                                               error(NXSL_ERR_NOT_OBJECT);
                                        }
                                        delete pReference;
                                }
                                else
                                {
-                                       Error(NXSL_ERR_DATA_STACK_UNDERFLOW);
+                                       error(NXSL_ERR_DATA_STACK_UNDERFLOW);
                                }
                                delete pValue;
          }
          else
          {
-            Error(NXSL_ERR_DATA_STACK_UNDERFLOW);
+            error(NXSL_ERR_DATA_STACK_UNDERFLOW);
          }
          break;
       default:
@@ -1017,10 +1017,10 @@ void NXSL_Program::Execute(void)
 // Perform binary operation on two operands from stack and push result to stack
 //
 
-void NXSL_Program::DoBinaryOperation(int nOpCode)
+void NXSL_Program::doBinaryOperation(int nOpCode)
 {
    NXSL_Value *pVal1, *pVal2, *pRes = NULL;
-   char *pszText1, *pszText2;
+   const TCHAR *pszText1, *pszText2;
    DWORD dwLen1, dwLen2;
    int nType;
    LONG nResult;
@@ -1028,52 +1028,52 @@ void NXSL_Program::DoBinaryOperation(int nOpCode)
        if (nOpCode == OPCODE_CASE)
        {
                pVal1 = m_ppInstructionSet[m_dwCurrPos]->m_operand.m_pConstant;
-               pVal2 = (NXSL_Value *)m_pDataStack->Peek();
+               pVal2 = (NXSL_Value *)m_pDataStack->peek();
        }
        else
        {
-               pVal2 = (NXSL_Value *)m_pDataStack->Pop();
-               pVal1 = (NXSL_Value *)m_pDataStack->Pop();
+               pVal2 = (NXSL_Value *)m_pDataStack->pop();
+               pVal1 = (NXSL_Value *)m_pDataStack->pop();
        }
 
    if ((pVal1 != NULL) && (pVal2 != NULL))
    {
-      if ((!pVal1->IsNull() && !pVal2->IsNull()) ||
+      if ((!pVal1->isNull() && !pVal2->isNull()) ||
           (nOpCode == OPCODE_EQ) || (nOpCode == OPCODE_NE) || (nOpCode == OPCODE_CASE))
       {
-         if (pVal1->IsNumeric() && pVal2->IsNumeric() &&
+         if (pVal1->isNumeric() && pVal2->isNumeric() &&
              (nOpCode != OPCODE_CONCAT) && (nOpCode != OPCODE_LIKE))
          {
-            nType = SelectResultType(pVal1->DataType(), pVal2->DataType(), nOpCode);
+            nType = SelectResultType(pVal1->getDataType(), pVal2->getDataType(), nOpCode);
             if (nType != NXSL_DT_NULL)
             {
-               if ((pVal1->Convert(nType)) && (pVal2->Convert(nType)))
+               if ((pVal1->convert(nType)) && (pVal2->convert(nType)))
                {
                   switch(nOpCode)
                   {
                      case OPCODE_ADD:
                         pRes = pVal1;
-                        pRes->Add(pVal2);
+                        pRes->add(pVal2);
                         delete pVal2;
                         break;
                      case OPCODE_SUB:
                         pRes = pVal1;
-                        pRes->Sub(pVal2);
+                        pRes->sub(pVal2);
                         delete pVal2;
                         break;
                      case OPCODE_MUL:
                         pRes = pVal1;
-                        pRes->Mul(pVal2);
+                        pRes->mul(pVal2);
                         delete pVal2;
                         break;
                      case OPCODE_DIV:
                         pRes = pVal1;
-                        pRes->Div(pVal2);
+                        pRes->div(pVal2);
                         delete pVal2;
                         break;
                      case OPCODE_REM:
                         pRes = pVal1;
-                        pRes->Rem(pVal2);
+                        pRes->rem(pVal2);
                         delete pVal2;
                         break;
                      case OPCODE_EQ:
@@ -1109,37 +1109,37 @@ void NXSL_Program::DoBinaryOperation(int nOpCode)
                         break;
                      case OPCODE_LSHIFT:
                         pRes = pVal1;
-                        pRes->LShift(pVal2->GetValueAsInt32());
+                        pRes->lshift(pVal2->getValueAsInt32());
                         delete pVal2;
                         break;
                      case OPCODE_RSHIFT:
                         pRes = pVal1;
-                        pRes->RShift(pVal2->GetValueAsInt32());
+                        pRes->rshift(pVal2->getValueAsInt32());
                         delete pVal2;
                         break;
                      case OPCODE_BIT_AND:
                         pRes = pVal1;
-                        pRes->BitAnd(pVal2);
+                        pRes->bitAnd(pVal2);
                         delete pVal2;
                         break;
                      case OPCODE_BIT_OR:
                         pRes = pVal1;
-                        pRes->BitOr(pVal2);
+                        pRes->bitOr(pVal2);
                         delete pVal2;
                         break;
                      case OPCODE_BIT_XOR:
                         pRes = pVal1;
-                        pRes->BitXor(pVal2);
+                        pRes->bitXor(pVal2);
                         delete pVal2;
                         break;
                      case OPCODE_AND:
-                        nResult = (pVal1->IsNonZero() && pVal2->IsNonZero());
+                        nResult = (pVal1->isNonZero() && pVal2->isNonZero());
                         delete pVal1;
                         delete pVal2;
                         pRes = new NXSL_Value(nResult);
                         break;
                      case OPCODE_OR:
-                        nResult = (pVal1->IsNonZero() || pVal2->IsNonZero());
+                        nResult = (pVal1->isNonZero() || pVal2->isNonZero());
                         delete pVal1;
                         delete pVal2;
                         pRes = new NXSL_Value(nResult);
@@ -1148,18 +1148,18 @@ void NXSL_Program::DoBinaryOperation(int nOpCode)
                         pRes = new NXSL_Value((LONG)pVal1->EQ(pVal2));
                         break;
                      default:
-                        Error(NXSL_ERR_INTERNAL);
+                        error(NXSL_ERR_INTERNAL);
                         break;
                   }
                }
                else
                {
-                  Error(NXSL_ERR_TYPE_CAST);
+                  error(NXSL_ERR_TYPE_CAST);
                }
             }
             else
             {
-               Error(NXSL_ERR_REAL_VALUE);
+               error(NXSL_ERR_REAL_VALUE);
             }
          }
          else
@@ -1169,18 +1169,18 @@ void NXSL_Program::DoBinaryOperation(int nOpCode)
                case OPCODE_EQ:
                case OPCODE_NE:
                                        case OPCODE_CASE:
-                  if (pVal1->IsNull() && pVal2->IsNull())
+                  if (pVal1->isNull() && pVal2->isNull())
                   {
                      nResult = 1;
                   }
-                  else if (pVal1->IsNull() || pVal2->IsNull())
+                  else if (pVal1->isNull() || pVal2->isNull())
                   {
                      nResult = 0;
                   }
                   else
                   {
-                     pszText1 = pVal1->GetValueAsString(&dwLen1);
-                     pszText2 = pVal2->GetValueAsString(&dwLen2);
+                     pszText1 = pVal1->getValueAsString(&dwLen1);
+                     pszText2 = pVal2->getValueAsString(&dwLen2);
                      if (dwLen1 == dwLen2)
                         nResult = !memcmp(pszText1, pszText2, dwLen1);
                      else
@@ -1194,48 +1194,48 @@ void NXSL_Program::DoBinaryOperation(int nOpCode)
                   pRes = new NXSL_Value((nOpCode == OPCODE_NE) ? !nResult : nResult);
                   break;
                case OPCODE_CONCAT:
-                  if (pVal1->IsNull() || pVal2->IsNull())
+                  if (pVal1->isNull() || pVal2->isNull())
                   {
-                     Error(NXSL_ERR_NULL_VALUE);
+                     error(NXSL_ERR_NULL_VALUE);
                   }
-                  else if (pVal1->IsObject() || pVal2->IsObject())
+                  else if (pVal1->isObject() || pVal2->isObject())
                   {
-                     Error(NXSL_ERR_INVALID_OBJECT_OPERATION);
+                     error(NXSL_ERR_INVALID_OBJECT_OPERATION);
                   }
                   else
                   {
                      pRes = pVal1;
-                     pszText2 = pVal2->GetValueAsString(&dwLen2);
-                     pRes->Concatenate(pszText2, dwLen2);
+                     pszText2 = pVal2->getValueAsString(&dwLen2);
+                     pRes->concatenate(pszText2, dwLen2);
                      delete pVal2;
                   }
                   break;
                case OPCODE_LIKE:
                case OPCODE_ILIKE:
-                  if (pVal1->IsString() && pVal2->IsString())
+                  if (pVal1->isString() && pVal2->isString())
                   {
-                     pRes = new NXSL_Value((LONG)MatchString(pVal2->GetValueAsCString(),
-                                                             pVal1->GetValueAsCString(),
+                     pRes = new NXSL_Value((LONG)MatchString(pVal2->getValueAsCString(),
+                                                             pVal1->getValueAsCString(),
                                                              nOpCode == OPCODE_LIKE));
                      delete pVal1;
                      delete pVal2;
                   }
                   else
                   {
-                     Error(NXSL_ERR_NOT_STRING);
+                     error(NXSL_ERR_NOT_STRING);
                   }
                   break;
                case OPCODE_MATCH:
                case OPCODE_IMATCH:
-                  if (pVal1->IsString() && pVal2->IsString())
+                  if (pVal1->isString() && pVal2->isString())
                   {
-                     pRes = MatchRegexp(pVal1, pVal2, nOpCode == OPCODE_IMATCH);
+                     pRes = matchRegexp(pVal1, pVal2, nOpCode == OPCODE_IMATCH);
                      delete pVal1;
                      delete pVal2;
                   }
                   else
                   {
-                     Error(NXSL_ERR_NOT_STRING);
+                     error(NXSL_ERR_NOT_STRING);
                   }
                   break;
                case OPCODE_ADD:
@@ -1254,26 +1254,26 @@ void NXSL_Program::DoBinaryOperation(int nOpCode)
                case OPCODE_BIT_XOR:
                case OPCODE_LSHIFT:
                case OPCODE_RSHIFT:
-                  Error(NXSL_ERR_NOT_NUMBER);
+                  error(NXSL_ERR_NOT_NUMBER);
                   break;
                default:
-                  Error(NXSL_ERR_INTERNAL);
+                  error(NXSL_ERR_INTERNAL);
                   break;
             }
          }
       }
       else
       {
-         Error(NXSL_ERR_NULL_VALUE);
+         error(NXSL_ERR_NULL_VALUE);
       }
    }
    else
    {
-      Error(NXSL_ERR_DATA_STACK_UNDERFLOW);
+      error(NXSL_ERR_DATA_STACK_UNDERFLOW);
    }
 
    if (pRes != NULL)
-      m_pDataStack->Push(pRes);
+      m_pDataStack->push(pRes);
 }
 
 
@@ -1281,53 +1281,53 @@ void NXSL_Program::DoBinaryOperation(int nOpCode)
 // Perform unary operation on operand from the stack and push result back to stack
 //
 
-void NXSL_Program::DoUnaryOperation(int nOpCode)
+void NXSL_Program::doUnaryOperation(int nOpCode)
 {
    NXSL_Value *pVal;
 
-   pVal = (NXSL_Value *)m_pDataStack->Peek();
+   pVal = (NXSL_Value *)m_pDataStack->peek();
    if (pVal != NULL)
    {
-      if (pVal->IsNumeric())
+      if (pVal->isNumeric())
       {
          switch(nOpCode)
          {
             case OPCODE_NEG:
-               pVal->Negate();
+               pVal->negate();
                break;
             case OPCODE_NOT:
-               if (!pVal->IsReal())
+               if (!pVal->isReal())
                {
-                  pVal->Set((LONG)pVal->IsZero());
+                  pVal->set((LONG)pVal->isZero());
                }
                else
                {
-                  Error(NXSL_ERR_REAL_VALUE);
+                  error(NXSL_ERR_REAL_VALUE);
                }
                break;
             case OPCODE_BIT_NOT:
-               if (!pVal->IsReal())
+               if (!pVal->isReal())
                {
-                  pVal->BitNot();
+                  pVal->bitNot();
                }
                else
                {
-                  Error(NXSL_ERR_REAL_VALUE);
+                  error(NXSL_ERR_REAL_VALUE);
                }
                break;
             default:
-               Error(NXSL_ERR_INTERNAL);
+               error(NXSL_ERR_INTERNAL);
                break;
          }
       }
       else
       {
-         Error(NXSL_ERR_NOT_NUMBER);
+         error(NXSL_ERR_NOT_NUMBER);
       }
    }
    else
    {
-      Error(NXSL_ERR_DATA_STACK_UNDERFLOW);
+      error(NXSL_ERR_DATA_STACK_UNDERFLOW);
    }
 }
 
@@ -1336,7 +1336,7 @@ void NXSL_Program::DoUnaryOperation(int nOpCode)
 // Relocate code block
 //
 
-void NXSL_Program::RelocateCode(DWORD dwStart, DWORD dwLen, DWORD dwShift)
+void NXSL_Program::relocateCode(DWORD dwStart, DWORD dwLen, DWORD dwShift)
 {
    DWORD i, dwLast;
 
@@ -1356,7 +1356,7 @@ void NXSL_Program::RelocateCode(DWORD dwStart, DWORD dwLen, DWORD dwShift)
 // Use external module
 //
 
-void NXSL_Program::UseModule(NXSL_Program *pModule, const char *pszName)
+void NXSL_Program::useModule(NXSL_Program *pModule, const char *pszName)
 {
    DWORD i, j, dwStart;
 
@@ -1372,7 +1372,7 @@ void NXSL_Program::UseModule(NXSL_Program *pModule, const char *pszName)
          sizeof(NXSL_Instruction *) * m_dwCodeSize);
    for(i = dwStart, j = 0; i < m_dwCodeSize; i++, j++)
       m_ppInstructionSet[i] = new NXSL_Instruction(pModule->m_ppInstructionSet[j]);
-   RelocateCode(dwStart, pModule->m_dwCodeSize, dwStart);
+   relocateCode(dwStart, pModule->m_dwCodeSize, dwStart);
    
    // Add function names from module
    m_pFunctionList = (NXSL_Function *)realloc(m_pFunctionList,
@@ -1399,7 +1399,7 @@ void NXSL_Program::UseModule(NXSL_Program *pModule, const char *pszName)
 // Call function at given address
 //
 
-void NXSL_Program::CallFunction(int nArgCount)
+void NXSL_Program::callFunction(int nArgCount)
 {
    int i;
    NXSL_Value *pValue;
@@ -1408,30 +1408,30 @@ void NXSL_Program::CallFunction(int nArgCount)
    if (m_dwSubLevel < CONTROL_STACK_LIMIT)
    {
       m_dwSubLevel++;
-      m_pCodeStack->Push(CAST_TO_POINTER(m_dwCurrPos + 1, void *));
-      m_pCodeStack->Push(m_pLocals);
+      m_pCodeStack->push(CAST_TO_POINTER(m_dwCurrPos + 1, void *));
+      m_pCodeStack->push(m_pLocals);
       m_pLocals = new NXSL_VariableSystem;
       m_nBindPos = 1;
 
       // Bind arguments
       for(i = nArgCount; i > 0; i--)
       {
-         pValue = (NXSL_Value *)m_pDataStack->Pop();
+         pValue = (NXSL_Value *)m_pDataStack->pop();
          if (pValue != NULL)
          {
             sprintf(szBuffer, "$%d", i);
-            m_pLocals->Create(szBuffer, pValue);
+            m_pLocals->create(szBuffer, pValue);
          }
          else
          {
-            Error(NXSL_ERR_DATA_STACK_UNDERFLOW);
+            error(NXSL_ERR_DATA_STACK_UNDERFLOW);
             break;
          }
       }
    }
    else
    {
-      Error(NXSL_ERR_CONTROL_STACK_OVERFLOW);
+      error(NXSL_ERR_CONTROL_STACK_OVERFLOW);
    }
 }
 
@@ -1440,7 +1440,7 @@ void NXSL_Program::CallFunction(int nArgCount)
 // Find function address by name
 //
 
-DWORD NXSL_Program::GetFunctionAddress(char *pszName)
+DWORD NXSL_Program::getFunctionAddress(char *pszName)
 {
    DWORD i;
 
@@ -1455,7 +1455,7 @@ DWORD NXSL_Program::GetFunctionAddress(char *pszName)
 // Match regular expression
 //
 
-NXSL_Value *NXSL_Program::MatchRegexp(NXSL_Value *pValue, NXSL_Value *pRegexp,
+NXSL_Value *NXSL_Program::matchRegexp(NXSL_Value *pValue, NXSL_Value *pRegexp,
                                       BOOL bIgnoreCase)
 {
    regex_t preg;
@@ -1465,20 +1465,20 @@ NXSL_Value *NXSL_Program::MatchRegexp(NXSL_Value *pValue, NXSL_Value *pRegexp,
    TCHAR szName[16];
    int i;
 
-   if (regcomp(&preg, pRegexp->GetValueAsCString(),
+   if (regcomp(&preg, pRegexp->getValueAsCString(),
                bIgnoreCase ? REG_EXTENDED | REG_ICASE : REG_EXTENDED) == 0)
    {
-      if (regexec(&preg, pValue->GetValueAsCString(), 256, fields, 0) == 0)
+      if (regexec(&preg, pValue->getValueAsCString(), 256, fields, 0) == 0)
       {
          pResult = new NXSL_Value((LONG)1);
          for(i = 1; (i < 256) && (fields[i].rm_so != -1); i++)
          {
             _stprintf(szName, _T("$%d"), i);
-            pVar = m_pLocals->Find(szName);
+            pVar = m_pLocals->find(szName);
             if (pVar == NULL)
-               m_pLocals->Create(szName, new NXSL_Value(pValue->GetValueAsCString() + fields[i].rm_so, fields[i].rm_eo - fields[i].rm_so));
+               m_pLocals->create(szName, new NXSL_Value(pValue->getValueAsCString() + fields[i].rm_so, fields[i].rm_eo - fields[i].rm_so));
             else
-               pVar->Set(new NXSL_Value(pValue->GetValueAsCString() + fields[i].rm_so, fields[i].rm_eo - fields[i].rm_so));
+               pVar->setValue(new NXSL_Value(pValue->getValueAsCString() + fields[i].rm_so, fields[i].rm_eo - fields[i].rm_so));
          }
       }
       else
@@ -1489,7 +1489,7 @@ NXSL_Value *NXSL_Program::MatchRegexp(NXSL_Value *pValue, NXSL_Value *pRegexp,
    }
    else
    {
-      Error(NXSL_ERR_REGEXP_ERROR);
+      error(NXSL_ERR_REGEXP_ERROR);
       pResult = NULL;
    }
    return pResult;
@@ -1500,9 +1500,9 @@ NXSL_Value *NXSL_Program::MatchRegexp(NXSL_Value *pValue, NXSL_Value *pRegexp,
 // Get final jump destination from a jump chain
 //
 
-DWORD NXSL_Program::FinalJumpDestination(DWORD dwAddr)
+DWORD NXSL_Program::getFinalJumpDestination(DWORD dwAddr)
 {
-       return (m_ppInstructionSet[dwAddr]->m_nOpCode == OPCODE_JMP) ? FinalJumpDestination(m_ppInstructionSet[dwAddr]->m_operand.m_dwAddr) : dwAddr;
+       return (m_ppInstructionSet[dwAddr]->m_nOpCode == OPCODE_JMP) ? getFinalJumpDestination(m_ppInstructionSet[dwAddr]->m_operand.m_dwAddr) : dwAddr;
 }
 
 
@@ -1510,7 +1510,7 @@ DWORD NXSL_Program::FinalJumpDestination(DWORD dwAddr)
 // Optimize compiled program
 //
 
-void NXSL_Program::Optimize(void)
+void NXSL_Program::optimize()
 {
        DWORD i, j;
 
@@ -1521,7 +1521,7 @@ void NXSL_Program::Optimize(void)
                         (m_ppInstructionSet[i]->m_nOpCode == OPCODE_JZ) ||
                         (m_ppInstructionSet[i]->m_nOpCode == OPCODE_JNZ))
                {
-                       m_ppInstructionSet[i]->m_operand.m_dwAddr = FinalJumpDestination(m_ppInstructionSet[i]->m_operand.m_dwAddr);
+                       m_ppInstructionSet[i]->m_operand.m_dwAddr = getFinalJumpDestination(m_ppInstructionSet[i]->m_operand.m_dwAddr);
                }
        }
 
@@ -1554,3 +1554,14 @@ void NXSL_Program::Optimize(void)
                }
        }
 }
+
+
+//
+// Trace
+//
+
+void NXSL_Program::trace(int level, const TCHAR *text)
+{
+       if (m_pEnv != NULL)
+               m_pEnv->trace(level, text);
+}
index b7c1b7c..d7a56d4 100644 (file)
@@ -28,7 +28,7 @@
 // Constructor
 //
 
-NXSL_Stack::NXSL_Stack(void)
+NXSL_Stack::NXSL_Stack()
 {
    m_nStackSize = 128;
    m_nStackPos = 0;
@@ -50,7 +50,7 @@ NXSL_Stack::~NXSL_Stack()
 // Push value to stack
 //
 
-void NXSL_Stack::Push(void *pData)
+void NXSL_Stack::push(void *pData)
 {
    if (m_nStackPos >= m_nStackSize)
    {
@@ -65,7 +65,7 @@ void NXSL_Stack::Push(void *pData)
 // Pop value from stack
 //
 
-void *NXSL_Stack::Pop(void)
+void *NXSL_Stack::pop()
 {
    if (m_nStackPos > 0)
       return m_ppData[--m_nStackPos];
@@ -77,7 +77,7 @@ void *NXSL_Stack::Pop(void)
 // Peek (get without removing) value from stack
 //
 
-void *NXSL_Stack::Peek(void)
+void *NXSL_Stack::peek()
 {
    if (m_nStackPos > 0)
       return m_ppData[m_nStackPos - 1];
index a2ac738..7d02449 100644 (file)
@@ -87,7 +87,7 @@
 // Constructors
 //
 
-NXSL_Value::NXSL_Value(void)
+NXSL_Value::NXSL_Value()
 {
    m_nDataType = NXSL_DT_NULL;
    m_pszValStr = NULL;
@@ -106,7 +106,7 @@ NXSL_Value::NXSL_Value(const NXSL_Value *pValue)
       else if (m_nDataType == NXSL_DT_ARRAY)
       {
          m_value.pArray = pValue->m_value.pArray;
-                       m_value.pArray->IncRefCount();
+                       m_value.pArray->incRefCount();
       }
       else
       {
@@ -142,7 +142,7 @@ NXSL_Value::NXSL_Value(NXSL_Array *pArray)
 {
    m_nDataType = NXSL_DT_ARRAY;
    m_value.pArray = pArray;
-       pArray->IncRefCount();
+       pArray->incRefCount();
    m_pszValStr = NULL;
    m_bStringIsValid = FALSE;
 }
@@ -201,7 +201,7 @@ NXSL_Value::NXSL_Value(const TCHAR *pszValue)
                m_pszValStr = _tcsdup(_T(""));
        }
    m_bStringIsValid = TRUE;
-   UpdateNumber();
+   updateNumber();
 }
 
 NXSL_Value::NXSL_Value(const TCHAR *pszValue, DWORD dwLen)
@@ -211,7 +211,7 @@ NXSL_Value::NXSL_Value(const TCHAR *pszValue, DWORD dwLen)
    m_pszValStr = (TCHAR *)nx_memdup(CHECK_NULL_EX(pszValue), (dwLen + 1) * sizeof(TCHAR));
    m_pszValStr[dwLen] = 0;
    m_bStringIsValid = TRUE;
-   UpdateNumber();
+   updateNumber();
 }
 
 
@@ -228,8 +228,8 @@ NXSL_Value::~NXSL_Value()
        }
    else if (m_nDataType == NXSL_DT_ARRAY)
        {
-               m_value.pArray->DecRefCount();
-               if (m_value.pArray->IsUnused())
+               m_value.pArray->decRefCount();
+               if (m_value.pArray->isUnused())
                        delete m_value.pArray;
        }
 }
@@ -239,7 +239,7 @@ NXSL_Value::~NXSL_Value()
 // Set value
 //
 
-void NXSL_Value::Set(LONG nValue)
+void NXSL_Value::set(LONG nValue)
 {
    m_nDataType = NXSL_DT_INT32;
    safe_free(m_pszValStr);
@@ -253,7 +253,7 @@ void NXSL_Value::Set(LONG nValue)
 // Update numeric value after string change
 //
 
-void NXSL_Value::UpdateNumber(void)
+void NXSL_Value::updateNumber()
 {
    char *eptr;
    INT64 nVal;
@@ -289,7 +289,7 @@ void NXSL_Value::UpdateNumber(void)
 // Update string value
 //
 
-void NXSL_Value::UpdateString()
+void NXSL_Value::updateString()
 {
    char szBuffer[64];
 
@@ -325,20 +325,20 @@ void NXSL_Value::UpdateString()
 // Convert to another data type
 //
 
-BOOL NXSL_Value::Convert(int nDataType)
+bool NXSL_Value::convert(int nDataType)
 {
    LONG nInt32;
    DWORD uInt32;
    INT64 nInt64;
    QWORD uInt64;
    double dReal;
-   BOOL bRet = TRUE;
+   bool bRet = true;
 
    if (m_nDataType == nDataType)
-      return TRUE;
+      return true;
 
-       if ((nDataType == NXSL_DT_STRING) && IsString())
-               return TRUE;
+       if ((nDataType == NXSL_DT_STRING) && isString())
+               return true;
 
    switch(nDataType)
    {
@@ -365,11 +365,11 @@ BOOL NXSL_Value::Convert(int nDataType)
       case NXSL_DT_REAL:
          if (m_nDataType == NXSL_DT_UINT64)
          {
-            bRet = FALSE;
+            bRet = false;
          }
          else
          {
-            dReal = GetValueAsReal();
+            dReal = getValueAsReal();
             m_nDataType = nDataType;
             m_value.dReal = dReal;
          }
@@ -378,17 +378,17 @@ BOOL NXSL_Value::Convert(int nDataType)
                        if (m_nDataType == NXSL_DT_NULL)
                        {
                                m_nDataType = NXSL_DT_STRING;
-                               bRet = TRUE;
+                               bRet = true;
                                // String value will be invalidated on exit, and next
-                               // call to UpdateString() will create empty string value
+                               // call to updateString() will create empty string value
                        }
                        break;
       default:
-         bRet = FALSE;
+         bRet = false;
          break;
    }
    if (bRet)
-      InvalidateString();
+      invalidateString();
    return bRet;
 }
 
@@ -397,13 +397,13 @@ BOOL NXSL_Value::Convert(int nDataType)
 // Get value as ASCIIZ string
 //
 
-char *NXSL_Value::GetValueAsCString(void)
+const TCHAR *NXSL_Value::getValueAsCString()
 {
-   if (IsNull() || IsObject() || IsArray())
+   if (isNull() || isObject() || isArray())
       return NULL;
 
    if (!m_bStringIsValid)
-      UpdateString();
+      updateString();
    return m_pszValStr;
 }
 
@@ -412,16 +412,16 @@ char *NXSL_Value::GetValueAsCString(void)
 // Get value as string
 //
 
-char *NXSL_Value::GetValueAsString(DWORD *pdwLen)
+const TCHAR *NXSL_Value::getValueAsString(DWORD *pdwLen)
 {
-   if (IsNull() || IsObject() || IsArray())
+   if (isNull() || isObject() || isArray())
        {
                *pdwLen = 0;
       return NULL;
        }
 
    if (!m_bStringIsValid)
-      UpdateString();
+      updateString();
    *pdwLen = m_dwStrLen;
    return m_pszValStr;
 }
@@ -431,7 +431,7 @@ char *NXSL_Value::GetValueAsString(DWORD *pdwLen)
 // Get value as 32 bit integer
 //
 
-LONG NXSL_Value::GetValueAsInt32(void)
+LONG NXSL_Value::getValueAsInt32()
 {
    LONG nVal;
 
@@ -444,7 +444,7 @@ LONG NXSL_Value::GetValueAsInt32(void)
 // Get value as unsigned 32 bit integer
 //
 
-DWORD NXSL_Value::GetValueAsUInt32(void)
+DWORD NXSL_Value::getValueAsUInt32()
 {
    DWORD uVal;
 
@@ -457,7 +457,7 @@ DWORD NXSL_Value::GetValueAsUInt32(void)
 // Get value as 64 bit integer
 //
 
-INT64 NXSL_Value::GetValueAsInt64(void)
+INT64 NXSL_Value::getValueAsInt64()
 {
    INT64 nVal;
 
@@ -470,7 +470,7 @@ INT64 NXSL_Value::GetValueAsInt64(void)
 // Get value as unsigned 64 bit integer
 //
 
-QWORD NXSL_Value::GetValueAsUInt64(void)
+QWORD NXSL_Value::getValueAsUInt64()
 {
    QWORD uVal;
 
@@ -483,7 +483,7 @@ QWORD NXSL_Value::GetValueAsUInt64(void)
 // Get value as real number
 //
 
-double NXSL_Value::GetValueAsReal(void)
+double NXSL_Value::getValueAsReal()
 {
    double dVal;
 
@@ -516,15 +516,15 @@ double NXSL_Value::GetValueAsReal(void)
 // Concatenate string value
 //
 
-void NXSL_Value::Concatenate(char *pszString, DWORD dwLen)
+void NXSL_Value::concatenate(const TCHAR *pszString, DWORD dwLen)
 {
    if (!m_bStringIsValid)
-      UpdateString();
+      updateString();
    m_pszValStr = (char *)realloc(m_pszValStr, m_dwStrLen + dwLen + 1);
    memcpy(&m_pszValStr[m_dwStrLen], pszString, dwLen);
    m_dwStrLen += dwLen;
    m_pszValStr[m_dwStrLen] = 0;
-   UpdateNumber();
+   updateNumber();
 }
 
 
@@ -532,9 +532,9 @@ void NXSL_Value::Concatenate(char *pszString, DWORD dwLen)
 // Increment value
 //
 
-void NXSL_Value::Increment(void)
+void NXSL_Value::increment()
 {
-   if (IsNumeric())
+   if (isNumeric())
    {
       switch(m_nDataType)
       {
@@ -556,7 +556,7 @@ void NXSL_Value::Increment(void)
          default:
             break;
       }
-      InvalidateString();
+      invalidateString();
    }
 }
 
@@ -565,9 +565,9 @@ void NXSL_Value::Increment(void)
 // Decrement value
 //
 
-void NXSL_Value::Decrement(void)
+void NXSL_Value::decrement()
 {
-   if (IsNumeric())
+   if (isNumeric())
    {
       switch(m_nDataType)
       {
@@ -589,7 +589,7 @@ void NXSL_Value::Decrement(void)
          default:
             break;
       }
-      InvalidateString();
+      invalidateString();
    }
 }
 
@@ -598,9 +598,9 @@ void NXSL_Value::Decrement(void)
 // Negate value
 //
 
-void NXSL_Value::Negate(void)
+void NXSL_Value::negate()
 {
-   if (IsNumeric())
+   if (isNumeric())
    {
       switch(m_nDataType)
       {
@@ -624,7 +624,7 @@ void NXSL_Value::Negate(void)
          default:
             break;
       }
-      InvalidateString();
+      invalidateString();
    }
 }
 
@@ -633,9 +633,9 @@ void NXSL_Value::Negate(void)
 // Bitwise NOT
 //
 
-void NXSL_Value::BitNot(void)
+void NXSL_Value::bitNot()
 {
-   if (IsNumeric())
+   if (isNumeric())
    {
       switch(m_nDataType)
       {
@@ -654,7 +654,7 @@ void NXSL_Value::BitNot(void)
          default:
             break;
       }
-      InvalidateString();
+      invalidateString();
    }
 }
 
@@ -663,9 +663,9 @@ void NXSL_Value::BitNot(void)
 // Check if value is zero
 //
 
-BOOL NXSL_Value::IsZero(void)
+bool NXSL_Value::isZero()
 {
-   BOOL bVal = FALSE;
+   bool bVal = false;
 
    switch(m_nDataType)
    {
@@ -695,9 +695,9 @@ BOOL NXSL_Value::IsZero(void)
 // Check if value is not a zero
 //
 
-BOOL NXSL_Value::IsNonZero(void)
+bool NXSL_Value::isNonZero()
 {
-   BOOL bVal = FALSE;
+   bool bVal = false;
 
    switch(m_nDataType)
    {
@@ -869,7 +869,7 @@ BOOL NXSL_Value::GE(NXSL_Value *pVal)
 // All these functions assumes that both values have same type
 //
 
-void NXSL_Value::Add(NXSL_Value *pVal)
+void NXSL_Value::add(NXSL_Value *pVal)
 {
    switch(m_nDataType)
    {
@@ -891,10 +891,10 @@ void NXSL_Value::Add(NXSL_Value *pVal)
       default:
          break;
    }
-   InvalidateString();
+   invalidateString();
 }
 
-void NXSL_Value::Sub(NXSL_Value *pVal)
+void NXSL_Value::sub(NXSL_Value *pVal)
 {
    switch(m_nDataType)
    {
@@ -916,10 +916,10 @@ void NXSL_Value::Sub(NXSL_Value *pVal)
       default:
          break;
    }
-   InvalidateString();
+   invalidateString();
 }
 
-void NXSL_Value::Mul(NXSL_Value *pVal)
+void NXSL_Value::mul(NXSL_Value *pVal)
 {
    switch(m_nDataType)
    {
@@ -941,10 +941,10 @@ void NXSL_Value::Mul(NXSL_Value *pVal)
       default:
          break;
    }
-   InvalidateString();
+   invalidateString();
 }
 
-void NXSL_Value::Div(NXSL_Value *pVal)
+void NXSL_Value::div(NXSL_Value *pVal)
 {
    switch(m_nDataType)
    {
@@ -966,10 +966,10 @@ void NXSL_Value::Div(NXSL_Value *pVal)
       default:
          break;
    }
-   InvalidateString();
+   invalidateString();
 }
 
-void NXSL_Value::Rem(NXSL_Value *pVal)
+void NXSL_Value::rem(NXSL_Value *pVal)
 {
    switch(m_nDataType)
    {
@@ -988,10 +988,10 @@ void NXSL_Value::Rem(NXSL_Value *pVal)
       default:
          break;
    }
-   InvalidateString();
+   invalidateString();
 }
 
-void NXSL_Value::BitAnd(NXSL_Value *pVal)
+void NXSL_Value::bitAnd(NXSL_Value *pVal)
 {
    switch(m_nDataType)
    {
@@ -1010,10 +1010,10 @@ void NXSL_Value::BitAnd(NXSL_Value *pVal)
       default:
          break;
    }
-   InvalidateString();
+   invalidateString();
 }
 
-void NXSL_Value::BitOr(NXSL_Value *pVal)
+void NXSL_Value::bitOr(NXSL_Value *pVal)
 {
    switch(m_nDataType)
    {
@@ -1032,10 +1032,10 @@ void NXSL_Value::BitOr(NXSL_Value *pVal)
       default:
          break;
    }
-   InvalidateString();
+   invalidateString();
 }
 
-void NXSL_Value::BitXor(NXSL_Value *pVal)
+void NXSL_Value::bitXor(NXSL_Value *pVal)
 {
    switch(m_nDataType)
    {
@@ -1054,7 +1054,7 @@ void NXSL_Value::BitXor(NXSL_Value *pVal)
       default:
          break;
    }
-   InvalidateString();
+   invalidateString();
 }
 
 
@@ -1062,7 +1062,7 @@ void NXSL_Value::BitXor(NXSL_Value *pVal)
 // Bit shift operations
 //
 
-void NXSL_Value::LShift(int nBits)
+void NXSL_Value::lshift(int nBits)
 {
    switch(m_nDataType)
    {
@@ -1081,10 +1081,10 @@ void NXSL_Value::LShift(int nBits)
       default:
          break;
    }
-   InvalidateString();
+   invalidateString();
 }
 
-void NXSL_Value::RShift(int nBits)
+void NXSL_Value::rshift(int nBits)
 {
    switch(m_nDataType)
    {
@@ -1103,5 +1103,5 @@ void NXSL_Value::RShift(int nBits)
       default:
          break;
    }
-   InvalidateString();
+   invalidateString();
 }
index e3d0b45..b18529a 100644 (file)
@@ -1,7 +1,7 @@
 /* 
 ** NetXMS - Network Management System
 ** NetXMS Scripting Language Interpreter
-** Copyright (C) 2005 Victor Kirhenshtein
+** Copyright (C) 2005-2010 Victor Kirhenshtein
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
 ** along with this program; if not, write to the Free Software
 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 **
-** $module: variable.cpp
+** File: variable.cpp
 **
 **/
 
@@ -62,7 +62,7 @@ NXSL_Variable::~NXSL_Variable()
 // Set variable's value
 //
 
-void NXSL_Variable::Set(NXSL_Value *pValue)
+void NXSL_Variable::setValue(NXSL_Value *pValue)
 {
    delete m_pValue;
    m_pValue = pValue;
@@ -73,7 +73,7 @@ void NXSL_Variable::Set(NXSL_Value *pValue)
 // Variable system constructors
 //
 
-NXSL_VariableSystem::NXSL_VariableSystem(void)
+NXSL_VariableSystem::NXSL_VariableSystem()
 {
    m_dwNumVariables = 0;
    m_ppVariableList = NULL;
@@ -94,7 +94,7 @@ NXSL_VariableSystem::NXSL_VariableSystem(NXSL_VariableSystem *pSrc)
 // Variable system destructor
 //
 
-NXSL_VariableSystem::~NXSL_VariableSystem(void)
+NXSL_VariableSystem::~NXSL_VariableSystem()
 {
    DWORD i;
 
@@ -108,12 +108,12 @@ NXSL_VariableSystem::~NXSL_VariableSystem(void)
 // Find variable by name
 //
 
-NXSL_Variable *NXSL_VariableSystem::Find(const TCHAR *pszName)
+NXSL_Variable *NXSL_VariableSystem::find(const TCHAR *pszName)
 {
    DWORD i;
 
    for(i = 0; i < m_dwNumVariables; i++)
-      if (!_tcscmp(pszName, m_ppVariableList[i]->Name()))
+      if (!_tcscmp(pszName, m_ppVariableList[i]->getName()))
          return m_ppVariableList[i];
    return NULL;
 }
@@ -123,7 +123,7 @@ NXSL_Variable *NXSL_VariableSystem::Find(const TCHAR *pszName)
 // Create variable
 //
 
-NXSL_Variable *NXSL_VariableSystem::Create(const TCHAR *pszName, NXSL_Value *pValue)
+NXSL_Variable *NXSL_VariableSystem::create(const TCHAR *pszName, NXSL_Value *pValue)
 {
    NXSL_Variable *pVar;
 
index 46b737a..5135c71 100644 (file)
@@ -30,7 +30,7 @@ NXSL_TestClass::NXSL_TestClass()
    strcpy(m_szName, "TEST");
 }
 
-NXSL_Value *NXSL_TestClass::GetAttr(NXSL_Object *pObject, char *pszAttr)
+NXSL_Value *NXSL_TestClass::getAttr(NXSL_Object *pObject, char *pszAttr)
 {
    NXSL_Value *pValue = NULL;
 
@@ -40,16 +40,16 @@ NXSL_Value *NXSL_TestClass::GetAttr(NXSL_Object *pObject, char *pszAttr)
    }
    else if (!strcmp(pszAttr, "value"))
    {
-               pValue = new NXSL_Value((char *)pObject->Data());
+               pValue = new NXSL_Value((char *)pObject->getData());
    }
    return pValue;
 }
 
-BOOL NXSL_TestClass::SetAttr(NXSL_Object *pObject, char *pszAttr, NXSL_Value *pValue)
+BOOL NXSL_TestClass::setAttr(NXSL_Object *pObject, char *pszAttr, NXSL_Value *pValue)
 {
    if (!strcmp(pszAttr, "value"))
    {
-               _tcscpy((char *)pObject->Data(), CHECK_NULL(pValue->GetValueAsCString()));
+               _tcscpy((char *)pObject->getData(), CHECK_NULL(pValue->getValueAsCString()));
                return TRUE;
    }
    return FALSE;
index 53d82f5..2b46dc6 100644 (file)
@@ -28,7 +28,7 @@
 static NXSL_TestClass *m_pTestClass;
 
 
-int F_new(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+int F_new(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
        TCHAR *buffer = (TCHAR *)malloc(1024);
        strcpy(buffer, "test value");
@@ -98,10 +98,10 @@ int main(int argc, char *argv[])
                if (pScript != NULL)
                {
                        if (dump)
-                               pScript->Dump(stdout);
+                               pScript->dump(stdout);
                        pEnv = new NXSL_Environment;
-                       pEnv->SetIO(stdin, stdout);
-                       pEnv->RegisterFunctionSet(1, &func);
+                       pEnv->setIO(stdin, stdout);
+                       pEnv->registerFunctionSet(1, &func);
 
                        // Prepare arguments
                        if (argc - optind > 1)
@@ -115,15 +115,15 @@ int main(int argc, char *argv[])
                                ppArgs = NULL;
                        }
 
-                       if (pScript->Run(pEnv, argc - optind - 1, ppArgs) == 0)
+                       if (pScript->run(pEnv, argc - optind - 1, ppArgs) == 0)
                        {
-                               NXSL_Value *result = pScript->GetResult();
+                               NXSL_Value *result = pScript->getResult();
                                if (printResult)
-                                       printf("Result = %s\n", (result != NULL) ? result->GetValueAsCString() : "(null)");
+                                       printf("Result = %s\n", (result != NULL) ? result->getValueAsCString() : "(null)");
                        }
                        else
                        {
-                               printf("%s\n", pScript->GetErrorText());
+                               printf("%s\n", pScript->getErrorText());
                        }
                        delete pScript;
                        safe_free(ppArgs);
index 8503726..ea05d16 100644 (file)
@@ -42,8 +42,8 @@ class NXSL_TestClass : public NXSL_Class
 public:
    NXSL_TestClass();
 
-   virtual NXSL_Value *GetAttr(NXSL_Object *pObject, char *pszAttr);
-   virtual BOOL SetAttr(NXSL_Object *pObject, char *pszAttr, NXSL_Value *pValue);
+   virtual NXSL_Value *getAttr(NXSL_Object *pObject, char *pszAttr);
+   virtual BOOL setAttr(NXSL_Object *pObject, char *pszAttr, NXSL_Value *pValue);
 };
 
 #endif
index 1eaf96e..f098f31 100644 (file)
@@ -431,10 +431,10 @@ void Condition::Check(void)
 
    DbgPrintf(6, _T("Running evaluation script for condition %d \"%s\""),
              m_dwId, m_szName);
-   if (m_pCompiledScript->Run(pEnv, dwNumValues, ppValueList) == 0)
+   if (m_pCompiledScript->run(pEnv, dwNumValues, ppValueList) == 0)
    {
-      pValue = m_pCompiledScript->GetResult();
-      if (pValue->GetValueAsInt32() == 0)
+      pValue = m_pCompiledScript->getResult();
+      if (pValue->getValueAsInt32() == 0)
       {
          if (m_bIsActive)
          {
@@ -500,7 +500,7 @@ void Condition::Check(void)
    else
    {
       nxlog_write(MSG_COND_SCRIPT_EXECUTION_ERROR, EVENTLOG_ERROR_TYPE,
-               "dss", m_dwId, m_szName, m_pCompiledScript->GetErrorText());
+               "dss", m_dwId, m_szName, m_pCompiledScript->getErrorText());
 
       LockData();
       if (m_iStatus != STATUS_UNKNOWN)
index 5617555..09174e2 100644 (file)
@@ -350,11 +350,11 @@ BOOL Container::IsSuitableForNode(Node *node)
        if (m_bindFilter != NULL)
        {
                pEnv = new NXSL_ServerEnv;
-               m_bindFilter->SetGlobalVariable(_T("$node"), new NXSL_Value(new NXSL_Object(&g_nxslNodeClass, node)));
-               if (m_bindFilter->Run(pEnv, 0, NULL) == 0)
+               m_bindFilter->setGlobalVariable(_T("$node"), new NXSL_Value(new NXSL_Object(&g_nxslNodeClass, node)));
+               if (m_bindFilter->run(pEnv, 0, NULL) == 0)
                {
-                       value = m_bindFilter->GetResult();
-                       result = ((value != NULL) && (value->GetValueAsInt32() != 0));
+                       value = m_bindFilter->getResult();
+                       result = ((value != NULL) && (value->getValueAsInt32() != 0));
                }
                else
                {
@@ -362,8 +362,8 @@ BOOL Container::IsSuitableForNode(Node *node)
 
                        _sntprintf(buffer, 1024, _T("Container::%s::%d"), m_szName, m_dwId);
                        PostEvent(EVENT_SCRIPT_ERROR, g_dwMgmtNode, _T("ssd"), buffer,
-                                                m_bindFilter->GetErrorText(), m_dwId);
-                       nxlog_write(MSG_CONTAINER_SCRIPT_EXECUTION_ERROR, EVENTLOG_WARNING_TYPE, "dss", m_dwId, m_szName, m_bindFilter->GetErrorText());
+                                                m_bindFilter->getErrorText(), m_dwId);
+                       nxlog_write(MSG_CONTAINER_SCRIPT_EXECUTION_ERROR, EVENTLOG_WARNING_TYPE, "dss", m_dwId, m_szName, m_bindFilter->getErrorText());
                }
        }
        UnlockData();
index 47f9dfe..5df381a 100644 (file)
 // and second is DCI ID
 //
 
-static int F_GetDCIValue(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+static int F_GetDCIValue(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
        NXSL_Object *object;
        Node *node;
        DCItem *dci;
 
-       if (!argv[0]->IsObject())
+       if (!argv[0]->isObject())
                return NXSL_ERR_NOT_OBJECT;
 
-       if (!argv[1]->IsInteger())
+       if (!argv[1]->isInteger())
                return NXSL_ERR_NOT_INTEGER;
 
-       object = argv[0]->GetValueAsObject();
-       if (_tcscmp(object->Class()->Name(), "NetXMS_Node"))
+       object = argv[0]->getValueAsObject();
+       if (_tcscmp(object->getClass()->getName(), "NetXMS_Node"))
                return NXSL_ERR_BAD_CLASS;
 
-       node = (Node *)object->Data();
-       dci = node->GetItemById(argv[1]->GetValueAsUInt32());
+       node = (Node *)object->getData();
+       dci = node->GetItemById(argv[1]->getValueAsUInt32());
        if (dci != NULL)
        {
                *ppResult = dci->getValueForNXSL(F_LAST, 1);
@@ -65,24 +65,24 @@ static int F_GetDCIValue(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 // Find DCI by name
 //
 
-static int F_FindDCIByName(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+static int F_FindDCIByName(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
        NXSL_Object *object;
        Node *node;
        DCItem *dci;
 
-       if (!argv[0]->IsObject())
+       if (!argv[0]->isObject())
                return NXSL_ERR_NOT_OBJECT;
 
-       if (!argv[1]->IsString())
+       if (!argv[1]->isString())
                return NXSL_ERR_NOT_STRING;
 
-       object = argv[0]->GetValueAsObject();
-       if (_tcscmp(object->Class()->Name(), "NetXMS_Node"))
+       object = argv[0]->getValueAsObject();
+       if (_tcscmp(object->getClass()->getName(), "NetXMS_Node"))
                return NXSL_ERR_BAD_CLASS;
 
-       node = (Node *)object->Data();
-       dci = node->GetItemByName(argv[1]->GetValueAsCString());
+       node = (Node *)object->getData();
+       dci = node->GetItemByName(argv[1]->getValueAsCString());
        *ppResult = (dci != NULL) ? new NXSL_Value(dci->getId()) : new NXSL_Value((DWORD)0);
        return 0;
 }
@@ -92,24 +92,24 @@ static int F_FindDCIByName(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 // Find DCI by description
 //
 
-static int F_FindDCIByDescription(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+static int F_FindDCIByDescription(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
        NXSL_Object *object;
        Node *node;
        DCItem *dci;
 
-       if (!argv[0]->IsObject())
+       if (!argv[0]->isObject())
                return NXSL_ERR_NOT_OBJECT;
 
-       if (!argv[1]->IsString())
+       if (!argv[1]->isString())
                return NXSL_ERR_NOT_STRING;
 
-       object = argv[0]->GetValueAsObject();
-       if (_tcscmp(object->Class()->Name(), "NetXMS_Node"))
+       object = argv[0]->getValueAsObject();
+       if (_tcscmp(object->getClass()->getName(), "NetXMS_Node"))
                return NXSL_ERR_BAD_CLASS;
 
-       node = (Node *)object->Data();
-       dci = node->GetItemByDescription(argv[1]->GetValueAsCString());
+       node = (Node *)object->getData();
+       dci = node->GetItemByDescription(argv[1]->getValueAsCString());
        *ppResult = (dci != NULL) ? new NXSL_Value(dci->getId()) : new NXSL_Value((DWORD)0);
        return 0;
 }
@@ -128,7 +128,7 @@ static NXSL_ExtFunction m_nxslDCIFunctions[] =
 
 void RegisterDCIFunctions(NXSL_Environment *pEnv)
 {
-       pEnv->RegisterFunctionSet(sizeof(m_nxslDCIFunctions) / sizeof(NXSL_ExtFunction), m_nxslDCIFunctions);
+       pEnv->registerFunctionSet(sizeof(m_nxslDCIFunctions) / sizeof(NXSL_ExtFunction), m_nxslDCIFunctions);
 }
 
 
@@ -1147,32 +1147,32 @@ void DCItem::transform(ItemValue &value, time_t nElapsedTime)
 
       pValue = new NXSL_Value((char *)((const char *)value));
       pEnv = new NXSL_ServerEnv;
-      m_pScript->SetGlobalVariable(_T("$node"), new NXSL_Value(new NXSL_Object(&g_nxslNodeClass, m_pNode)));
+      m_pScript->setGlobalVariable(_T("$node"), new NXSL_Value(new NXSL_Object(&g_nxslNodeClass, m_pNode)));
        
-      if (m_pScript->Run(pEnv, 1, &pValue) == 0)
+      if (m_pScript->run(pEnv, 1, &pValue) == 0)
       {
-         pValue = m_pScript->GetResult();
+         pValue = m_pScript->getResult();
          if (pValue != NULL)
          {
             switch(m_iDataType)
             {
                case DCI_DT_INT:
-                  value = pValue->GetValueAsInt32();
+                  value = pValue->getValueAsInt32();
                   break;
                case DCI_DT_UINT:
-                  value = pValue->GetValueAsUInt32();
+                  value = pValue->getValueAsUInt32();
                   break;
                case DCI_DT_INT64:
-                  value = pValue->GetValueAsInt64();
+                  value = pValue->getValueAsInt64();
                   break;
                case DCI_DT_UINT64:
-                  value = pValue->GetValueAsUInt64();
+                  value = pValue->getValueAsUInt64();
                   break;
                case DCI_DT_FLOAT:
-                  value = pValue->GetValueAsReal();
+                  value = pValue->getValueAsReal();
                   break;
                case DCI_DT_STRING:
-                  value = CHECK_NULL_EX(pValue->GetValueAsCString());
+                  value = CHECK_NULL_EX(pValue->getValueAsCString());
                   break;
                default:
                   break;
@@ -1186,7 +1186,7 @@ void DCItem::transform(ItemValue &value, time_t nElapsedTime)
          _sntprintf(szBuffer, 1024, _T("DCI::%s::%d"),
                     (m_pNode != NULL) ? m_pNode->Name() : _T("(null)"), m_dwId);
          PostEvent(EVENT_SCRIPT_ERROR, g_dwMgmtNode, _T("ssd"), szBuffer,
-                   m_pScript->GetErrorText(), m_dwId);
+                   m_pScript->getErrorText(), m_dwId);
       }
    }
 }
@@ -2016,34 +2016,34 @@ void DCItem::expandMacros(const TCHAR *src, TCHAR *dst, size_t dstLen)
                        NXSL_Program *script;
                        NXSL_ServerEnv *pEnv;
 
-             g_pScriptLibrary->Lock();
-                       script = g_pScriptLibrary->FindScript(&macro[7]);
+             g_pScriptLibrary->lock();
+                       script = g_pScriptLibrary->findScript(&macro[7]);
                        if (script != NULL)
                        {
                                pEnv = new NXSL_ServerEnv;
                                if (m_pNode != NULL)
-                                       script->SetGlobalVariable(_T("$node"), new NXSL_Value(new NXSL_Object(&g_nxslNodeClass, m_pNode)));
+                                       script->setGlobalVariable(_T("$node"), new NXSL_Value(new NXSL_Object(&g_nxslNodeClass, m_pNode)));
 
-                               if (script->Run(pEnv) == 0)
+                               if (script->run(pEnv) == 0)
                                {
-                                       NXSL_Value *result = script->GetResult();
+                                       NXSL_Value *result = script->getResult();
                                        if (result != NULL)
-                                               temp += CHECK_NULL_EX(result->GetValueAsCString());
+                                               temp += CHECK_NULL_EX(result->getValueAsCString());
                         DbgPrintf(4, "DCItem::expandMacros(%d,\"%s\"): Script %s executed successfully", m_dwId, src, &macro[7]);
                                }
                                else
                                {
                         DbgPrintf(4, "DCItem::expandMacros(%d,\"%s\"): Script %s execution error: %s",
-                                                 m_dwId, src, &macro[7], script->GetErrorText());
+                                                 m_dwId, src, &macro[7], script->getErrorText());
                                        PostEvent(EVENT_SCRIPT_ERROR, g_dwMgmtNode, _T("ssd"), &macro[7],
-                                                                script->GetErrorText(), m_dwId);
+                                                                script->getErrorText(), m_dwId);
                                }
                        }
                        else
                        {
                 DbgPrintf(4, "DCItem::expandMacros(%d,\"%s\"): Cannot find script %s", m_dwId, src, &macro[7]);
                        }
-             g_pScriptLibrary->Unlock();
+             g_pScriptLibrary->unlock();
                }
                temp += rest;
                
@@ -2073,31 +2073,31 @@ BOOL DCItem::testTransformation(const TCHAR *script, const TCHAR *value, TCHAR *
 
       pValue = new NXSL_Value(value);
       pEnv = new NXSL_ServerEnv;
-      pScript->SetGlobalVariable(_T("$node"), new NXSL_Value(new NXSL_Object(&g_nxslNodeClass, m_pNode)));
+      pScript->setGlobalVariable(_T("$node"), new NXSL_Value(new NXSL_Object(&g_nxslNodeClass, m_pNode)));
        
                lock();
-               if (pScript->Run(pEnv, 1, &pValue) == 0)
+               if (pScript->run(pEnv, 1, &pValue) == 0)
       {
-         pValue = pScript->GetResult();
+         pValue = pScript->getResult();
          if (pValue != NULL)
          {
-                               if (pValue->IsNull())
+                               if (pValue->isNull())
                                {
                                        nx_strncpy(buffer, _T("(null)"), bufSize);
                                }
-                               else if (pValue->IsObject())
+                               else if (pValue->isObject())
                                {
                                        nx_strncpy(buffer, _T("(object)"), bufSize);
                                }
-                               else if (pValue->IsArray())
+                               else if (pValue->isArray())
                                {
                                        nx_strncpy(buffer, _T("(array)"), bufSize);
                                }
                                else
                                {
-                                       TCHAR *strval;
+                                       const TCHAR *strval;
 
-                                       strval = pValue->GetValueAsCString();
+                                       strval = pValue->getValueAsCString();
                                        nx_strncpy(buffer, CHECK_NULL(strval), bufSize);
                                }
                        }
@@ -2109,7 +2109,7 @@ BOOL DCItem::testTransformation(const TCHAR *script, const TCHAR *value, TCHAR *
       }
       else
       {
-                       nx_strncpy(buffer, pScript->GetErrorText(), bufSize);
+                       nx_strncpy(buffer, pScript->getErrorText(), bufSize);
       }
                unlock();
    }
index 63cae0e..1507bec 100644 (file)
@@ -75,7 +75,7 @@ EPRule::EPRule(DB_RESULT hResult, int iRow)
       m_pScript = (NXSL_Program *)NXSLCompile(m_pszScript, szError, 256);
       if (m_pScript != NULL)
       {
-       m_pScript->SetGlobalVariable(_T("CUSTOM_MESSAGE"), new NXSL_Value(_T("")));
+       m_pScript->setGlobalVariable(_T("CUSTOM_MESSAGE"), new NXSL_Value(_T("")));
       }
       else
       {
@@ -144,7 +144,7 @@ EPRule::EPRule(CSCPMessage *pMsg)
       m_pScript = (NXSL_Program *)NXSLCompile(m_pszScript, szError, 256);
       if (m_pScript != NULL)
       {
-       m_pScript->SetGlobalVariable(_T("CUSTOM_MESSAGE"), new NXSL_Value(_T("")));
+       m_pScript->setGlobalVariable(_T("CUSTOM_MESSAGE"), new NXSL_Value(_T("")));
       }
       else
       {
@@ -289,37 +289,37 @@ BOOL EPRule::MatchScript(Event *pEvent)
       ppValueList[i] = new NXSL_Value(pEvent->getParameter(i));
 
    pLocals = new NXSL_VariableSystem;
-   pLocals->Create(_T("EVENT_CODE"), new NXSL_Value(pEvent->getCode()));
-   pLocals->Create(_T("SEVERITY"), new NXSL_Value(pEvent->getSeverity()));
-   pLocals->Create(_T("SEVERITY_TEXT"), new NXSL_Value(g_szStatusText[pEvent->getSeverity()]));
-   pLocals->Create(_T("OBJECT_ID"), new NXSL_Value(pEvent->getSourceId()));
-   pLocals->Create(_T("EVENT_TEXT"), new NXSL_Value((TCHAR *)pEvent->getMessage()));
-   pLocals->Create(_T("USER_TAG"), new NXSL_Value((TCHAR *)pEvent->getUserTag()));
+   pLocals->create(_T("EVENT_CODE"), new NXSL_Value(pEvent->getCode()));
+   pLocals->create(_T("SEVERITY"), new NXSL_Value(pEvent->getSeverity()));
+   pLocals->create(_T("SEVERITY_TEXT"), new NXSL_Value(g_szStatusText[pEvent->getSeverity()]));
+   pLocals->create(_T("OBJECT_ID"), new NXSL_Value(pEvent->getSourceId()));
+   pLocals->create(_T("EVENT_TEXT"), new NXSL_Value((TCHAR *)pEvent->getMessage()));
+   pLocals->create(_T("USER_TAG"), new NXSL_Value((TCHAR *)pEvent->getUserTag()));
        pObject = FindObjectById(pEvent->getSourceId());
        if (pObject != NULL)
        {
                if (pObject->Type() == OBJECT_NODE)
-                       m_pScript->SetGlobalVariable(_T("$node"), new NXSL_Value(new NXSL_Object(&g_nxslNodeClass, pObject)));
+                       m_pScript->setGlobalVariable(_T("$node"), new NXSL_Value(new NXSL_Object(&g_nxslNodeClass, pObject)));
        }
-       m_pScript->SetGlobalVariable(_T("$event"), new NXSL_Value(new NXSL_Object(&g_nxslEventClass, pEvent)));
-       m_pScript->SetGlobalVariable(_T("CUSTOM_MESSAGE"), new NXSL_Value);
+       m_pScript->setGlobalVariable(_T("$event"), new NXSL_Value(new NXSL_Object(&g_nxslEventClass, pEvent)));
+       m_pScript->setGlobalVariable(_T("CUSTOM_MESSAGE"), new NXSL_Value);
 
    // Run script
-   if (m_pScript->Run(pEnv, pEvent->getParametersCount(), ppValueList, pLocals, &pGlobals) == 0)
+   if (m_pScript->run(pEnv, pEvent->getParametersCount(), ppValueList, pLocals, &pGlobals) == 0)
    {
-      pValue = m_pScript->GetResult();
+      pValue = m_pScript->getResult();
       if (pValue != NULL)
       {
-         bRet = pValue->GetValueAsInt32() ? TRUE : FALSE;
+         bRet = pValue->getValueAsInt32() ? TRUE : FALSE;
          if (bRet)
          {
                NXSL_Variable *var;
                
-               var = pGlobals->Find(_T("CUSTOM_MESSAGE"));
+               var = pGlobals->find(_T("CUSTOM_MESSAGE"));
                if (var != NULL)
                {
                        // Update custom message in event
-                       pEvent->setCustomMessage(CHECK_NULL_EX(var->Value()->GetValueAsCString()));
+                       pEvent->setCustomMessage(CHECK_NULL_EX(var->getValue()->getValueAsCString()));
                }
          }
       }
@@ -327,7 +327,7 @@ BOOL EPRule::MatchScript(Event *pEvent)
    else
    {
       nxlog_write(MSG_EPRULE_SCRIPT_EXECUTION_ERROR, EVENTLOG_ERROR_TYPE,
-               "ds", m_dwId, m_pScript->GetErrorText());
+               "ds", m_dwId, m_pScript->getErrorText());
    }
    free(ppValueList);
    delete pGlobals;
index 049dd0b..1b6185d 100644 (file)
@@ -354,23 +354,23 @@ TCHAR *Event::expandText(const TCHAR *pszTemplate, const TCHAR *pszAlarmMsg)
                                                        scriptName[i] = 0;
                                                        StrStrip(scriptName);
 
-                                                       g_pScriptLibrary->Lock();
-                                                       script = g_pScriptLibrary->FindScript(scriptName);
+                                                       g_pScriptLibrary->lock();
+                                                       script = g_pScriptLibrary->findScript(scriptName);
                                                        if (script != NULL)
                                                        {
                                                                pEnv = new NXSL_ServerEnv;
                                                                if (pObject->Type() == OBJECT_NODE)
-                                                                       script->SetGlobalVariable(_T("$node"), new NXSL_Value(new NXSL_Object(&g_nxslNodeClass, pObject)));
-                                                               script->SetGlobalVariable(_T("$event"), new NXSL_Value(new NXSL_Object(&g_nxslEventClass, this)));
+                                                                       script->setGlobalVariable(_T("$node"), new NXSL_Value(new NXSL_Object(&g_nxslNodeClass, pObject)));
+                                                               script->setGlobalVariable(_T("$event"), new NXSL_Value(new NXSL_Object(&g_nxslEventClass, this)));
                                                                if (pszAlarmMsg != NULL)
-                                                                       script->SetGlobalVariable(_T("$alarmMessage"), new NXSL_Value(pszAlarmMsg));
+                                                                       script->setGlobalVariable(_T("$alarmMessage"), new NXSL_Value(pszAlarmMsg));
 
-                                                               if (script->Run(pEnv) == 0)
+                                                               if (script->run(pEnv) == 0)
                                                                {
-                                                                       NXSL_Value *result = script->GetResult();
+                                                                       NXSL_Value *result = script->getResult();
                                                                        if (result != NULL)
                                                                        {
-                                                                               TCHAR *temp = result->GetValueAsCString();
+                                                                               const TCHAR *temp = result->getValueAsCString();
                                                                                if (temp != NULL)
                                                                                {
                                                                                        dwSize += (DWORD)_tcslen(temp);
@@ -385,16 +385,16 @@ TCHAR *Event::expandText(const TCHAR *pszTemplate, const TCHAR *pszAlarmMsg)
                                                                else
                                                                {
                                                                        DbgPrintf(4, "Event::ExpandText(%d, \"%s\"): Script %s execution error: %s",
-                                                                                                m_dwCode, pszTemplate, scriptName, script->GetErrorText());
+                                                                                                m_dwCode, pszTemplate, scriptName, script->getErrorText());
                                                                        PostEvent(EVENT_SCRIPT_ERROR, g_dwMgmtNode, _T("ssd"), scriptName,
-                                                                                                script->GetErrorText(), 0);
+                                                                                                script->getErrorText(), 0);
                                                                }
                                                        }
                                                        else
                                                        {
                                                                DbgPrintf(4, "Event::ExpandText(%d, \"%s\"): Cannot find script %s", m_dwCode, pszTemplate, scriptName);
                                                        }
-                                                       g_pScriptLibrary->Unlock();
+                                                       g_pScriptLibrary->unlock();
                                                }
                                                break;
                                        case '{':       // Custom attribute
index a02533f..3ff825f 100644 (file)
@@ -39,7 +39,7 @@ class NXSL_DiscoveryClass : public NXSL_Class
 public:
    NXSL_DiscoveryClass();
 
-   virtual NXSL_Value *GetAttr(NXSL_Object *pObject, char *pszAttr);
+   virtual NXSL_Value *getAttr(NXSL_Object *pObject, char *pszAttr);
 };
 
 
@@ -53,13 +53,13 @@ NXSL_DiscoveryClass::NXSL_DiscoveryClass()
    strcpy(m_szName, "NewNode");
 }
 
-NXSL_Value *NXSL_DiscoveryClass::GetAttr(NXSL_Object *pObject, char *pszAttr)
+NXSL_Value *NXSL_DiscoveryClass::getAttr(NXSL_Object *pObject, char *pszAttr)
 {
    DISCOVERY_FILTER_DATA *pData;
    NXSL_Value *pValue = NULL;
    char szBuffer[256];
 
-   pData = (DISCOVERY_FILTER_DATA *)pObject->Data();
+   pData = (DISCOVERY_FILTER_DATA *)pObject->getData();
    if (!strcmp(pszAttr, "ipAddr"))
    {
       IpToStr(pData->dwIpAddr, szBuffer);
@@ -378,30 +378,30 @@ static BOOL AcceptNewNode(DWORD dwIpAddr, DWORD dwNetMask)
    }
    else
    {
-      g_pScriptLibrary->Lock();
-      pScript = g_pScriptLibrary->FindScript(szFilter);
+      g_pScriptLibrary->lock();
+      pScript = g_pScriptLibrary->findScript(szFilter);
       if (pScript != NULL)
       {
          DbgPrintf(4, "AcceptNewNode(%s): Running filter script %s", szIpAddr, szFilter);
          pValue = new NXSL_Value(new NXSL_Object(&m_nxslDiscoveryClass, &data));
-         if (pScript->Run(NULL, 1, &pValue) == 0)
+         if (pScript->run(NULL, 1, &pValue) == 0)
          {
-            bResult = (pScript->GetResult()->GetValueAsInt32() != 0) ? TRUE : FALSE;
+            bResult = (pScript->getResult()->getValueAsInt32() != 0) ? TRUE : FALSE;
             DbgPrintf(4, "AcceptNewNode(%s): Filter script result: %d", szIpAddr, bResult);
          }
          else
          {
             DbgPrintf(4, "AcceptNewNode(%s): Filter script execution error: %s",
-                      szIpAddr, pScript->GetErrorText());
+                      szIpAddr, pScript->getErrorText());
             PostEvent(EVENT_SCRIPT_ERROR, g_dwMgmtNode, _T("ssd"), szFilter,
-                      pScript->GetErrorText(), 0);
+                      pScript->getErrorText(), 0);
          }
       }
       else
       {
          DbgPrintf(4, "AcceptNewNode(%s): Cannot find filter script %s", szIpAddr, szFilter);
       }
-      g_pScriptLibrary->Unlock();
+      g_pScriptLibrary->unlock();
    }
 
    return bResult;
index e69cf41..80af335 100644 (file)
@@ -33,13 +33,13 @@ NXSL_NodeClass::NXSL_NodeClass()
    strcpy(m_szName, "NetXMS_Node");
 }
 
-NXSL_Value *NXSL_NodeClass::GetAttr(NXSL_Object *pObject, char *pszAttr)
+NXSL_Value *NXSL_NodeClass::getAttr(NXSL_Object *pObject, char *pszAttr)
 {
    Node *pNode;
    NXSL_Value *pValue = NULL;
    char szBuffer[256];
 
-   pNode = (Node *)pObject->Data();
+   pNode = (Node *)pObject->getData();
    if (!strcmp(pszAttr, "name"))
    {
       pValue = new NXSL_Value(pNode->Name());
@@ -127,12 +127,12 @@ NXSL_EventClass::NXSL_EventClass()
    strcpy(m_szName, "NetXMS_Event");
 }
 
-NXSL_Value *NXSL_EventClass::GetAttr(NXSL_Object *pObject, char *pszAttr)
+NXSL_Value *NXSL_EventClass::getAttr(NXSL_Object *pObject, char *pszAttr)
 {
    Event *event;
    NXSL_Value *value = NULL;
 
-   event = (Event *)pObject->Data();
+   event = (Event *)pObject->getData();
    if (!strcmp(pszAttr, "code"))
    {
       value = new NXSL_Value(event->getCode());
@@ -167,7 +167,7 @@ NXSL_Value *NXSL_EventClass::GetAttr(NXSL_Object *pObject, char *pszAttr)
                DWORD i;
 
                for(i = 0; i < event->getParametersCount(); i++)
-                       array->Set((int)(i + 1), new NXSL_Value(event->getParameter(i)));
+                       array->set((int)(i + 1), new NXSL_Value(event->getParameter(i)));
       value = new NXSL_Value(array);
    }
    return value;
index 209617c..4317047 100644 (file)
@@ -38,24 +38,24 @@ void RegisterDCIFunctions(NXSL_Environment *pEnv);
 // First argument is a node object, and second is an attribute name
 //
 
-static int F_GetCustomAttribute(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+static int F_GetCustomAttribute(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
        NXSL_Object *object;
        Node *node;
        const TCHAR *value;
 
-       if (!argv[0]->IsObject())
+       if (!argv[0]->isObject())
                return NXSL_ERR_NOT_OBJECT;
 
-       if (!argv[1]->IsString())
+       if (!argv[1]->isString())
                return NXSL_ERR_NOT_STRING;
 
-       object = argv[0]->GetValueAsObject();
-       if (_tcscmp(object->Class()->Name(), "NetXMS_Node"))
+       object = argv[0]->getValueAsObject();
+       if (_tcscmp(object->getClass()->getName(), "NetXMS_Node"))
                return NXSL_ERR_BAD_CLASS;
 
-       node = (Node *)object->Data();
-       value = node->GetCustomAttribute(argv[1]->GetValueAsCString());
+       node = (Node *)object->getData();
+       value = node->GetCustomAttribute(argv[1]->getValueAsCString());
        if (value != NULL)
        {
                *ppResult = new NXSL_Value(value);
@@ -74,20 +74,20 @@ static int F_GetCustomAttribute(int argc, NXSL_Value **argv, NXSL_Value **ppResu
 // Parameters: node object and interface index
 //
 
-static int F_GetInterfaceName(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+static int F_GetInterfaceName(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
-       if (!argv[0]->IsObject())
+       if (!argv[0]->isObject())
                return NXSL_ERR_NOT_OBJECT;
 
-       if (!argv[1]->IsInteger())
+       if (!argv[1]->isInteger())
                return NXSL_ERR_NOT_INTEGER;
 
-       NXSL_Object *object = argv[0]->GetValueAsObject();
-       if (_tcscmp(object->Class()->Name(), "NetXMS_Node"))
+       NXSL_Object *object = argv[0]->getValueAsObject();
+       if (_tcscmp(object->getClass()->getName(), "NetXMS_Node"))
                return NXSL_ERR_BAD_CLASS;
 
-       Node *node = (Node *)object->Data();
-       Interface *ifc = node->FindInterface(argv[1]->GetValueAsUInt32(), INADDR_ANY);
+       Node *node = (Node *)object->getData();
+       Interface *ifc = node->FindInterface(argv[1]->getValueAsUInt32(), INADDR_ANY);
        if (ifc != NULL)
        {
                *ppResult = new NXSL_Value(ifc->Name());
@@ -119,8 +119,25 @@ static NXSL_ExtFunction m_nxslServerFunctions[] =
 NXSL_ServerEnv::NXSL_ServerEnv()
                : NXSL_Environment()
 {
-       SetLibrary(g_pScriptLibrary);
-       RegisterFunctionSet(sizeof(m_nxslServerFunctions) / sizeof(NXSL_ExtFunction), m_nxslServerFunctions);
+       setLibrary(g_pScriptLibrary);
+       registerFunctionSet(sizeof(m_nxslServerFunctions) / sizeof(NXSL_ExtFunction), m_nxslServerFunctions);
        RegisterDCIFunctions(this);
-       RegisterFunctionSet(g_nxslNumSituationFunctions, g_nxslSituationFunctions);
+       registerFunctionSet(g_nxslNumSituationFunctions, g_nxslSituationFunctions);
+}
+
+
+//
+// Script trace output
+//
+
+void NXSL_ServerEnv::trace(int level, const TCHAR *text)
+{
+       if (level == 0)
+       {
+               nxlog_write(MSG_OTHER, EVENTLOG_INFORMATION_TYPE, "s", text);
+       }
+       else
+       {
+               DbgPrintf(level, _T("%s"), text);
+       }
 }
index 017883a..e22d20b 100644 (file)
@@ -34,13 +34,13 @@ NXSL_Library *g_pScriptLibrary = NULL;
 // Read object's attribute
 //
 
-NXSL_Value *NXSL_NetXMSObjectClass::GetAttr(NXSL_Object *pObject, char *pszAttr)
+NXSL_Value *NXSL_NetXMSObjectClass::getAttr(NXSL_Object *pObject, char *pszAttr)
 {
    NetObj *pSysObj;
    NXSL_Value *pValue = NULL;
    TCHAR szBuffer[256];
 
-   pSysObj = (NetObj *)pObject->Data();
+   pSysObj = (NetObj *)pObject->getData();
    if (pSysObj != NULL)
    {
       if (!strcmp(pszAttr, "id"))
@@ -64,7 +64,7 @@ NXSL_Value *NXSL_NetXMSObjectClass::GetAttr(NXSL_Object *pObject, char *pszAttr)
 // Set object's attribute
 //
 
-BOOL NXSL_NetXMSObjectClass::SetAttr(NXSL_Object *pObject, char *pszAttr, NXSL_Value *pValue)
+BOOL NXSL_NetXMSObjectClass::setAttr(NXSL_Object *pObject, char *pszAttr, NXSL_Value *pValue)
 {
    return FALSE;
 }
@@ -74,7 +74,7 @@ BOOL NXSL_NetXMSObjectClass::SetAttr(NXSL_Object *pObject, char *pszAttr, NXSL_V
 // Load scripts from database
 //
 
-void LoadScripts(void)
+void LoadScripts()
 {
    DB_RESULT hResult;
    NXSL_Program *pScript;
@@ -94,7 +94,7 @@ void LoadScripts(void)
          free(pszCode);
          if (pScript != NULL)
          {
-            g_pScriptLibrary->AddScript(DBGetFieldULong(hResult, i, 0),
+            g_pScriptLibrary->addScript(DBGetFieldULong(hResult, i, 0),
                                         DBGetField(hResult, i, 1, szBuffer, MAX_DB_STRING), pScript);
          }
          else
@@ -119,8 +119,8 @@ void ReloadScript(DWORD dwScriptId)
    DB_RESULT hResult;
    NXSL_Program *pScript;
 
-   g_pScriptLibrary->Lock();
-   g_pScriptLibrary->DeleteScript(dwScriptId);
+   g_pScriptLibrary->lock();
+   g_pScriptLibrary->deleteScript(dwScriptId);
    
    _stprintf(szQuery, _T("SELECT script_name,script_code FROM script_library WHERE script_id=%d"), dwScriptId);
    hResult = DBSelect(g_hCoreDB, szQuery);
@@ -134,7 +134,7 @@ void ReloadScript(DWORD dwScriptId)
          free(pszCode);
          if (pScript != NULL)
          {
-            g_pScriptLibrary->AddScript(dwScriptId, DBGetField(hResult, 0, 0, szBuffer, MAX_DB_STRING), pScript);
+            g_pScriptLibrary->addScript(dwScriptId, DBGetField(hResult, 0, 0, szBuffer, MAX_DB_STRING), pScript);
          }
          else
          {
@@ -144,7 +144,7 @@ void ReloadScript(DWORD dwScriptId)
       }
       DBFreeResult(hResult);
    }
-   g_pScriptLibrary->Unlock();
+   g_pScriptLibrary->unlock();
 }
 
 
index 6c12aa9..ae7c2c4 100644 (file)
@@ -6699,9 +6699,9 @@ void ClientSession::DeleteScript(CSCPMessage *pRequest)
          _stprintf(szQuery, _T("DELETE FROM script_library WHERE script_id=%d"), dwScriptId);
          if (DBQuery(g_hCoreDB, szQuery))
          {
-            g_pScriptLibrary->Lock();
-            g_pScriptLibrary->DeleteScript(dwScriptId);
-            g_pScriptLibrary->Unlock();
+            g_pScriptLibrary->lock();
+            g_pScriptLibrary->deleteScript(dwScriptId);
+            g_pScriptLibrary->unlock();
             msg.SetVariable(VID_RCC, RCC_SUCCESS);
          }
          else
@@ -8047,10 +8047,10 @@ void ClientSession::SendConfigForAgent(CSCPMessage *pRequest)
 
             // Run script
             DbgPrintf(3, "Running configuration matching script %d", dwCfgId);
-            if (pScript->Run(NULL, 5, ppArgList) == 0)
+            if (pScript->run(NULL, 5, ppArgList) == 0)
             {
-               pValue = pScript->GetResult();
-               if (pValue->GetValueAsInt32() != 0)
+               pValue = pScript->getResult();
+               if (pValue->getValueAsInt32() != 0)
                {
                   DbgPrintf(3, "Configuration script %d matched for agent %s, sending config",
                             dwCfgId, IpToStr(m_dwHostAddr, szBuffer));
@@ -8071,7 +8071,7 @@ void ClientSession::SendConfigForAgent(CSCPMessage *pRequest)
             {
                _stprintf(szError, _T("AgentCfg::%d"), dwCfgId);
                PostEvent(EVENT_SCRIPT_ERROR, g_dwMgmtNode, _T("ssd"), szError,
-                         pScript->GetErrorText(), 0);
+                         pScript->getErrorText(), 0);
             }
             delete pScript;
          }
index 37db824..3b98a87 100644 (file)
@@ -537,7 +537,7 @@ NXSL_Value *NXSL_SituationClass::GetAttr(NXSL_Object *pObject, char *pszAttr)
    NXSL_Value *value = NULL;
        const TCHAR *attrValue;
 
-   instance = (SituationInstance *)pObject->Data();
+   instance = (SituationInstance *)pObject->getData();
    if (!strcmp(pszAttr, "name"))
    {
       value = new NXSL_Value(instance->GetParent()->GetName());
@@ -577,23 +577,23 @@ static NXSL_SituationClass m_nxslSituationClass;
 // NXSL function for finding situation
 //
 
-static int F_FindSituation(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+static int F_FindSituation(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
        Situation *situation;
        SituationInstance *instance;
 
-   if (argv[0]->IsInteger())
+   if (argv[0]->isInteger())
    {
-               situation = FindSituationById(argv[0]->GetValueAsUInt32());
+               situation = FindSituationById(argv[0]->getValueAsUInt32());
    }
    else        // First parameter is not a number, assume that it's a name
    {
-               situation = FindSituationByName(argv[0]->GetValueAsCString());
+               situation = FindSituationByName(argv[0]->getValueAsCString());
    }
 
        if (situation != NULL)
        {
-               instance = situation->FindInstance(argv[1]->GetValueAsCString());
+               instance = situation->FindInstance(argv[1]->getValueAsCString());
                if (instance != NULL)
                {
                        *ppResult = new NXSL_Value(new NXSL_Object(&m_nxslSituationClass, instance));
@@ -616,22 +616,22 @@ static int F_FindSituation(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
 // NXSL function: get situation instance attribute
 //
 
-static int F_GetSituationAttribute(int argc, NXSL_Value **argv, NXSL_Value **ppResult)
+static int F_GetSituationAttribute(int argc, NXSL_Value **argv, NXSL_Value **ppResult, NXSL_Program *program)
 {
        NXSL_Object *object;
        const TCHAR *attrValue;
 
-       if (!argv[0]->IsObject())
+       if (!argv[0]->isObject())
                return NXSL_ERR_NOT_OBJECT;
 
-       if (!argv[1]->IsString())
+       if (!argv[1]->isString())
                return NXSL_ERR_NOT_STRING;
 
-       object = argv[0]->GetValueAsObject();
-       if (_tcscmp(object->Class()->Name(), "Situation"))
+       object = argv[0]->getValueAsObject();
+       if (_tcscmp(object->getClass()->getName(), "Situation"))
                return NXSL_ERR_BAD_CLASS;
 
-       attrValue = ((SituationInstance *)object->Data())->GetAttribute(argv[1]->GetValueAsCString());
+       attrValue = ((SituationInstance *)object->getData())->GetAttribute(argv[1]->getValueAsCString());
        *ppResult = (attrValue != NULL) ? new NXSL_Value(attrValue) : new NXSL_Value;
        return 0;
 }
index 69601a9..11b510e 100644 (file)
@@ -658,8 +658,14 @@ static DWORD HandlerRoute(DWORD dwVersion, SNMP_Variable *pVar,
 {
    DWORD oidName[MAX_OID_LEN], dwNameLen, dwResult;
    ROUTE route;
+       ROUTING_TABLE *rt = (ROUTING_TABLE *)pArg;
 
    dwNameLen = pVar->GetName()->Length();
+       if ((dwNameLen < 5) || (dwNameLen > MAX_OID_LEN))
+       {
+               DbgPrintf(4, _T("HandlerRoute(): strange dwNameLen %d (name=%s)"), dwNameLen, pVar->GetName()->GetValueAsText());
+               return SNMP_ERR_SUCCESS;
+       }
    memcpy(oidName, pVar->GetName()->GetValue(), dwNameLen * sizeof(DWORD));
    route.dwDestAddr = ntohl(pVar->GetValueAsUInt());
 
@@ -683,12 +689,9 @@ static DWORD HandlerRoute(DWORD dwVersion, SNMP_Variable *pVar,
                            &route.dwDestMask, sizeof(DWORD), FALSE, FALSE)) != SNMP_ERR_SUCCESS)
       return dwResult;
 
-   ((ROUTING_TABLE *)pArg)->iNumEntries++;
-   ((ROUTING_TABLE *)pArg)->pRoutes = 
-      (ROUTE *)realloc(((ROUTING_TABLE *)pArg)->pRoutes,
-                       sizeof(ROUTE) * ((ROUTING_TABLE *)pArg)->iNumEntries);
-   memcpy(&((ROUTING_TABLE *)pArg)->pRoutes[((ROUTING_TABLE *)pArg)->iNumEntries - 1],
-          &route, sizeof(ROUTE));
+   rt->iNumEntries++;
+   rt->pRoutes = (ROUTE *)realloc(rt->pRoutes, sizeof(ROUTE) * rt->iNumEntries);
+   memcpy(&rt->pRoutes[rt->iNumEntries - 1], &route, sizeof(ROUTE));
    return SNMP_ERR_SUCCESS;
 }
 
index 7d1248c..5b07bcd 100644 (file)
@@ -1097,11 +1097,11 @@ BOOL Template::isApplicable(Node *node)
        if (m_applyFilter != NULL)
        {
                pEnv = new NXSL_ServerEnv;
-               m_applyFilter->SetGlobalVariable(_T("$node"), new NXSL_Value(new NXSL_Object(&g_nxslNodeClass, node)));
-               if (m_applyFilter->Run(pEnv, 0, NULL) == 0)
+               m_applyFilter->setGlobalVariable(_T("$node"), new NXSL_Value(new NXSL_Object(&g_nxslNodeClass, node)));
+               if (m_applyFilter->run(pEnv, 0, NULL) == 0)
                {
-                       value = m_applyFilter->GetResult();
-                       result = ((value != NULL) && (value->GetValueAsInt32() != 0));
+                       value = m_applyFilter->getResult();
+                       result = ((value != NULL) && (value->getValueAsInt32() != 0));
                }
                else
                {
@@ -1109,8 +1109,8 @@ BOOL Template::isApplicable(Node *node)
 
                        _sntprintf(buffer, 1024, _T("Template::%s::%d"), m_szName, m_dwId);
                        PostEvent(EVENT_SCRIPT_ERROR, g_dwMgmtNode, _T("ssd"), buffer,
-                                                m_applyFilter->GetErrorText(), m_dwId);
-                       nxlog_write(MSG_TEMPLATE_SCRIPT_EXECUTION_ERROR, EVENTLOG_WARNING_TYPE, "dss", m_dwId, m_szName, m_applyFilter->GetErrorText());
+                                                m_applyFilter->getErrorText(), m_dwId);
+                       nxlog_write(MSG_TEMPLATE_SCRIPT_EXECUTION_ERROR, EVENTLOG_WARNING_TYPE, "dss", m_dwId, m_szName, m_applyFilter->getErrorText());
                }
        }
        UnlockData();
index 37110b5..1d3f3a3 100644 (file)
@@ -33,8 +33,8 @@ class NXSL_NetXMSObjectClass : public NXSL_Class
 public:
    NXSL_NetXMSObjectClass() : NXSL_Class() { _tcscpy(m_szName, _T("NetXMS_Object")); }
 
-   virtual NXSL_Value *GetAttr(NXSL_Object *pObject, char *pszAttr);
-   virtual BOOL SetAttr(NXSL_Object *pObject, char *pszAttr, NXSL_Value *pValue);
+   virtual NXSL_Value *getAttr(NXSL_Object *pObject, char *pszAttr);
+   virtual BOOL setAttr(NXSL_Object *pObject, char *pszAttr, NXSL_Value *pValue);
 };
 
 
@@ -47,7 +47,7 @@ class NXSL_NodeClass : public NXSL_Class
 public:
    NXSL_NodeClass();
 
-   virtual NXSL_Value *GetAttr(NXSL_Object *pObject, char *pszAttr);
+   virtual NXSL_Value *getAttr(NXSL_Object *pObject, char *pszAttr);
 };
 
 
@@ -60,7 +60,7 @@ class NXSL_EventClass : public NXSL_Class
 public:
    NXSL_EventClass();
 
-   virtual NXSL_Value *GetAttr(NXSL_Object *pObject, char *pszAttr);
+   virtual NXSL_Value *getAttr(NXSL_Object *pObject, char *pszAttr);
 };
 
 
@@ -72,6 +72,8 @@ class NXSL_ServerEnv : public NXSL_Environment
 {
 public:
        NXSL_ServerEnv();
+
+       virtual void trace(int level, const TCHAR *text);
 };