示例#1
0
/*--------------------------------------------------------------------------*/
int getRecursionGatewayToCall(void)
{
	int gw = ERROR_GW_ID;

	if ( isRecursionCallToFunction() )
	{
		int ir = C2F(recu).rstk[C2F(recu).pt-1] - 900;
		gw = C2F(getrecursiongatewaytocall)(&ir);
	}

	return gw;
}
示例#2
0
/*--------------------------------------------------------------------------*/
recursion_function_called getRecursionFunctionToCall(void)
{
	int function_number = RECURSION_ERROR;

	if ( isRecursionCallToFunction() )
	{
		int ir = (int)(C2F(recu).rstk[C2F(recu).pt-1] - 900);

		if ( (ir > (int) RECURSION_CALL_EXEC2) || (ir < (int) RECURSION_CALL_COMP) )
		{
			function_number = RECURSION_ERROR;
		}
		else
		{
			function_number = (recursion_function_called) ir;
		}
	}
	return (recursion_function_called)function_number;
}
示例#3
0
/*--------------------------------------------------------------------------*/
int gw_io(void)
{
    /* Recursion from a function */
    if (pvApiCtx == NULL)
    {
        pvApiCtx = (StrCtx*)MALLOC(sizeof(StrCtx));
    }

    if ( isRecursionCallToFunction() )
    {
        switch ( getRecursionFunctionToCall() )
        {
            case RECURSION_CALL_SAVE:
            {
                pvApiCtx->pstName = "save";
                C2F(intsave)();
                return 0;
            }
            break;
            case RECURSION_CALL_LOAD:
            {
                pvApiCtx->pstName = "load";
                sci_load("load", (unsigned long)strlen("load"));
                return 0;
            }
            break;
            default:
                break;
        }
    }
    else
    {
        Rhs = Max(0, Rhs);
        pvApiCtx->pstName = (char*)Tab[Fin - 1].name;
        callFunctionFromGateway(Tab, SIZE_CURRENT_GENERIC_TABLE(Tab));
    }
    return 0;
}
示例#4
0
/*--------------------------------------------------------------------------*/
int gw_functions(void)
{  
	Rhs = Max(0, Rhs);

	if ( isRecursionCallToFunction() )
	{
		switch ( getRecursionFunctionToCall() )
		{
			case RECURSION_CALL_DEFF:
				#define deff_fname "deff"
				C2F(sci_deff)(deff_fname,(unsigned long)strlen(deff_fname));
				return 0;

			case RECURSION_CALL_EXEC1: case RECURSION_CALL_EXEC2:
				#define exec_fname "exec"
				C2F(sci_exec)(exec_fname,(unsigned long)strlen(exec_fname));
				return 0;

			case RECURSION_CALL_EXECSTR:
				#define execstr_fname "execstr"
				C2F(sci_execstr)(execstr_fname,(unsigned long)strlen(execstr_fname));
				return 0;

			default:
				return 0;
		}
	}
	
	if(pvApiCtx == NULL)
	{
		pvApiCtx = (StrCtx*)MALLOC(sizeof(StrCtx));
	}

	pvApiCtx->pstName = (char*)Tab[Fin-1].name;
	callFunctionFromGateway(Tab, SIZE_CURRENT_GENERIC_TABLE(Tab));
	return 0;
}
示例#5
0
/*--------------------------------------------------------------------------*/
int C2F(isrecursioncalltofunction)(void)
{
	return isRecursionCallToFunction();
}
示例#6
0
/*--------------------------------------------------------------------------*/
int syncexec(char *str, int *ns, int *ierr, int *seq, long int str_len)
{
	

	/* Local variables */
	static int zero = 0;
	static int one = 1;
	int Pts, Tops;
	static int k;

	static int *Ids  = C2F(recu).ids-nsiz-1;
	static int *Rstk = C2F(recu).rstk-1;
	static int *Lstk = C2F(vstk).lstk-1;
	static int *Infstk  = C2F(vstk).infstk-1;

	Pt = Max(Pt,0);Pts=Pt;
	Top = Max(Top,0);Tops=Top;
	C2F(bexec)(str, ns, ierr, (*ns));
	if (*ierr != 0) {
		goto L9998;
	}
	/* + */
	if (Eptover(1)) {
		goto L9998;
	}
	Ids[1 + Pt * nsiz] = Lhs;
	Ids[2 + Pt * nsiz] = Rhs;
	Ids[3 + Pt * nsiz] = C2F(com).sym;
	Ids[4 + Pt * nsiz] =  C2F(basbrk).interruptible;
	C2F(basbrk).interruptible = *seq == 0;

	Rstk[Pt] = 1002;
	++C2F(recu).niv;
	C2F(com).fun = 0;
	C2F(recu).icall = 5;

	/* code translated from callinterf.h */
L60:

	C2F(parse)();

	if (Err > 0) {
	  goto L9999;
	}

	if (C2F(com).fun == 99) {
		C2F(com).fun = 0;
		goto L200;
	}

	if ( isRecursionCallToFunction() )
	{
		int gw = getRecursionGatewayToCall();
		if (gw == END_OVERLOAD)
		{
			goto L96;
		} 
		else if (gw == ERROR_GW_ID)
		{
			goto L89;
		}
		else
		{
			k = gw;
		}
		goto L95;
	}


L89:
	if (Top < Rhs) {
		int lierr = 22;
		SciError(lierr);
		goto L9999;
	}
	if (Top - Rhs + Lhs + 1 >= Bot) {
		int lierr = 18;
		SciError(lierr);
		goto L9999;
	}
	goto L91;

L90:
	if (Err > 0) {
		goto L9999;
	}
L91:
	k = C2F(com).fun;
	C2F(com).fun = 0;
	if (k == C2F(recu).krec) {
		int lierr = 22;
		C2F(recu).krec = -1;
		SciError(lierr);
		goto L9999;
	}
	C2F(recu).krec = -1;
	if (k == 0) {
		goto L60;
	}
L95:
	if (! C2F(allowptr)(&k)) {
		C2F(ref2val)();
	}
	C2F(recu).krec = k;
	C2F(callinterf)(&k);
	/*      if (k.eq.krec) krec=99999 */
	C2F(recu).krec = -1;
	if (C2F(com).fun >= 0) {
		if (Top - Lhs + 1 > 0) {
			C2F(iset)(&Rhs, &zero, &Infstk[Top - Lhs+1], &one);
		}
		goto L90;
	}
	/*     called interface ask for a scilab function to perform the function (fun=-1) */
	/*     the function name is given in ids(1,pt+1) */
	C2F(ref2val)();
	C2F(com).fun = 0;
	C2F(funs)(&Ids[1 + (Pt + 1) * nsiz]);
	if (Err > 0) {
		goto L9999;
	}
	if (C2F(com).fun > 0) {
		goto L91;
	}
	if (Fin == 0) {
		int lierr = 246;
		SciError(lierr);
		if (Err > 0) {
			goto L9999;
		}
		goto L90;
	}
	++Pt;
	Fin = Lstk[C2F(com).fin];
	Rstk[Pt] = 910;
	C2F(recu).icall = 5;
	C2F(com).fun = 0;
	/*     *call*  macro */
	goto L60;
L96:
	--Pt;
	goto L90;
	/* End of callinterf.h code */

L200:
	Lhs = Ids[1 + Pt * nsiz];
	Rhs = Ids[2 + Pt * nsiz];
	C2F(com).sym = Ids[3 + Pt * nsiz];
	C2F(basbrk).interruptible = Ids[4 + Pt * nsiz];
	--Pt;
	--Top;
	/* + */
	--C2F(recu).niv;
	*ierr = 0;
	C2F(recu).icall = 0;
	Fin = 3;
	return 0;
L9998:
	*ierr = 1;
	C2F(basbrk).interruptible = Ids[4 + Pt * nsiz];
	Pt=Pts;Top=Tops;
	return 0;
L9999:
	/* Err == 9999999 arises if abort has been used to terminate the callback execution */
	if (Err != 9999999) *ierr = 1;
	--Top;
	--C2F(recu).niv;
	/*
	** OVVERRIDE WHAT PARSE AS PUT INTO THIS
	** F. FLAG !!!!
	** We want to be interruptible after having an error
	** _VERY_ CRAPPY CODE
	*/
	//C2F(basbrk).interruptible = Ids[4 + Pt * nsiz];
	C2F(basbrk).interruptible = TRUE;
	Pt=Pts;Top=Tops;
	C2F(recu).icall = 0;
	return 0;
} /* syncexec */
示例#7
0
/*--------------------------------------------------------------------------*/
int C2F(sci_execstr)(char *fname,unsigned long fname_len)
{
	if ( isRecursionCallToFunction() )
	{
		C2F(intexecstr)(fname, fname_len);
	}
	else
	{
		SciErr sciErr;

		int *piAddressVarOne = NULL;
		int iType1 = 0;

		CheckRhs(1,3);
		CheckLhs(0,1);

		sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne);
		if(sciErr.iErr)
		{
			printError(&sciErr, 0);
            Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
			return 0;
		}

		sciErr = getVarType(pvApiCtx, piAddressVarOne, &iType1);
		if(sciErr.iErr)
		{
			printError(&sciErr, 0);
            Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
			return 0;
		}

		/* execstr([])*/
		if (iType1 == sci_matrix)
		{
			int m1 = 0, n1 = 0;

			sciErr = getVarDimension(pvApiCtx, piAddressVarOne, &m1, &n1);
			if(sciErr.iErr)
			{
				printError(&sciErr, 0);
                Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
				return 0;
			}

			if ((m1 == n1) && (m1 == 0)) /* [] */
			{
				sciErr = createMatrixOfDouble(pvApiCtx, Rhs + 1, 0, 0, NULL);
				if(sciErr.iErr)
				{
					printError(&sciErr, 0);
                    Scierror(999,_("%s: Memory allocation error.\n"), fname);
					return 0;
				}

				LhsVar(1) = Rhs + 1;

				PutLhsVar();
				return 0;
			}
			else
			{
				Scierror(999,_("%s: Wrong type for input argument #%d: A string expected.\n"),fname,1);
				return 0;
			}
		}

		if (iType1 != sci_strings)
		{
			Scierror(999,_("%s: Wrong type for input argument #%d: A string expected.\n"),fname,1);
			return 0;
		}

		if (Rhs > 1)
		{
			int m2 = 0, n2 = 0;
			int *piAddressVarTwo = NULL;
			char *pStVarTwo = NULL;
			int lenStVarTwo = 0;
			int iType2 = 0;

			sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddressVarTwo);
			if(sciErr.iErr)
			{
				printError(&sciErr, 0);
                Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
				return 0;
			}

			sciErr = getVarType(pvApiCtx, piAddressVarTwo, &iType2);
			if(sciErr.iErr)
			{
				printError(&sciErr, 0);
                Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
				return 0;
			}

			if (iType2 != sci_strings)
			{
				Scierror(999,_("%s: Wrong type for input argument #%d: A string expected.\n"),fname,2);
				return 0;
			}

			sciErr = getMatrixOfString(pvApiCtx, piAddressVarTwo,&m2,&n2,&lenStVarTwo, NULL);
			if(sciErr.iErr)
			{
				printError(&sciErr, 0);
                Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
				return 0;
			}

			if (m2 * n2 != 1)
			{
				Scierror(999,_("%s: Wrong size for input argument #%d: A string expected.\n"),fname,2);
				return 0;
			}

			pStVarTwo = (char*)MALLOC(sizeof(char)*(lenStVarTwo + 1));
			if (pStVarTwo)
			{
				sciErr = getMatrixOfString(pvApiCtx, piAddressVarTwo,&m2,&n2,&lenStVarTwo,&pStVarTwo);
				if(sciErr.iErr)
				{
					printError(&sciErr, 0);
                    Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
					return 0;
				}

				if (strcmp(pStVarTwo,ERRCATCH_KEYWORD))
				{
					Scierror(999,_("%s: Wrong value for input argument #%d: 'errcatch' expected.\n"),fname,2);
					FREE(pStVarTwo);
					pStVarTwo = NULL;
					return 0;
				}

				FREE(pStVarTwo);
				pStVarTwo = NULL;
			}
			else
			{
				Scierror(999,_("%s: Memory allocation error.\n"),fname);
				return 0;
			}
		}

		if (Rhs > 2)
		{
			int m3 = 0, n3 = 0;
			int *piAddressVarThree = NULL;
			char *pStVarThree = NULL;
			int lenStVarThree = 0;
			int iType3 = 0;

			sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddressVarThree);
			if(sciErr.iErr)
			{
				printError(&sciErr, 0);
                Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 3);
				return 0;
			}

			sciErr = getVarType(pvApiCtx, piAddressVarThree, &iType3);
			if(sciErr.iErr)
			{
				printError(&sciErr, 0);
                Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 3);
				return 0;
			}

			if (iType3 != sci_strings)
			{
				Scierror(999,_("%s: Wrong type for input argument #%d: A string expected.\n"),fname,3);
				return 0;
			}

			sciErr = getMatrixOfString(pvApiCtx, piAddressVarThree,&m3,&n3,&lenStVarThree, NULL);
			if(sciErr.iErr)
			{
				printError(&sciErr, 0);
                Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 3);
				return 0;
			}

			if (m3 * n3 != 1)
			{
				Scierror(999,_("%s: Wrong size for input argument #%d: A string expected.\n"),fname,3);
				return 0;
			}

			pStVarThree = (char*)MALLOC(sizeof(char)*(lenStVarThree + 1));
			if (pStVarThree)
			{
				sciErr = getMatrixOfString(pvApiCtx, piAddressVarThree,&m3,&n3,&lenStVarThree,&pStVarThree);
				if(sciErr.iErr)
				{
					printError(&sciErr, 0);
                    Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 3);
					return 0;
				}

				if ( strcmp(pStVarThree, MESSAGE_KEYWORD) && strcmp(pStVarThree, MESSAGE_DEFAULT_KEYWORD) )
				{
					Scierror(999,_("%s: Wrong value for input argument #%d: 'm' or 'n' expected.\n"),fname,3);
					FREE(pStVarThree);
					pStVarThree = NULL;
					return 0;
				}

				FREE(pStVarThree);
				pStVarThree = NULL;
			}
			else
			{
				Scierror(999,_("%s: Memory allocation error.\n"),fname);
				return 0;
			}
		}

		C2F(intexecstr)(fname, fname_len);
	}
	return 0;
}