Remove some warnings in the C code (mostly unused variables) 66/11066/2
Sylvestre Ledru [Wed, 27 Mar 2013 14:20:28 +0000 (15:20 +0100)]
Change-Id: I6fb4117fc68152bd96d182a151464e8f07151fe9

12 files changed:
scilab/modules/external_objects/src/cpp/ScilabObjects.cpp
scilab/modules/external_objects/src/cpp/array.cpp
scilab/modules/external_objects/src/cpp/cast.cpp
scilab/modules/external_objects/src/cpp/doubleExclam_invoke.cpp
scilab/modules/external_objects/src/cpp/getEnvId.cpp
scilab/modules/external_objects/src/cpp/getEnvironmentName.cpp
scilab/modules/external_objects/src/cpp/getFields.cpp
scilab/modules/external_objects/src/cpp/getMethods.cpp
scilab/modules/external_objects/src/cpp/getNamedVariable.cpp
scilab/modules/external_objects/src/cpp/getRepresentation.cpp
scilab/modules/external_objects/src/cpp/getsetOptions.cpp
scilab/modules/xml/sci_gateway/cpp/sci_xmlAppend.cpp

index 5534aa8..1415f87 100644 (file)
@@ -21,34 +21,34 @@ extern "C" {
 
 namespace org_modules_external_objects
 {
-    bool ScilabObjects::isInit = false;
-    const char * ScilabObjects::_EOBJ[] = {"_EObj", "_EnvId", "_id"};
-    const char * ScilabObjects::_ECLASS[] = {"_EClass", "_EnvId", "_id"};
-    const char * ScilabObjects::_EVOID[] = {"_EVoid", "_EnvId", "_id"};
-    const char * ScilabObjects::_INVOKE_ = "!!_invoke_";
+bool ScilabObjects::isInit = false;
+const char * ScilabObjects::_EOBJ[] = {"_EObj", "_EnvId", "_id"};
+const char * ScilabObjects::_ECLASS[] = {"_EClass", "_EnvId", "_id"};
+const char * ScilabObjects::_EVOID[] = {"_EVoid", "_EnvId", "_id"};
+const char * ScilabObjects::_INVOKE_ = "!!_invoke_";
 
-    void ScilabObjects::initialization(ScilabAbstractEnvironment & env, void * pvApiCtx)
+void ScilabObjects::initialization(ScilabAbstractEnvironment & env, void * pvApiCtx)
+{
+    if (!isInit)
     {
-        if (!isInit)
-        {
-            isInit = true;
-            //createNamedEnvironmentObject(EXTERNAL_OBJECT, "enull", 0, 0, pvApiCtx);
-        }
+        isInit = true;
+        //createNamedEnvironmentObject(EXTERNAL_OBJECT, "enull", 0, 0, pvApiCtx);
     }
+}
 
-    int ScilabObjects::createNamedEnvironmentObject(int type, const char * name, int id, const int envId, void * pvApiCtx)
-    {
-        const char ** fields;
-        int * mlistaddr = 0;
-        SciErr err;
+int ScilabObjects::createNamedEnvironmentObject(int type, const char * name, int id, const int envId, void * pvApiCtx)
+{
+    const char ** fields;
+    int * mlistaddr = 0;
+    SciErr err;
 
-        if (envId < 0)
-        {
-            throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid environment"));
-        }
+    if (envId < 0)
+    {
+        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid environment"));
+    }
 
-        switch (type)
-        {
+    switch (type)
+    {
         case EXTERNAL_OBJECT:
             fields = static_cast<const char **>(_EOBJ);
             break;
@@ -61,53 +61,53 @@ namespace org_modules_external_objects
         default :
             fields = static_cast<const char **>(_EOBJ);
             break;
-        }
-
-        err = createNamedMList(pvApiCtx, name, FIELDS_LENGTH, &mlistaddr);
-        if (err.iErr)
-        {
-            if (err.iErr == API_ERROR_INVALID_NAME)
-            {
-                throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable name: %s"), name);
-            }
-
-            throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Cannot allocate memory"));
-        }
+    }
 
-        err = createMatrixOfStringInNamedList(pvApiCtx, name, mlistaddr, 1, 1, FIELDS_LENGTH, fields);
-        if (err.iErr)
+    err = createNamedMList(pvApiCtx, name, FIELDS_LENGTH, &mlistaddr);
+    if (err.iErr)
+    {
+        if (err.iErr == API_ERROR_INVALID_NAME)
         {
-            throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Cannot allocate memory"));
+            throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable name: %s"), name);
         }
 
-        err = createMatrixOfInteger32InNamedList(pvApiCtx, name, mlistaddr, EXTERNAL_ENV_ID_POSITION, 1, 1, &envId);
-        if (err.iErr)
-        {
-            throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Cannot allocate memory"));
-        }
+        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Cannot allocate memory"));
+    }
 
-        err = createMatrixOfInteger32InNamedList(pvApiCtx, name, mlistaddr, EXTERNAL_OBJ_ID_POSITION, 1, 1, &id);
-        if (err.iErr)
-        {
-            throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Cannot allocate memory"));
-        }
+    err = createMatrixOfStringInNamedList(pvApiCtx, name, mlistaddr, 1, 1, FIELDS_LENGTH, fields);
+    if (err.iErr)
+    {
+        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Cannot allocate memory"));
+    }
 
-        return 1;
+    err = createMatrixOfInteger32InNamedList(pvApiCtx, name, mlistaddr, EXTERNAL_ENV_ID_POSITION, 1, 1, &envId);
+    if (err.iErr)
+    {
+        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Cannot allocate memory"));
     }
 
-    void ScilabObjects::createEnvironmentObjectAtPos(int type, int pos, int id, const int envId, void * pvApiCtx)
+    err = createMatrixOfInteger32InNamedList(pvApiCtx, name, mlistaddr, EXTERNAL_OBJ_ID_POSITION, 1, 1, &id);
+    if (err.iErr)
     {
-        const char ** fields = 0;
-        int * mlistaddr = 0;
-        SciErr err;
+        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Cannot allocate memory"));
+    }
 
-        if (envId < 0)
-        {
-            throw ScilabAbstractEnvironmentException("Invalid environment");
-        }
+    return 1;
+}
 
-        switch (type)
-        {
+void ScilabObjects::createEnvironmentObjectAtPos(int type, int pos, int id, const int envId, void * pvApiCtx)
+{
+    const char ** fields = 0;
+    int * mlistaddr = 0;
+    SciErr err;
+
+    if (envId < 0)
+    {
+        throw ScilabAbstractEnvironmentException("Invalid environment");
+    }
+
+    switch (type)
+    {
         case EXTERNAL_OBJECT:
             fields = static_cast<const char **>(_EOBJ);
             break;
@@ -120,98 +120,134 @@ namespace org_modules_external_objects
         default :
             fields = static_cast<const char **>(_EOBJ);
             break;
-        }
+    }
 
-        err = createMList(pvApiCtx, pos, FIELDS_LENGTH, &mlistaddr);
-        if (err.iErr)
-        {
-            throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Cannot allocate memory"));
-        }
+    err = createMList(pvApiCtx, pos, FIELDS_LENGTH, &mlistaddr);
+    if (err.iErr)
+    {
+        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Cannot allocate memory"));
+    }
 
-        err = createMatrixOfStringInList(pvApiCtx, pos, mlistaddr, 1, 1, FIELDS_LENGTH, fields);
-        if (err.iErr)
-        {
-            throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Cannot allocate memory"));
-        }
+    err = createMatrixOfStringInList(pvApiCtx, pos, mlistaddr, 1, 1, FIELDS_LENGTH, fields);
+    if (err.iErr)
+    {
+        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Cannot allocate memory"));
+    }
 
-        err = createMatrixOfInteger32InList(pvApiCtx, pos, mlistaddr, EXTERNAL_ENV_ID_POSITION, 1, 1, &envId);
-        if (err.iErr)
-        {
-            throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Cannot allocate memory"));
-        }
+    err = createMatrixOfInteger32InList(pvApiCtx, pos, mlistaddr, EXTERNAL_ENV_ID_POSITION, 1, 1, &envId);
+    if (err.iErr)
+    {
+        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Cannot allocate memory"));
+    }
 
-        err = createMatrixOfInteger32InList(pvApiCtx, pos, mlistaddr, EXTERNAL_OBJ_ID_POSITION, 1, 1, &id);
-        if (err.iErr)
-        {
-            throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Cannot allocate memory"));
-        }
+    err = createMatrixOfInteger32InList(pvApiCtx, pos, mlistaddr, EXTERNAL_OBJ_ID_POSITION, 1, 1, &id);
+    if (err.iErr)
+    {
+        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Cannot allocate memory"));
+    }
+}
+
+void ScilabObjects::copyInvocationMacroToStack(int pos, ScilabAbstractEnvironment & env, void * pvApiCtx)
+{
+    static bool init = false;
+    static int id[nsiz];
+    static int interf = 0;
+    static int funnumber = 0;
+
+    if (!init)
+    {
+        init = true;
+        C2F(str2name)(const_cast<char *>(_INVOKE_), id, strlen(_INVOKE_));
+        int fins = Fin;
+        int funs = C2F(com).fun;
+        Fin = -1;
+        C2F(funs)(id);
+        funnumber = Fin;
+        interf = C2F(com).fun;
+        C2F(com).fun = funs;
+        Fin = fins;
     }
 
-    void ScilabObjects::copyInvocationMacroToStack(int pos, ScilabAbstractEnvironment & env, void * pvApiCtx)
+    int tops = Top;
+    // Remove 1 since varfunptr will increment Top
+    Top = Top - Rhs + pos - 1;
+
+    // Create a function pointer variable
+    C2F(varfunptr)(id, &interf, &funnumber);
+    C2F(intersci).ntypes[pos - 1] = '$';
+
+    Top = tops;
+
+    OptionsHelper::setCopyOccured(true);
+}
+
+void ScilabObjects::removeTemporaryVars(const int envId, int * tmpvar)
+{
+    if (tmpvar && *tmpvar)
     {
-        static bool init = false;
-        static int id[nsiz];
-        static int interf = 0;
-        static int funnumber = 0;
+        ScilabAbstractEnvironment & env = ScilabEnvironments::getEnvironment(envId);
 
-        if (!init)
+        for (int i = 1; i <= *tmpvar; i++)
         {
-            init = true;
-            C2F(str2name)(const_cast<char *>(_INVOKE_), id, strlen(_INVOKE_));
-            int fins = Fin;
-            int funs = C2F(com).fun;
-            Fin = -1;
-            C2F(funs)(id);
-            funnumber = Fin;
-            interf = C2F(com).fun;
-            C2F(com).fun = funs;
-            Fin = fins;
+            env.removeobject(tmpvar[i]);
         }
 
-        int tops = Top;
-        // Remove 1 since varfunptr will increment Top
-        Top = Top - Rhs + pos - 1;
-
-        // Create a function pointer variable
-        C2F(varfunptr)(id, &interf, &funnumber);
-        C2F(intersci).ntypes[pos - 1] = '$';
+        *tmpvar = 0;
+    }
+}
 
-        Top = tops;
+void ScilabObjects::removeVar(int * addr, void * pvApiCtx)
+{
+    SciErr err;
+    int type, row, col, * id;
 
-        OptionsHelper::setCopyOccured(true);
+    err = getVarType(pvApiCtx, addr, &type);
+    if (err.iErr)
+    {
+        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
     }
 
-    void ScilabObjects::removeTemporaryVars(const int envId, int * tmpvar)
+    if (type == sci_mlist && (isExternalObjOrClass(addr, pvApiCtx)))
     {
-        if (tmpvar && *tmpvar)
+        err = getMatrixOfInteger32InList(pvApiCtx, addr, EXTERNAL_OBJ_ID_POSITION, &row, &col, &id);
+        if (err.iErr)
         {
-            ScilabAbstractEnvironment & env = ScilabEnvironments::getEnvironment(envId);
+            throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
+        }
 
-            for (int i = 1; i <= *tmpvar; i++)
-            {
-                env.removeobject(tmpvar[i]);
-            }
+        int envId = getEnvironmentId(addr, pvApiCtx);
+        ScilabAbstractEnvironment & env = ScilabEnvironments::getEnvironment(envId);
 
-            *tmpvar = 0;
-        }
+        env.removeobject(*id);
     }
-
-    void ScilabObjects::removeVar(int * addr, void * pvApiCtx)
+    else if (type == sci_strings)
     {
-        SciErr err;
-        int type, row, col, * id;
+        char * varName = 0;
+        if (getAllocatedSingleString(pvApiCtx, addr, &varName))
+        {
+            throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
+        }
+
+        err = getVarAddressFromName(pvApiCtx, varName, &addr);
+        if (err.iErr)
+        {
+            freeAllocatedSingleString(varName);
+            return;
+        }
 
         err = getVarType(pvApiCtx, addr, &type);
         if (err.iErr)
         {
+            freeAllocatedSingleString(varName);
             throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
         }
 
-        if (type == sci_mlist && (isExternalObjOrClass(addr, pvApiCtx)))
+        if (type == sci_mlist && isExternalObjOrClass(addr, pvApiCtx))
         {
             err = getMatrixOfInteger32InList(pvApiCtx, addr, EXTERNAL_OBJ_ID_POSITION, &row, &col, &id);
             if (err.iErr)
             {
+                freeAllocatedSingleString(varName);
                 throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
             }
 
@@ -219,67 +255,31 @@ namespace org_modules_external_objects
             ScilabAbstractEnvironment & env = ScilabEnvironments::getEnvironment(envId);
 
             env.removeobject(*id);
-        }
-        else if (type == sci_strings)
-        {
-            char * varName = 0;
-            if (getAllocatedSingleString(pvApiCtx, addr, &varName))
-            {
-                throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
-            }
-
-            err = getVarAddressFromName(pvApiCtx, varName, &addr);
-            if (err.iErr)
-            {
-                freeAllocatedSingleString(varName);
-                return;
-            }
-
-            err = getVarType(pvApiCtx, addr, &type);
-            if (err.iErr)
-            {
-                freeAllocatedSingleString(varName);
-                throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
-            }
-
-            if (type == sci_mlist && isExternalObjOrClass(addr, pvApiCtx))
-            {
-                err = getMatrixOfInteger32InList(pvApiCtx, addr, EXTERNAL_OBJ_ID_POSITION, &row, &col, &id);
-                if (err.iErr)
-                {
-                    freeAllocatedSingleString(varName);
-                    throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
-                }
-
-                int envId = getEnvironmentId(addr, pvApiCtx);
-                ScilabAbstractEnvironment & env = ScilabEnvironments::getEnvironment(envId);
-
-                env.removeobject(*id);
-                deleteNamedVariable(pvApiCtx, varName);
-                freeAllocatedSingleString(varName);
-            }
+            deleteNamedVariable(pvApiCtx, varName);
+            freeAllocatedSingleString(varName);
         }
     }
+}
 
-    bool ScilabObjects::unwrap(int idObj, int pos, const int envId, void * pvApiCtx)
+bool ScilabObjects::unwrap(int idObj, int pos, const int envId, void * pvApiCtx)
+{
+    if (idObj == 0)
     {
-        if (idObj == 0)
+        if (createEmptyMatrix(pvApiCtx, pos))
         {
-            if (createEmptyMatrix(pvApiCtx, pos))
-            {
-                throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot create data"));
-            }
-            return true;
+            throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot create data"));
         }
+        return true;
+    }
 
-        VariableType type = Nothing;
-        ScilabAbstractEnvironment & env = ScilabEnvironments::getEnvironment(envId);
-        const ScilabAbstractEnvironmentWrapper & wrapper = env.getWrapper();
+    VariableType type = Nothing;
+    ScilabAbstractEnvironment & env = ScilabEnvironments::getEnvironment(envId);
+    const ScilabAbstractEnvironmentWrapper & wrapper = env.getWrapper();
 
-        type = env.isunwrappable(idObj);
+    type = env.isunwrappable(idObj);
 
-        switch (type)
-        {
+    switch (type)
+    {
         case Nothing:
             return false;
         case Null:
@@ -406,62 +406,62 @@ namespace org_modules_external_objects
             break;
         default:
             return false;
-        }
-
-        return true;
     }
 
-    int ScilabObjects::getEnvironmentId(int * addr, void * pvApiCtx)
-    {
-        SciErr err;
-        int row = 0, col = 0;
-        int * envId = 0;
+    return true;
+}
 
-        err = getMatrixOfInteger32InList(pvApiCtx, addr, EXTERNAL_ENV_ID_POSITION, &row, &col, &envId);
-        if (err.iErr)
-        {
-            throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
-        }
+int ScilabObjects::getEnvironmentId(int * addr, void * pvApiCtx)
+{
+    SciErr err;
+    int row = 0, col = 0;
+    int * envId = 0;
 
-        return *envId;
+    err = getMatrixOfInteger32InList(pvApiCtx, addr, EXTERNAL_ENV_ID_POSITION, &row, &col, &envId);
+    if (err.iErr)
+    {
+        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
     }
 
-    int ScilabObjects::getExternalId(int * addr, void * pvApiCtx)
-    {
-        SciErr err;
-        int row = 0, col = 0;
-        int * id = 0;
+    return *envId;
+}
 
-        err = getMatrixOfInteger32InList(pvApiCtx, addr, EXTERNAL_OBJ_ID_POSITION, &row, &col, &id);
-        if (err.iErr)
-        {
-            throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
-        }
+int ScilabObjects::getExternalId(int * addr, void * pvApiCtx)
+{
+    SciErr err;
+    int row = 0, col = 0;
+    int * id = 0;
 
-        return *id;
+    err = getMatrixOfInteger32InList(pvApiCtx, addr, EXTERNAL_OBJ_ID_POSITION, &row, &col, &id);
+    if (err.iErr)
+    {
+        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
     }
 
-    int ScilabObjects::getArgumentId(int * addr, int * tmpvars, const bool isRef, const bool isClass, const int envId, void * pvApiCtx)
-    {
-        SciErr err;
-        int typ, row = 0, col = 0, returnId;
-        const ScilabAbstractEnvironmentWrapper & wrapper = ScilabEnvironments::getEnvironment(envId).getWrapper();
+    return *id;
+}
 
-        err = getVarType(pvApiCtx, addr, &typ);
-        if (err.iErr)
-        {
-            removeTemporaryVars(envId, tmpvars);
-            throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
-        }
+int ScilabObjects::getArgumentId(int * addr, int * tmpvars, const bool isRef, const bool isClass, const int envId, void * pvApiCtx)
+{
+    SciErr err;
+    int typ, row = 0, col = 0, returnId;
+    const ScilabAbstractEnvironmentWrapper & wrapper = ScilabEnvironments::getEnvironment(envId).getWrapper();
 
-        if (isClass && typ != sci_mlist)
-        {
-            removeTemporaryVars(envId, tmpvars);
-            throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("External Class expected"));
-        }
+    err = getVarType(pvApiCtx, addr, &typ);
+    if (err.iErr)
+    {
+        removeTemporaryVars(envId, tmpvars);
+        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
+    }
 
-        switch (typ)
-        {
+    if (isClass && typ != sci_mlist)
+    {
+        removeTemporaryVars(envId, tmpvars);
+        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("External Class expected"));
+    }
+
+    switch (typ)
+    {
         case sci_matrix :
         {
             double * mat = 0;
@@ -508,96 +508,96 @@ namespace org_modules_external_objects
 
             switch (prec)
             {
-            case SCI_INT8 :
-                err = getMatrixOfInteger8(pvApiCtx, addr, &row, &col, (char**)(&ints));
-                if (err.iErr)
-                {
-                    removeTemporaryVars(envId, tmpvars);
-                    throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
-                }
+                case SCI_INT8 :
+                    err = getMatrixOfInteger8(pvApiCtx, addr, &row, &col, (char**)(&ints));
+                    if (err.iErr)
+                    {
+                        removeTemporaryVars(envId, tmpvars);
+                        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
+                    }
 
-                returnId = wrap<char>(row, col, static_cast<char *>(ints), wrapper, isRef);
-                tmpvars[++tmpvars[0]] = returnId;
-                return returnId;
-            case SCI_UINT8 :
-                err = getMatrixOfUnsignedInteger8(pvApiCtx, addr, &row, &col, (unsigned char**)(&ints));
-                if (err.iErr)
-                {
-                    removeTemporaryVars(envId, tmpvars);
-                    throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
-                }
+                    returnId = wrap<char>(row, col, static_cast<char *>(ints), wrapper, isRef);
+                    tmpvars[++tmpvars[0]] = returnId;
+                    return returnId;
+                case SCI_UINT8 :
+                    err = getMatrixOfUnsignedInteger8(pvApiCtx, addr, &row, &col, (unsigned char**)(&ints));
+                    if (err.iErr)
+                    {
+                        removeTemporaryVars(envId, tmpvars);
+                        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
+                    }
 
-                returnId = wrap<unsigned char>(row, col, static_cast<unsigned char *>(ints), wrapper, isRef);
-                tmpvars[++tmpvars[0]] = returnId;
-                return returnId;
-            case SCI_INT16 :
-                err = getMatrixOfInteger16(pvApiCtx, addr, &row, &col, (short**)(&ints));
-                if (err.iErr)
-                {
-                    removeTemporaryVars(envId, tmpvars);
-                    throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
-                }
+                    returnId = wrap<unsigned char>(row, col, static_cast<unsigned char *>(ints), wrapper, isRef);
+                    tmpvars[++tmpvars[0]] = returnId;
+                    return returnId;
+                case SCI_INT16 :
+                    err = getMatrixOfInteger16(pvApiCtx, addr, &row, &col, (short**)(&ints));
+                    if (err.iErr)
+                    {
+                        removeTemporaryVars(envId, tmpvars);
+                        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
+                    }
 
-                returnId = wrap<short>(row, col, static_cast<short *>(ints), wrapper, isRef);
-                tmpvars[++tmpvars[0]] = returnId;
-                return returnId;
-            case SCI_UINT16 :
-                err = getMatrixOfUnsignedInteger16(pvApiCtx, addr, &row, &col, (unsigned short**)(&ints));
-                if (err.iErr)
-                {
-                    removeTemporaryVars(envId, tmpvars);
-                    throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
-                }
+                    returnId = wrap<short>(row, col, static_cast<short *>(ints), wrapper, isRef);
+                    tmpvars[++tmpvars[0]] = returnId;
+                    return returnId;
+                case SCI_UINT16 :
+                    err = getMatrixOfUnsignedInteger16(pvApiCtx, addr, &row, &col, (unsigned short**)(&ints));
+                    if (err.iErr)
+                    {
+                        removeTemporaryVars(envId, tmpvars);
+                        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
+                    }
 
-                returnId = wrap<unsigned short>(row, col, static_cast<unsigned short *>(ints), wrapper, isRef);
-                tmpvars[++tmpvars[0]] = returnId;
-                return returnId;
-            case SCI_INT32 :
-                err = getMatrixOfInteger32(pvApiCtx, addr, &row, &col, (int**)(&ints));
-                if (err.iErr)
-                {
-                    removeTemporaryVars(envId, tmpvars);
-                    throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
-                }
+                    returnId = wrap<unsigned short>(row, col, static_cast<unsigned short *>(ints), wrapper, isRef);
+                    tmpvars[++tmpvars[0]] = returnId;
+                    return returnId;
+                case SCI_INT32 :
+                    err = getMatrixOfInteger32(pvApiCtx, addr, &row, &col, (int**)(&ints));
+                    if (err.iErr)
+                    {
+                        removeTemporaryVars(envId, tmpvars);
+                        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
+                    }
 
-                returnId = wrap<int>(row, col, static_cast<int *>(ints), wrapper, isRef);
-                tmpvars[++tmpvars[0]] = returnId;
-                return returnId;
-            case SCI_UINT32 :
-                err = getMatrixOfUnsignedInteger32(pvApiCtx, addr, &row, &col, (unsigned int**)(&ints));
-                if (err.iErr)
-                {
-                    removeTemporaryVars(envId, tmpvars);
-                    throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
-                }
+                    returnId = wrap<int>(row, col, static_cast<int *>(ints), wrapper, isRef);
+                    tmpvars[++tmpvars[0]] = returnId;
+                    return returnId;
+                case SCI_UINT32 :
+                    err = getMatrixOfUnsignedInteger32(pvApiCtx, addr, &row, &col, (unsigned int**)(&ints));
+                    if (err.iErr)
+                    {
+                        removeTemporaryVars(envId, tmpvars);
+                        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
+                    }
 
-                returnId = wrap<unsigned int>(row, col, static_cast<unsigned int *>(ints), wrapper, isRef);
-                tmpvars[++tmpvars[0]] = returnId;
-                return returnId;
+                    returnId = wrap<unsigned int>(row, col, static_cast<unsigned int *>(ints), wrapper, isRef);
+                    tmpvars[++tmpvars[0]] = returnId;
+                    return returnId;
 
 #ifdef __SCILAB_INT64__
-            case SCI_INT64 :
-                err = getMatrixOfInteger64(pvApiCtx, addr, &row, &col, (long long**)(&ints));
-                if (err.iErr)
-                {
-                    removeTemporaryVars(envId, tmpvars);
-                    throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
-                }
+                case SCI_INT64 :
+                    err = getMatrixOfInteger64(pvApiCtx, addr, &row, &col, (long long**)(&ints));
+                    if (err.iErr)
+                    {
+                        removeTemporaryVars(envId, tmpvars);
+                        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
+                    }
 
-                returnId = wrap<long long>(row, col, static_cast<long long *>(ints), wrapper, isRef);
-                tmpvars[++tmpvars[0]] = returnId;
-                return returnId;
-            case SCI_UINT64 :
-                err = getMatrixOfUnsignedInteger64(pvApiCtx, addr, &row, &col, (unsigned long long**)(&ints));
-                if (err.iErr)
-                {
-                    removeTemporaryVars(envId, tmpvars);
-                    throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
-                }
+                    returnId = wrap<long long>(row, col, static_cast<long long *>(ints), wrapper, isRef);
+                    tmpvars[++tmpvars[0]] = returnId;
+                    return returnId;
+                case SCI_UINT64 :
+                    err = getMatrixOfUnsignedInteger64(pvApiCtx, addr, &row, &col, (unsigned long long**)(&ints));
+                    if (err.iErr)
+                    {
+                        removeTemporaryVars(envId, tmpvars);
+                        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data"));
+                    }
 
-                returnId = wrap<unsigned long long>(row, col, static_cast<unsigned long long *>(ints), wrapper, isRef);
-                tmpvars[++tmpvars[0]] = returnId;
-                return returnId;
+                    returnId = wrap<unsigned long long>(row, col, static_cast<unsigned long long *>(ints), wrapper, isRef);
+                    tmpvars[++tmpvars[0]] = returnId;
+                    return returnId;
 #endif
             }
         }
@@ -686,161 +686,160 @@ namespace org_modules_external_objects
             removeTemporaryVars(envId, tmpvars);
             throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Unable to wrap. Unmanaged datatype ?"));
         }
-        }
     }
+}
 
-    int ScilabObjects::getMListType(int * mlist, void * pvApiCtx)
+int ScilabObjects::getMListType(int * mlist, void * pvApiCtx)
+{
+    char * mlist_type[3];
+    char * mtype = 0;
+    int lengths[3];
+    int rows, cols;
+    int type;
+
+    SciErr err = getVarType(pvApiCtx, mlist, &type);
+    if (err.iErr || type != sci_mlist)
     {
-        char * mlist_type[3];
-        char * mtype = 0;
-        int lengths[3];
-        int rows, cols;
-        int type;
-
-        SciErr err = getVarType(pvApiCtx, mlist, &type);
-        if (err.iErr || type != sci_mlist)
-        {
-            return EXTERNAL_INVALID;
-        }
-
-        err = getMatrixOfStringInList(pvApiCtx, mlist, 1, &rows, &cols, NULL, NULL);
-        if (err.iErr || rows != 1 || cols != 3)
-        {
-            return EXTERNAL_INVALID;
-        }
-
-        err = getMatrixOfStringInList(pvApiCtx, mlist, 1, &rows, &cols, lengths, NULL);
-        if (err.iErr)
-        {
-            return EXTERNAL_INVALID;
-        }
-
-        for (int i = 0; i < 3; i++)
-        {
-            mlist_type[i] = new char[lengths[i] + 1];
-        }
+        return EXTERNAL_INVALID;
+    }
 
-        err = getMatrixOfStringInList(pvApiCtx, mlist, 1, &rows, &cols, lengths, mlist_type);
-        mtype = mlist_type[0];
-        for (int i = 1; i < 3; i++)
-        {
-            delete[] mlist_type[i];
-        }
+    err = getMatrixOfStringInList(pvApiCtx, mlist, 1, &rows, &cols, NULL, NULL);
+    if (err.iErr || rows != 1 || cols != 3)
+    {
+        return EXTERNAL_INVALID;
+    }
 
-        type = EXTERNAL_INVALID;
+    err = getMatrixOfStringInList(pvApiCtx, mlist, 1, &rows, &cols, lengths, NULL);
+    if (err.iErr)
+    {
+        return EXTERNAL_INVALID;
+    }
 
-        if (err.iErr)
-        {
-            return EXTERNAL_INVALID;
-        }
+    for (int i = 0; i < 3; i++)
+    {
+        mlist_type[i] = new char[lengths[i] + 1];
+    }
 
-        if (!std::strcmp("_EObj", mtype))
-        {
-            type = EXTERNAL_OBJECT;
-        }
-        else if (!std::strcmp("_EClass", mtype))
-        {
-            type = EXTERNAL_CLASS;
-        }
-        else if (!std::strcmp("_EVoid", mtype))
-        {
-            type = EXTERNAL_VOID;
-        }
+    err = getMatrixOfStringInList(pvApiCtx, mlist, 1, &rows, &cols, lengths, mlist_type);
+    mtype = mlist_type[0];
+    for (int i = 1; i < 3; i++)
+    {
+        delete[] mlist_type[i];
+    }
 
-        delete[] mtype;
+    type = EXTERNAL_INVALID;
 
-        return type;
+    if (err.iErr)
+    {
+        return EXTERNAL_INVALID;
     }
 
-    bool ScilabObjects::isValidExternal(int * mlist, void * pvApiCtx)
+    if (!std::strcmp("_EObj", mtype))
     {
-        int type = getMListType(mlist, pvApiCtx);
-        return type == EXTERNAL_OBJECT || type == EXTERNAL_CLASS || type == EXTERNAL_VOID;
+        type = EXTERNAL_OBJECT;
     }
-
-    bool ScilabObjects::isExternalObj(int * mlist, void * pvApiCtx)
+    else if (!std::strcmp("_EClass", mtype))
     {
-        return getMListType(mlist, pvApiCtx) == EXTERNAL_OBJECT;
+        type = EXTERNAL_CLASS;
     }
-
-    bool ScilabObjects::isExternalClass(int * mlist, void * pvApiCtx)
+    else if (!std::strcmp("_EVoid", mtype))
     {
-        return getMListType(mlist, pvApiCtx) == EXTERNAL_CLASS;
+        type = EXTERNAL_VOID;
     }
 
-    bool ScilabObjects::isExternalObjOrClass(int * mlist, void * pvApiCtx)
+    delete[] mtype;
+
+    return type;
+}
+
+bool ScilabObjects::isValidExternal(int * mlist, void * pvApiCtx)
+{
+    int type = getMListType(mlist, pvApiCtx);
+    return type == EXTERNAL_OBJECT || type == EXTERNAL_CLASS || type == EXTERNAL_VOID;
+}
+
+bool ScilabObjects::isExternalObj(int * mlist, void * pvApiCtx)
+{
+    return getMListType(mlist, pvApiCtx) == EXTERNAL_OBJECT;
+}
+
+bool ScilabObjects::isExternalClass(int * mlist, void * pvApiCtx)
+{
+    return getMListType(mlist, pvApiCtx) == EXTERNAL_CLASS;
+}
+
+bool ScilabObjects::isExternalObjOrClass(int * mlist, void * pvApiCtx)
+{
+    int type = getMListType(mlist, pvApiCtx);
+    return type == EXTERNAL_OBJECT || type == EXTERNAL_CLASS;
+}
+
+bool ScilabObjects::isExternalVoid(int * mlist, void * pvApiCtx)
+{
+    return getMListType(mlist, pvApiCtx) == EXTERNAL_VOID;
+}
+
+char * ScilabObjects::getSingleString(int pos, void * pvApiCtx)
+{
+    SciErr err;
+    int * addr = 0;
+    char * str = 0;
+
+    err = getVarAddressFromPosition(pvApiCtx, pos, &addr);
+    if (err.iErr)
     {
-        int type = getMListType(mlist, pvApiCtx);
-        return type == EXTERNAL_OBJECT || type == EXTERNAL_CLASS;
+        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid String"));
     }
 
-    bool ScilabObjects::isExternalVoid(int * mlist, void * pvApiCtx)
+    if (!isStringType(pvApiCtx, addr))
     {
-        return getMListType(mlist, pvApiCtx) == EXTERNAL_VOID;
+        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("A single string expected"));
     }
 
-    char * ScilabObjects::getSingleString(int pos, void * pvApiCtx)
+    if (!isScalar(pvApiCtx, addr))
     {
-        SciErr err;
-        int * addr = 0;
-        char * str = 0;
-
-        err = getVarAddressFromPosition(pvApiCtx, pos, &addr);
-        if (err.iErr)
-        {
-            throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid String"));
-        }
+        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("A single String expected"));
+    }
 
-        if (!isStringType(pvApiCtx, addr))
-        {
-            throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("A single string expected"));
-        }
+    if (getAllocatedSingleString(pvApiCtx, addr, &str))
+    {
+        throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid String"));
+    }
 
