/* ========================================================================== */ int sci_bug_11106(char *fname) { int* piAddr = NULL; char pstRet[64]; getVarAddressFromPosition(pvApiCtx, 1, &piAddr); if (isStringType(pvApiCtx, piAddr)) { //named check char* pstVar = NULL; getAllocatedSingleString(pvApiCtx, piAddr, &pstVar); if (isNamedListType(pvApiCtx, pstVar)) { sprintf(pstRet, "%s", "isNamedList"); } else if (isNamedTListType(pvApiCtx, pstVar)) { sprintf(pstRet, "%s", "isNamedTList"); } else if (isNamedMListType(pvApiCtx, pstVar)) { sprintf(pstRet, "%s", "isNamedMList"); } else { sprintf(pstRet, "%s", "unmanaged named type"); } FREE(pstVar); } else { if (isListType(pvApiCtx, piAddr)) { sprintf(pstRet, "%s", "isList"); } else if (isTListType(pvApiCtx, piAddr)) { sprintf(pstRet, "%s", "isTList"); } else if (isMListType(pvApiCtx, piAddr)) { sprintf(pstRet, "%s", "isMList"); } else { sprintf(pstRet, "%s", "unmanaged type"); } } createSingleString(pvApiCtx, Rhs + 1, pstRet); LhsVar(1) = Rhs + 1; return 0; }
/*-------------------------------------------------------------------------- * sciset(choice-name,x1,x2,x3,x4,x5) * or xset() *-----------------------------------------------------------*/ int sci_set(char *fname, void *pvApiCtx) { SciErr sciErr; int i = 0; int* piAddr1 = NULL; int isMatrixOfString = 0; char* pstNewProperty = NULL; unsigned long hdl; int iObjUID = 0; int iType = 0; int* piType = &iType; int iSetProperty = 0; int iRhs = nbInputArgument(pvApiCtx); sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr1); if (sciErr.iErr) { Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1); return 1; } if (isMListType(pvApiCtx, piAddr1) || isTListType(pvApiCtx, piAddr1)) { OverLoad(1); return 0; } CheckInputArgumentAtLeast(pvApiCtx, 2); CheckOutputArgument(pvApiCtx, 0, 1); if (isDoubleType(pvApiCtx, piAddr1)) /* tclsci handle */ { /* call "set" for tcl/tk see tclsci/sci_gateway/c/sci_set.c */ OverLoad(1); return 0; } if (iRhs == 2) { #define NB_PROPERTIES_SUPPORTED 7 /* No object specified */ /* ONLY supported properties are */ /* 'current_entity' */ /* 'hdl' */ /* 'current_figure' */ /* 'current_axes' */ /* 'default_values' */ /* 'figure_style' for compatibility but do nothing */ /* others values must return a error */ char *propertiesSupported[NB_PROPERTIES_SUPPORTED] = { "current_entity", "hdl", "current_figure", "current_axes", "figure_style", "default_values", "auto_clear" }; int iPropertyFound = 0; int* piAddr2 = NULL; int iType2 = 0; int iRows2 = 0; int iCols2 = 0; void* pvData = NULL; char* pstProperty = NULL; if (isStringType(pvApiCtx, piAddr1) == 0) { Scierror(999, _("%s: Wrong size for input argument #%d: A single string expected.\n"), fname, 1); return 0; } if (getAllocatedSingleString(pvApiCtx, piAddr1, &pstProperty)) { Scierror(999, _("%s: Wrong size for input argument #%d: A single string expected.\n"), fname, 1); return 1; } sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddr2); if (sciErr.iErr) { freeAllocatedSingleString(pstProperty); Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2); return 1; } sciErr = getVarType(pvApiCtx, piAddr2, &iType2); if (sciErr.iErr) { freeAllocatedSingleString(pstProperty); Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2); return 1; } switch (iType2) { case sci_matrix: sciErr = getMatrixOfDouble(pvApiCtx, piAddr2, &iRows2, &iCols2, (double**)&pvData); if (sciErr.iErr) { freeAllocatedSingleString(pstProperty); printError(&sciErr, 0); Scierror(999, _("%s: Wrong type for input argument #%d: Matrix expected.\n"), fname, 2); return sciErr.iErr; } break; case sci_handles : sciErr = getMatrixOfHandle(pvApiCtx, piAddr2, &iRows2, &iCols2, (long long**)&pvData); if (sciErr.iErr) { freeAllocatedSingleString(pstProperty); printError(&sciErr, 0); Scierror(999, _("%s: Wrong type for input argument #%d: Matrix of handle expected.\n"), fname, 3); return 1; } break; case sci_strings : if (strcmp(pstProperty, "tics_labels") == 0 || strcmp(pstProperty, "auto_ticks") == 0 || strcmp(pstProperty, "axes_visible") == 0 || strcmp(pstProperty, "axes_reverse") == 0 || strcmp(pstProperty, "text") == 0 || strcmp(pstProperty, "ticks_format") == 0) { isMatrixOfString = 1; if (getAllocatedMatrixOfString(pvApiCtx, piAddr2, &iRows2, &iCols2, (char***)&pvData)) { freeAllocatedSingleString(pstProperty); Scierror(999, _("%s: Wrong size for input argument #%d: A matrix of string expected.\n"), fname, 2); return 1; } } else { if (getAllocatedSingleString(pvApiCtx, piAddr2, (char**)&pvData)) { freeAllocatedSingleString(pstProperty); Scierror(999, _("%s: Wrong size for input argument #%d: A single string expected.\n"), fname, 2); return 1; } iRows2 = (int)strlen((char*)pvData); iCols2 = 1; isMatrixOfString = 0; } break; } for (i = 0; i < NB_PROPERTIES_SUPPORTED; i++) { if (strcmp(propertiesSupported[i], pstProperty) == 0) { iPropertyFound = 1; } } if (iPropertyFound) { callSetProperty(pvApiCtx, 0, pvData, iType2, iRows2, iCols2, pstProperty); if (iType2 == sci_strings) { //free allocated data if (isMatrixOfString == 1) { freeAllocatedMatrixOfString(iRows2, iCols2, (char**)pvData); } else { freeAllocatedSingleString((char*)pvData); } } } else { freeAllocatedSingleString(pstProperty); Scierror(999, _("%s: Wrong value for input argument #%d: a valid property expected.\n"), fname, 1); if (iType2 == sci_strings) { if (isMatrixOfString == 1) { freeAllocatedMatrixOfString(iRows2, iCols2, (char**)pvData); } else { freeAllocatedSingleString((char*)pvData); } } return 0; } freeAllocatedSingleString(pstProperty); AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 0; } if (iRhs % 2 != 1) { Scierror(999, _("%s: Wrong number of input argument(s) : an odd number is expected.\n"), fname); return 0; } /* after the call to sciSet get the status : 0 <=> OK, */ /* -1 <=> Error, */ /* 1 <=> nothing done */ /* set or create a graphic window */ if (isHandleType(pvApiCtx, piAddr1) == 0 && isStringType(pvApiCtx, piAddr1) == 0) { Scierror(999, _("%s: Wrong type for input argument #%d: A handle or a string expected.\n"), fname, 1); return 0; } if (isStringType(pvApiCtx, piAddr1)) { char* pstPath = NULL; if (getAllocatedSingleString(pvApiCtx, piAddr1, &pstPath)) { Scierror(999, _("%s: Wrong size for input argument #%d: A single string expected.\n"), fname, 1); return 1; } iObjUID = search_path(pstPath); if (iObjUID == 0) { Scierror(999, _("%s: Unable to find handle for path %s.\n"), fname, pstPath); freeAllocatedSingleString(pstPath); return 1; } } else { //matrix of handle are managed by a %h_set if (isScalar(pvApiCtx, piAddr1) == FALSE) { OverLoad(1); return 0; } if (getScalarHandle(pvApiCtx, piAddr1, (long long*)&hdl)) { Scierror(999, _("%s: Wrong size for input argument #%d: A single handle expected.\n"), fname, 1); return 1; } iObjUID = getObjectFromHandle(hdl); } if (iObjUID == 0) { Scierror(999, _("%s: The handle is not or no more valid.\n"), fname); return 0; } for (i = 1 ; i < iRhs ; i = i + 2) { int setStatus = 0; int* piAddr2 = NULL; int* piAddr3 = NULL; int iPos = i + 1; int isData = 0; int iRows3 = 0; int iCols3 = 0; int iType3 = 0; void* pvData = NULL; char* pstProperty = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, iPos, &piAddr2); if (sciErr.iErr) { Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, iPos); return 1; } if (isStringType(pvApiCtx, piAddr2) == 0) { Scierror(999, _("%s: Wrong type for input argument #%d: string expected.\n"), fname, iPos); return 0; } if (getAllocatedSingleString(pvApiCtx, piAddr2, &pstProperty)) { Scierror(999, _("%s: Wrong size for input argument #%d: A single string expected.\n"), fname, iPos); return 1; } sciErr = getVarAddressFromPosition(pvApiCtx, iPos + 1, &piAddr3); if (sciErr.iErr) { Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, iPos + 1); return 1; } if ((pstProperty[0] == 'd' || pstProperty[0] == 'D') && stricmp("data", pstProperty) == 0) { //send to datamodel isData = 1; } if (stricmp(pstProperty, "user_data") == 0 || stricmp(pstProperty, "userdata") == 0 || stricmp(pstProperty, "display_function_data") == 0 || stricmp(pstProperty, "data") == 0) { /* in this case set_user_data_property * directly uses the third position in the stack * to get the variable which is to be set in * the user_data property (any data type is allowed) S. Steer */ pvData = (void*)piAddr3; /*position in the stack */ iRows3 = -1; /*unused */ iCols3 = -1; /*unused */ iType3 = -1; } else { sciErr = getVarType(pvApiCtx, piAddr3, &iType3); if (sciErr.iErr) { freeAllocatedSingleString(pstProperty); Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, iPos + 1); return 1; } switch (iType3) { case sci_matrix : sciErr = getMatrixOfDouble(pvApiCtx, piAddr3, &iRows3, &iCols3, (double**)&pvData); break; case sci_boolean : sciErr = getMatrixOfBoolean(pvApiCtx, piAddr3, &iRows3, &iCols3, (int**)&pvData); break; case sci_handles : sciErr = getMatrixOfHandle(pvApiCtx, piAddr3, &iRows3, &iCols3, (long long**)&pvData); break; case sci_strings : if (strcmp(pstProperty, "tics_labels") != 0 && strcmp(pstProperty, "auto_ticks") != 0 && strcmp(pstProperty, "tight_limits") != 0 && strcmp(pstProperty, "axes_visible") != 0 && strcmp(pstProperty, "axes_reverse") != 0 && strcmp(pstProperty, "text") != 0 && stricmp(pstProperty, "string") != 0 && stricmp(pstProperty, "tooltipstring") != 0 && stricmp(pstProperty, "ticks_format") != 0) /* Added for uicontrols */ { if (isScalar(pvApiCtx, piAddr3) == 0) { freeAllocatedSingleString(pstProperty); Scierror(999, _("%s: Wrong size for input argument #%d: A single string expected.\n"), fname, iPos + 1); return 1; } if (getAllocatedSingleString(pvApiCtx, piAddr3, (char**)&pvData)) { freeAllocatedSingleString(pstProperty); Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, iPos + 1); return 1; } iRows3 = (int)strlen((char*)pvData); iCols3 = 1; isMatrixOfString = 0; } else { isMatrixOfString = 1; getAllocatedMatrixOfString(pvApiCtx, piAddr3, &iRows3, &iCols3, (char***)&pvData); } break; case sci_list : iCols3 = 1; sciErr = getListItemNumber(pvApiCtx, piAddr3, &iRows3); pvData = (void*)piAddr3; /* In this case l3 is the list position in stack */ break; default : pvData = (void*)piAddr3; /* In this case l3 is the list position in stack */ break; } if (sciErr.iErr) { freeAllocatedSingleString(pstProperty); Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, iPos + 1); return 1; } } setStatus = callSetProperty(pvApiCtx, iObjUID, pvData, iType3, iRows3, iCols3, pstProperty); if (iType3 == sci_strings) { //free allacted data if (isMatrixOfString == 1) { freeAllocatedMatrixOfString(iRows3, iCols3, (char**)pvData); } else { freeAllocatedSingleString((char*)pvData); } } freeAllocatedSingleString(pstProperty); } AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); return 0; }
/*-------------------------------------------------------------------------- * sciset(choice-name,x1,x2,x3,x4,x5) * or xset() *-----------------------------------------------------------*/ int sci_set(char *fname, unsigned long fname_len) { SciErr sciErr; int* piAddr1 = NULL; int* piAddr2 = NULL; int* piAddr3 = NULL; int lw = 0; int isMatrixOfString = 0; char* pstProperty = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr1); if (sciErr.iErr) { //error return 1; } if (isMListType(pvApiCtx, piAddr1) || isTListType(pvApiCtx, piAddr1)) { OverLoad(1); return 0; } CheckRhs(2, 3); CheckLhs(0, 1); if (isDoubleType(pvApiCtx, piAddr1)) /* tclsci handle */ { /* call "set" for tcl/tk see tclsci/sci_gateway/c/sci_set.c */ OverLoad(1); return 0; } else /* others types */ { int iRows1 = 0, iCols1 = 0; int iRows2 = 0, iCols2 = 0; int iRows3 = 0, iCols3 = 0; void* _pvData = NULL; unsigned long hdl; char *pobjUID = NULL; int iType1 = 0; int valueType = 0; /* type of the rhs */ int setStatus = 0; /* after the call to sciSet get the status : 0 <=> OK, */ /* -1 <=> Error, */ /* 1 <=> nothing done */ /* set or create a graphic window */ sciErr = getVarType(pvApiCtx, piAddr1, &iType1); if (sciErr.iErr) { //error return 1; } switch (iType1) { case sci_handles: /* first is a scalar argument so it's a gset(hdl,"command",[param]) */ /* F.Leray; INFO: case 9 is considered for a matrix of graphic handles */ CheckRhs(3, 3); if (isScalar(pvApiCtx, piAddr1) == FALSE) { OverLoad(1); return 0; } getScalarHandle(pvApiCtx, piAddr1, (long long*)&hdl); pobjUID = (char*)getObjectFromHandle(hdl); getVarAddressFromPosition(pvApiCtx, 2, &piAddr2); getAllocatedSingleString(pvApiCtx, piAddr2, &pstProperty); valueType = getInputArgumentType(pvApiCtx, 3); getVarAddressFromPosition(pvApiCtx, 3, &piAddr3); if ((strcmp(pstProperty, "user_data") == 0) || (stricmp(pstProperty, "userdata") == 0)) { /* in this case set_user_data_property * directly uses the third position in the stack * to get the variable which is to be set in * the user_data property (any data type is allowed) S. Steer */ _pvData = (void*)piAddr3; /*position in the stack */ iRows3 = -1; /*unused */ iCols3 = -1; /*unused */ valueType = -1; } else if (valueType == sci_matrix) { getMatrixOfDouble(pvApiCtx, piAddr3, &iRows3, &iCols3, (double**)&_pvData); } else if (valueType == sci_boolean) { getMatrixOfBoolean(pvApiCtx, piAddr3, &iRows3, &iCols3, (int**)&_pvData); } else if (valueType == sci_handles) { getMatrixOfHandle(pvApiCtx, piAddr3, &iRows3, &iCols3, (long long**)&_pvData); } else if (valueType == sci_strings) { if ( strcmp(pstProperty, "tics_labels") != 0 && strcmp(pstProperty, "auto_ticks") != 0 && strcmp(pstProperty, "axes_visible") != 0 && strcmp(pstProperty, "axes_reverse") != 0 && strcmp(pstProperty, "text") != 0 && stricmp(pstProperty, "string") != 0 && stricmp(pstProperty, "tooltipstring") != 0) /* Added for uicontrols */ { getAllocatedSingleString(pvApiCtx, piAddr3, (char**)&_pvData); iRows3 = (int)strlen((char*)_pvData); iCols3 = 1; } else { isMatrixOfString = 1; getAllocatedMatrixOfString(pvApiCtx, piAddr3, &iRows3, &iCols3, (char***)&_pvData); } } else if (valueType == sci_list) /* Added for callbacks */ { iCols3 = 1; getListItemNumber(pvApiCtx, piAddr3, &iRows3); _pvData = (void*)piAddr3; /* In this case l3 is the list position in stack */ } break; case sci_strings: /* first is a string argument so it's a set("command",[param]) */ CheckRhs(2, 2); getAllocatedSingleString(pvApiCtx, piAddr1, &pstProperty); hdl = 0; pobjUID = NULL; valueType = getInputArgumentType(pvApiCtx, 2); getVarAddressFromPosition(pvApiCtx, 2, &piAddr2); if (valueType == sci_matrix) { getMatrixOfDouble(pvApiCtx, piAddr2, &iRows3, &iCols3, (double**)&_pvData); } else if (valueType == sci_handles) { getMatrixOfHandle(pvApiCtx, piAddr2, &iRows3, &iCols3, (long long**)&_pvData); } else if (valueType == sci_strings) { if (strcmp(pstProperty, "tics_labels") == 0 || strcmp(pstProperty, "auto_ticks") == 0 || strcmp(pstProperty, "axes_visible") == 0 || strcmp(pstProperty, "axes_reverse") == 0 || strcmp(pstProperty, "text") == 0) { isMatrixOfString = 1; getAllocatedMatrixOfString(pvApiCtx, piAddr2, &iRows3, &iCols3, (char***)&_pvData); } else { getAllocatedSingleString(pvApiCtx, piAddr2, (char**)&_pvData); iRows3 = (int)strlen((char*)_pvData); iCols3 = 1; } } break; default: Scierror(999, _("%s: Wrong type for input argument #%d: String or handle expected.\n"), fname, 1); return 0; break; } if (hdl != 0) { pobjUID = (char*)getObjectFromHandle(hdl); if (pobjUID == NULL) { Scierror(999, _("%s: The handle is not or no more valid.\n"), fname); return 0; } // Only set the property whitout doing anythig else. //static int sciSet(void* _pvCtx, char *pobjUID, char *marker, void* value, int valueType, int *numrow, int *numcol) setStatus = callSetProperty(pvApiCtx, pobjUID, _pvData, valueType, iRows3, iCols3, pstProperty); if (valueType == sci_strings) { //free allacted data if (isMatrixOfString == 1) { freeAllocatedMatrixOfString(iRows3, iCols3, (char**)_pvData); } else { freeAllocatedSingleString((char*)_pvData); } } } else { #define NB_PROPERTIES_SUPPORTED 7 /* No object specified */ /* ONLY supported properties are */ /* 'current_entity' */ /* 'hdl' */ /* 'current_figure' */ /* 'current_axes' */ /* 'default_values' */ /* 'figure_style' for compatibility but do nothing */ /* others values must return a error */ char *propertiesSupported[NB_PROPERTIES_SUPPORTED] = { "current_entity", "hdl", "current_figure", "current_axes", "figure_style", "default_values", "auto_clear" }; int i = 0; int iPropertyFound = 0; for (i = 0; i < NB_PROPERTIES_SUPPORTED; i++) { if (strcmp(propertiesSupported[i], pstProperty) == 0) { iPropertyFound = 1; } } if (iPropertyFound) { // we do nothing with "figure_style" "new" (to remove in 5.4) int bDoSet = ((isMatrixOfString) && (strcmp(pstProperty, "figure_style") == 0) && (strcmp(((char**)_pvData)[0], "new") == 0)) != 1; if (bDoSet) { setStatus = callSetProperty(pvApiCtx, NULL, _pvData, valueType, iRows3, iCols3, pstProperty); if (valueType == sci_strings) { //free allocated data if (isMatrixOfString == 1) { freeAllocatedMatrixOfString(iRows3, iCols3, (char**)_pvData); } else { freeAllocatedSingleString((char*)_pvData); } } } } else { Scierror(999, _("%s: Wrong value for input argument #%d: a valid property expected.\n"), fname, 1); if (isMatrixOfString) { freeArrayOfString((char **)_pvData, iRows3 * iCols3); } return 0; } } AssignOutputVariable(pvApiCtx, 1) = 0; ReturnArguments(pvApiCtx); } return 0; }
/*--------------------------------------------------------------------------*/ int sci_get(char *fname, void *pvApiCtx) { SciErr sciErr; int* piAddrl1 = NULL; long long* l1 = NULL; int* piAddrl2 = NULL; char* l2 = NULL; int m1 = 0, n1 = 0; long hdl = 0; int lw = 0; int iObjUID = 0; int status = SET_PROPERTY_ERROR; CheckInputArgument(pvApiCtx, 1, 2); CheckOutputArgument(pvApiCtx, 0, 1); sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrl1); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } if (isMListType(pvApiCtx, piAddrl1) || isTListType(pvApiCtx, piAddrl1)) { OverLoad(1); return 0; } /* * The first input argument can be an ID or a marker (in this case, get returns the value of the current object */ switch (getInputArgumentType(pvApiCtx, 1)) { case sci_matrix: //console handle { double dbll1 = 0; if (isScalar(pvApiCtx, piAddrl1) == 0) { Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1); return 1; } // Retrieve a matrix of double at position 1. if (getScalarDouble(pvApiCtx, piAddrl1, &dbll1)) { Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1); return 1; } if ((int)dbll1 == 0) /* Console property */ { int* piAddrstkAdr = NULL; char *stkAdr = NULL; if (nbInputArgument(pvApiCtx) == 1) { if (sciReturnHandle(getHandle(getConsoleIdentifier())) != 0) /* Get Console handle */ { ReturnArguments(pvApiCtx); return 0; } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; ReturnArguments(pvApiCtx); return 0; } CheckInputArgument(pvApiCtx, 2, 2); sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrstkAdr); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of string at position 2. if (getAllocatedSingleString(pvApiCtx, piAddrstkAdr, &stkAdr)) { Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 2); return 1; } if (GetScreenProperty(pvApiCtx, stkAdr) != SET_PROPERTY_SUCCEED) { Scierror(999, _("%s: Could not read property '%s' for console object.\n"), "get", stkAdr[0]); freeAllocatedSingleString(stkAdr); return 1; } freeAllocatedSingleString(stkAdr); AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; ReturnArguments(pvApiCtx); } return 0; break; } case sci_handles: /* scalar argument (hdl + string) */ CheckInputArgument(pvApiCtx, 1, 2); // Retrieve a matrix of handle at position 1. sciErr = getMatrixOfHandle(pvApiCtx, piAddrl1, &m1, &n1, &l1); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(202, _("%s: Wrong type for input argument #%d: Handle matrix expected.\n"), fname, 1); return 1; } if (m1 != 1 || n1 != 1) { //lw = 1 + nbArgumentOnStack(pvApiCtx) - nbInputArgument(pvApiCtx); OverLoad(1); return 0; } if (nbInputArgument(pvApiCtx) == 1) { //get path from handle int uic = getObjectFromHandle((long) * l1); char* path = get_path(uic); if (path[0] == '\0') { Scierror(999, _("%s: Unable to get useful path from this handle.\n"), fname); return 1; } createSingleString(pvApiCtx, nbInputArgument(pvApiCtx) + 1, path); FREE(path); AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; ReturnArguments(pvApiCtx); return 0; } sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrl2); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } if (isScalar(pvApiCtx, piAddrl2) == 0 || isStringType(pvApiCtx, piAddrl2) == 0) { Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 2); return 1; } // Retrieve a matrix of double at position 2. if (getAllocatedSingleString(pvApiCtx, piAddrl2, &l2)) { Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 2); return 1; } hdl = (long) * l1; /* on recupere le pointeur d'objet par le handle */ break; case sci_strings: /* string argument (string) */ { char* pstFirst = NULL; CheckInputArgument(pvApiCtx, 1, 2); if (isScalar(pvApiCtx, piAddrl1) == 0) { Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1); return 1; } // Retrieve a matrix of double at position 1. if (getAllocatedSingleString(pvApiCtx, piAddrl1, &pstFirst)) { Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 1); return 1; } if (strcmp(pstFirst, "default_figure") == 0 || strcmp(pstFirst, "default_axes") == 0 || strcmp(pstFirst, "current_figure") == 0 || strcmp(pstFirst, "current_axes") == 0 || strcmp(pstFirst, "current_entity") == 0 || strcmp(pstFirst, "hdl") == 0 || strcmp(pstFirst, "figures_id") == 0) { hdl = 0; l2 = pstFirst; } else { int uid = search_path(pstFirst); if (uid != 0) { freeAllocatedSingleString(pstFirst); hdl = getHandle(uid); if (nbInputArgument(pvApiCtx) == 1) { createScalarHandle(pvApiCtx, nbInputArgument(pvApiCtx) + 1, hdl); AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; ReturnArguments(pvApiCtx); return 0; } sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrl2); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } if (isScalar(pvApiCtx, piAddrl2) == 0 || isStringType(pvApiCtx, piAddrl2) == 0) { Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 2); return 1; } if (getAllocatedSingleString(pvApiCtx, piAddrl2, &l2)) { Scierror(202, _("%s: Wrong type for argument #%d: string expected.\n"), fname, 2); return 1; } } else { createEmptyMatrix(pvApiCtx, nbInputArgument(pvApiCtx) + 1); AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; ReturnArguments(pvApiCtx); return 0; } } break; } default: //lw = 1 + nbArgumentOnStack(pvApiCtx) - nbInputArgument(pvApiCtx); OverLoad(1); return 0; break; } /* (l2) est la commande, l3 l'indice sur les parametres de la commande */ CheckOutputArgument(pvApiCtx, 0, 1); if (hdl == 0) { /* No handle specified */ if (callGetProperty(pvApiCtx, 0, (l2)) != 0) { /* An error has occurred */ freeAllocatedSingleString(l2); ReturnArguments(pvApiCtx); return 0; } } else { iObjUID = getObjectFromHandle(hdl); if (iObjUID != 0) { if (callGetProperty(pvApiCtx, iObjUID, (l2)) != 0) { /* An error has occurred */ freeAllocatedSingleString(l2); ReturnArguments(pvApiCtx); return 0; } } else { Scierror(999, _("%s: The handle is not or no more valid.\n"), fname); freeAllocatedSingleString(l2); return 0; } } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; ReturnArguments(pvApiCtx); freeAllocatedSingleString(l2); return 0; }