/*--------------------------------------------------------------------------*/ int isXMLObjects(const int * types, int nb, int *mlist, void *pvApiCtx) { const int type = getMListType(mlist, pvApiCtx); int i = 0; for (; i < nb; i++) { if (type == types[i]) { return i; } } return -1; }
/*--------------------------------------------------------------------------*/ int isXMLValid(int *mlist, void *pvApiCtx) { return getMListType(mlist, pvApiCtx) == XMLVALID; }
/*--------------------------------------------------------------------------*/ int isXMLObject(int *mlist, void *pvApiCtx) { const int type = getMListType(mlist, pvApiCtx); return type == XMLDOCUMENT || type == XMLELEMENT || type == XMLATTRIBUTE || type == XMLNAMESPACE || type == XMLLIST || type == XMLNOTHANDLED || type == XMLSET || type == XMLVALID; }
/*--------------------------------------------------------------------------*/ int isXMLNotHandled(int *mlist, void *pvApiCtx) { return getMListType(mlist, pvApiCtx) == XMLNOTHANDLED; }
/*--------------------------------------------------------------------------*/ int isXMLSet(int *mlist, void *pvApiCtx) { return getMListType(mlist, pvApiCtx) == XMLSET; }
/*--------------------------------------------------------------------------*/ int isXMLAttr(int *mlist, void *pvApiCtx) { return getMListType(mlist, pvApiCtx) == XMLATTRIBUTE; }
/*--------------------------------------------------------------------------*/ int isXMLNs(int *mlist, void *pvApiCtx) { return getMListType(mlist, pvApiCtx) == XMLNAMESPACE; }
/*--------------------------------------------------------------------------*/ int isXMLDoc(int *mlist, void *pvApiCtx) { return getMListType(mlist, pvApiCtx) == XMLDOCUMENT; }
/*--------------------------------------------------------------------------*/ int isXMLElem(int *mlist, void *pvApiCtx) { return getMListType(mlist, pvApiCtx) == XMLELEMENT; }
bool ScilabObjects::isExternalVoid(int * mlist, void * pvApiCtx) { return getMListType(mlist, pvApiCtx) == EXTERNAL_VOID; }
bool ScilabObjects::isExternalObjOrClass(int * mlist, void * pvApiCtx) { int type = getMListType(mlist, pvApiCtx); return type == EXTERNAL_OBJECT || type == EXTERNAL_CLASS; }
bool ScilabObjects::isExternalClass(int * mlist, void * pvApiCtx) { return getMListType(mlist, pvApiCtx) == EXTERNAL_CLASS; }
bool ScilabObjects::isExternalObj(int * mlist, void * pvApiCtx) { return getMListType(mlist, pvApiCtx) == EXTERNAL_OBJECT; }
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(); err = getVarType(pvApiCtx, addr, &typ); if (err.iErr) { removeTemporaryVars(envId, tmpvars); throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data")); } if (isClass && typ != sci_mlist) { removeTemporaryVars(envId, tmpvars); throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("External Class expected")); } switch (typ) { case sci_matrix : { double * mat = 0; if (isVarComplex(pvApiCtx, addr)) { double * imag = 0; err = getComplexMatrixOfDouble(pvApiCtx, addr, &row, &col, &mat, &imag); if (err.iErr) { removeTemporaryVars(envId, tmpvars); throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data")); } returnId = wrap(row, col, mat, imag, wrapper, isRef); } else { err = getMatrixOfDouble(pvApiCtx, addr, &row, &col, &mat); if (err.iErr) { removeTemporaryVars(envId, tmpvars); throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data")); } returnId = wrap<double>(row, col, mat, wrapper, isRef); } tmpvars[++tmpvars[0]] = returnId; return returnId; } case sci_ints : { int prec = 0; void * ints = 0; err = getMatrixOfIntegerPrecision(pvApiCtx, addr, &prec); if (err.iErr) { removeTemporaryVars(envId, tmpvars); throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data")); } 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")); } 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<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<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; #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")); } 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; #endif } } case sci_strings : { char ** matS = NULL; if (getAllocatedMatrixOfString(pvApiCtx, addr, &row, &col, &matS)) { removeTemporaryVars(envId, tmpvars); throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data")); } returnId = wrap<char *>(row, col, matS, wrapper, isRef); freeAllocatedMatrixOfString(row, col, matS); tmpvars[++tmpvars[0]] = returnId; return returnId; } case sci_boolean : { int * matB; err = getMatrixOfBoolean(pvApiCtx, addr, &row, &col, &matB); if (err.iErr) { removeTemporaryVars(envId, tmpvars); throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data")); } returnId = wrapBool(row, col, matB, wrapper, isRef); tmpvars[++tmpvars[0]] = returnId; return returnId; } case sci_mlist : { int * id = 0; int type = getMListType(addr, pvApiCtx); int eId = getEnvironmentId(addr, pvApiCtx); if (eId != envId) { removeTemporaryVars(envId, tmpvars); throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Incompatible External Objects")); } if (isClass) { if (type == EXTERNAL_CLASS) { err = getMatrixOfInteger32InList(pvApiCtx, addr, EXTERNAL_OBJ_ID_POSITION, &row, &col, &id); if (err.iErr) { removeTemporaryVars(envId, tmpvars); throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data")); } return *id; } else { removeTemporaryVars(envId, tmpvars); throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("External Class expected")); } } if (type == EXTERNAL_OBJECT || type == EXTERNAL_CLASS) { err = getMatrixOfInteger32InList(pvApiCtx, addr, EXTERNAL_OBJ_ID_POSITION, &row, &col, &id); if (err.iErr) { removeTemporaryVars(envId, tmpvars); throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Invalid variable: cannot retrieve the data")); } return *id; } else if (type == EXTERNAL_VOID) { return -1; } else { removeTemporaryVars(envId, tmpvars); throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("External object expected")); } break; } default : { removeTemporaryVars(envId, tmpvars); throw ScilabAbstractEnvironmentException(__LINE__, __FILE__, gettext("Unable to wrap. Unmanaged datatype ?")); } } }