/*-----------------------------------------------------------------------------------*/ static int callExternalFunction(char *fname, GatefuncS F, BOOL withPutLhsVar) { (*F)(fname, (int)strlen(fname)); if (withPutLhsVar) { returnArguments(NULL); } return 0; }
/*--------------------------------------------------------------------------*/ int sci_dlgamma(char *fname, unsigned long fname_len) { SciErr sciErr; double* lX = NULL; int* piAddrX = NULL; int iType1 = 0; int MX = 0, NX = 0, i = 0; nbInputArgument(pvApiCtx) = Max(0, nbInputArgument(pvApiCtx)); CheckInputArgument(pvApiCtx, 1, 1); CheckOutputArgument(pvApiCtx, 1, 1); sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrX); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1); return 1; } sciErr = getVarType(pvApiCtx, piAddrX, &iType1); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1); return 1; } if ((iType1 == sci_list) || (iType1 == sci_tlist) || (iType1 == sci_mlist)) { OverLoad(1); return 0; } if (isVarComplex(pvApiCtx, piAddrX)) { Scierror(999, _("%s: Wrong type for input argument #%d: A real expected.\n"), fname, 1); return 1; } sciErr = getMatrixOfDouble(pvApiCtx, piAddrX, &MX, &NX, &lX); if (sciErr.iErr) { Scierror(999, _("%s: Wrong type for argument %d: A matrix expected.\n"), fname, 1); } for (i = 0; i < MX * NX; i++) { lX[i] = C2F(psi)(lX + i); } AssignOutputVariable(pvApiCtx, 1) = 1; returnArguments(pvApiCtx); return 0; }
//delete all allocd arrays before exit, and return output argument static void cleanupBeforeExit() { if(conMatrixColStart) delete[] conMatrixColStart; if(conMatrixRowIndex) delete[] conMatrixRowIndex; if(isIntVar) delete[] isIntVar; if(conType) delete[] conType; if(conRange) delete[] conRange; if(conRHS) delete[] conRHS; iRet = createScalarDouble(pvApiCtx, nbInputArgument(pvApiCtx)+1,0); if(iRet) { /* If error, no return variable */ AssignOutputVariable(pvApiCtx, 1) = 0; return; } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx)+1; returnArguments(pvApiCtx); }
/*--------------------------------------------------------------------------*/ int sci_getinstalledlookandfeels(char *fname, unsigned long fname_len) { SciErr sciErr; CheckInputArgument(pvApiCtx, 0, 0); CheckOutputArgument(pvApiCtx, 1, 1); org_scilab_modules_gui_utils::LookAndFeelManager * lnf = 0; try { lnf = new org_scilab_modules_gui_utils::LookAndFeelManager(getScilabJavaVM()); } catch (const GiwsException::JniException & e) { Scierror(999, _("%s: A Java exception arisen:\n%s"), fname, e.whatStr().c_str()); return 1; } if (lnf) { char **lookandfeels = NULL; int nbElems = 0; int nbCol = 0; lookandfeels = lnf->getInstalledLookAndFeels(); nbElems = lnf->numbersOfInstalledLookAndFeels(); nbCol = 1; sciErr = createMatrixOfString(pvApiCtx, nbInputArgument(pvApiCtx) + 1, nbElems, nbCol, lookandfeels); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(999, _("%s: Memory allocation error.\n"), fname); return 1; } if (lookandfeels) { int i = 0; for (i = 0; i < nbElems; i++) { if (lookandfeels[i]) { delete[]lookandfeels[i]; } } delete[]lookandfeels; lookandfeels = NULL; } delete lnf; AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; returnArguments(pvApiCtx); } else { Scierror(999, _("%s: No more memory.\n"), fname); } return 0; }