-        if (!isScalar(pvApiCtx, addr))
-        {
-            throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("A single String expected"));
-        }
+    return str;
+}
 
-        if (getAllocatedSingleString(pvApiCtx, addr, &str))
-        {
-            throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid String"));
-        }
+int ScilabObjects::isPositiveIntegerAtAddress(int * addr, void * pvApiCtx)
+{
+    SciErr err;
+    int typ = 0, row, col, prec;
 
-        return str;
+    err = getVarDimension(pvApiCtx, addr, &row, &col);
+    if (err.iErr)
+    {
+        return -1;
     }
 
-    int ScilabObjects::isPositiveIntegerAtAddress(int * addr, void * pvApiCtx)
+    if (row != 1 || col != 1)
     {
-        SciErr err;
-        int typ = 0, row, col, prec;
-        int * id = 0;
-
-        err = getVarDimension(pvApiCtx, addr, &row, &col);
-        if (err.iErr)
-        {
-            return -1;
-        }
+        return -1;
+    }
 
-        if (row != 1 || col != 1)
-        {
-            return -1;
-        }
+    err = getVarType(pvApiCtx, addr, &typ);
+    if (err.iErr)
+    {
+        return -1;
+    }
 
-        err = getVarType(pvApiCtx, addr, &typ);
+    if (typ == sci_ints)
+    {
+        err = getMatrixOfIntegerPrecision(pvApiCtx, addr, &prec);
         if (err.iErr)
         {
             return -1;
         }
-
-        if (typ == sci_ints)
+        switch (prec)
         {
-            err = getMatrixOfIntegerPrecision(pvApiCtx, addr, &prec);
-            if (err.iErr)
-            {
-                return -1;
-            }
-            switch (prec)
-            {
             case SCI_INT8:
             {
                 char * cvalue = 0;
@@ -933,29 +932,29 @@ namespace org_modules_external_objects
 #endif
             default:
                 return -1;
-            }
         }
-        else if (typ == sci_matrix)
-        {
-            double * dvalue = 0;
-
-            if (isVarComplex(pvApiCtx, addr))
-            {
-                return -1;
-            }
+    }
+    else if (typ == sci_matrix)
+    {
+        double * dvalue = 0;
 
-            err = getMatrixOfDouble(pvApiCtx, addr, &row, &col, &dvalue);
-            if (err.iErr)
-            {
-                return -1;
-            }
+        if (isVarComplex(pvApiCtx, addr))
+        {
+            return -1;
+        }
 
-            if (*dvalue - (double)(int)(*dvalue) == 0.0)
-            {
-                return (int)(*dvalue);
-            }
+        err = getMatrixOfDouble(pvApiCtx, addr, &row, &col, &dvalue);
+        if (err.iErr)
+        {
+            return -1;
         }
 
-        return -1;
+        if (*dvalue - (double)(int)(*dvalue) == 0.0)
+        {
+            return (int)(*dvalue);
+        }
     }
+
+    return -1;
+}
 }
index 220e795..f8e4f74 100644 (file)
@@ -22,7 +22,6 @@ int ScilabGateway::array(char * fname, const int envId, void * pvApiCtx)
     int * addr = 0;
     char * className = 0;
     int * args = 0;
-    char * errmsg = 0;
 
     ScilabAbstractEnvironment & env = ScilabEnvironments::getEnvironment(envId);
 
index 45ad0c2..ccb0d5f 100644 (file)
@@ -24,13 +24,11 @@ int ScilabGateway::cast(char * fname, const int envId, void * pvApiCtx)
     int row = 0, col = 0;
     int * id = 0;
     char * objName = 0;
-    char * errmsg = 0;
     int ret = 0;
 
     CheckInputArgument(pvApiCtx, 2, 2);
 
     ScilabAbstractEnvironment & env = ScilabEnvironments::getEnvironment(envId);
-    OptionsHelper & helper = env.getOptionsHelper();
     ScilabGatewayOptions & options = env.getGatewayOptions();
     OptionsHelper::setCopyOccured(false);
     ScilabObjects::initialization(env, pvApiCtx);
index cb546f5..9829688 100644 (file)
@@ -25,8 +25,6 @@ int ScilabGateway::doubleExclam_invoke(char * fname, const int envId, void * pvA
     int * addr = 0;
     int * tmpvar = 0;
     int * args = 0;
-    int typ = 0;
-    int * child = 0;
     int eId = OptionsHelper::getEnvId();
     int ret = 0;
     int * sret = 0;
index d20480b..4e174ba 100644 (file)
@@ -18,8 +18,6 @@ namespace org_modules_external_objects
 int ScilabGateway::getEnvId(char * fname, const int envId, void * pvApiCtx)
 {
     SciErr sciErr;
-    int * addr = 0;
-    int val = 0;
 
     CheckInputArgument(pvApiCtx, 0, 0);
     CheckOutputArgument(pvApiCtx, 1, 1);
index b03afaa..d932035 100644 (file)
@@ -18,8 +18,6 @@ namespace org_modules_external_objects
 int ScilabGateway::getEnvironmentName(char * fname, const int envId, void * pvApiCtx)
 {
     SciErr err;
-    int row = 0;
-    int col = 0;
     int * addr = 0;
     int eId = 0;
     std::string envName;
index f8e8fec..a1000c4 100644 (file)
@@ -20,7 +20,6 @@ int ScilabGateway::getFields(char * fname, const int envId, void * pvApiCtx)
     SciErr err;
     int * addr = 0;
     int tmpvar[2] = {0, 0};
-    int row = 0, col = 0;
     int idObj = 0;
     ScilabStringStackAllocator * allocator = 0;
 
index 7ac509e..4915094 100644 (file)
@@ -20,7 +20,6 @@ int ScilabGateway::getMethods(char * fname, const int envId, void * pvApiCtx)
     SciErr err;
     int * addr = 0;
     int tmpvar[2] = {0, 0};
-    int row = 0, col = 0;
     int idObj = 0;
 
     CheckInputArgument(pvApiCtx, 1, 1);
index 96d72b9..351195e 100644 (file)
@@ -17,8 +17,6 @@ namespace org_modules_external_objects
 
 int ScilabGateway::getNamedVariable(char * fname, const int envId, void * pvApiCtx)
 {
-    SciErr err;
-    int * addr = 0;
     char * varName = 0;
     int idObj;
 
index 27b1a4f..cc87e37 100644 (file)
@@ -20,7 +20,6 @@ int ScilabGateway::getRepresentation(char * fname, const int envId, void * pvApi
     SciErr err;
     int * addr = 0;
     int tmpvar[2] = {0, 0};
-    int row = 0, col = 0;
     int idObj = 0;
 
     CheckInputArgument(pvApiCtx, 1, 1);
index 9150b7d..0ab2aae 100644 (file)
@@ -25,7 +25,6 @@ int ScilabGateway::getsetOptions(char * fname, const int envId, ScilabAbstractOp
     CheckOutputArgument(pvApiCtx, 1, 1);
 
     ScilabAbstractEnvironment & env = ScilabEnvironments::getEnvironment(envId);
-    OptionsHelper & helper = env.getOptionsHelper();
     ScilabGatewayOptions & options = env.getGatewayOptions();
     OptionsHelper::setCopyOccured(false);
     ScilabObjects::initialization(env, pvApiCtx);
index ff393f1..fea4cde 100644 (file)
@@ -33,7 +33,6 @@ int sci_xmlAppend(char *fname, unsigned long fname_len)
     XMLElement *elem = 0;
     SciErr err;
     int *addr = 0;
-    char *name = 0;
 
     CheckLhs(1, 1);
     CheckRhs(2, 2);