class EXTERN_AST Context
{
public :
+ typedef std::map<Symbol, Variable*> VarList;
+ typedef std::stack<VarList*> VarStack;
+
static Context* getInstance(void);
static void destroyInstance(void);
types::InternalType* get(const Symbol& key, int _iLevel);
bool clearCurrentScope(bool _bClose);
- typedef std::map<Symbol, Variable*> VarList;
- typedef std::stack<VarList*> VarStack;
std::list<Symbol>* globals;
VarStack varStack;
Variables variables;
struct Library
{
+ typedef std::stack<ScopedLibrary*> StackLib;
+
Library(const Symbol& _name) : name(_name) {};
void put(types::Library* _pLib, int _iLevel)
}
private :
- typedef std::stack<ScopedLibrary*> StackLib;
StackLib stack;
Symbol name;
bool m_global;
struct Libraries
{
+ typedef std::map<Symbol, Library*> MapLibs;
+
Libraries() {};
Library* getOrCreate(const Symbol& _key)
}
private:
- typedef std::map<Symbol, Library*> MapLibs;
MapLibs libs;
};
}
struct Variable
{
+ typedef std::stack<ScopedVariable*> StackVar;
+
Variable(const Symbol& _name) : name(_name), m_Global(false), m_GlobalValue(NULL) {};
~Variable()
{
Symbol name;
types::InternalType* m_GlobalValue;
bool m_Global;
- typedef std::stack<ScopedVariable*> StackVar;
StackVar stack;
};
struct Variables
{
+ typedef std::map<Symbol, Variable*> MapVars;
+
Variables() {};
Variable* getOrCreate(const Symbol& _key)
}
private:
- typedef std::map<Symbol, Variable*> MapVars;
MapVars vars;
};
}
bool Context::addFunction(types::Function *_info)
{
Variable* var = variables.getOrCreate(Symbol(_info->getName()));
- variables.putInPreviousScope(var, _info, 1);
+ variables.putInPreviousScope(var, _info, 0);
return true;
}
sci_gateway/cpp/core_gw.cpp \
sci_gateway/cpp/sci_getmodules.cpp \
sci_gateway/cpp/sci_clear.cpp \
+ sci_gateway/cpp/sci_clearfun.cpp \
+ sci_gateway/cpp/sci_newfun.cpp \
+ sci_gateway/cpp/sci_funptr.cpp \
sci_gateway/cpp/sci_banner.cpp \
sci_gateway/cpp/sci_quit.cpp \
sci_gateway/cpp/sci_exit.cpp \
am__objects_5 = sci_gateway/cpp/libscicore_la-core_gw.lo \
sci_gateway/cpp/libscicore_la-sci_getmodules.lo \
sci_gateway/cpp/libscicore_la-sci_clear.lo \
+ sci_gateway/cpp/libscicore_la-sci_clearfun.lo \
+ sci_gateway/cpp/libscicore_la-sci_newfun.lo \
+ sci_gateway/cpp/libscicore_la-sci_funptr.lo \
sci_gateway/cpp/libscicore_la-sci_banner.lo \
sci_gateway/cpp/libscicore_la-sci_quit.lo \
sci_gateway/cpp/libscicore_la-sci_exit.lo \
sci_gateway/cpp/core_gw.cpp \
sci_gateway/cpp/sci_getmodules.cpp \
sci_gateway/cpp/sci_clear.cpp \
+ sci_gateway/cpp/sci_clearfun.cpp \
+ sci_gateway/cpp/sci_newfun.cpp \
+ sci_gateway/cpp/sci_funptr.cpp \
sci_gateway/cpp/sci_banner.cpp \
sci_gateway/cpp/sci_quit.cpp \
sci_gateway/cpp/sci_exit.cpp \
sci_gateway/cpp/libscicore_la-sci_clear.lo: \
sci_gateway/cpp/$(am__dirstamp) \
sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
+sci_gateway/cpp/libscicore_la-sci_clearfun.lo: \
+ sci_gateway/cpp/$(am__dirstamp) \
+ sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
+sci_gateway/cpp/libscicore_la-sci_newfun.lo: \
+ sci_gateway/cpp/$(am__dirstamp) \
+ sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
+sci_gateway/cpp/libscicore_la-sci_funptr.lo: \
+ sci_gateway/cpp/$(am__dirstamp) \
+ sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
sci_gateway/cpp/libscicore_la-sci_banner.lo: \
sci_gateway/cpp/$(am__dirstamp) \
sci_gateway/cpp/$(DEPDIR)/$(am__dirstamp)
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_argn.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_banner.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_clear.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_clearfun.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_clearglobal.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_errclear.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_error.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_exit.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_format.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_funcprot.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_funptr.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_getmd5.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_getmemory.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_getmodules.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_isglobal.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_lasterror.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_mode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_newfun.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_pause.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_quit.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_sciargs.Plo@am__quote@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libscicore_la-sci_clear.lo `test -f 'sci_gateway/cpp/sci_clear.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_clear.cpp
+sci_gateway/cpp/libscicore_la-sci_clearfun.lo: sci_gateway/cpp/sci_clearfun.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sci_gateway/cpp/libscicore_la-sci_clearfun.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_clearfun.Tpo -c -o sci_gateway/cpp/libscicore_la-sci_clearfun.lo `test -f 'sci_gateway/cpp/sci_clearfun.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_clearfun.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_clearfun.Tpo sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_clearfun.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='sci_gateway/cpp/sci_clearfun.cpp' object='sci_gateway/cpp/libscicore_la-sci_clearfun.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libscicore_la-sci_clearfun.lo `test -f 'sci_gateway/cpp/sci_clearfun.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_clearfun.cpp
+
+sci_gateway/cpp/libscicore_la-sci_newfun.lo: sci_gateway/cpp/sci_newfun.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sci_gateway/cpp/libscicore_la-sci_newfun.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_newfun.Tpo -c -o sci_gateway/cpp/libscicore_la-sci_newfun.lo `test -f 'sci_gateway/cpp/sci_newfun.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_newfun.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_newfun.Tpo sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_newfun.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='sci_gateway/cpp/sci_newfun.cpp' object='sci_gateway/cpp/libscicore_la-sci_newfun.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libscicore_la-sci_newfun.lo `test -f 'sci_gateway/cpp/sci_newfun.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_newfun.cpp
+
+sci_gateway/cpp/libscicore_la-sci_funptr.lo: sci_gateway/cpp/sci_funptr.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sci_gateway/cpp/libscicore_la-sci_funptr.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_funptr.Tpo -c -o sci_gateway/cpp/libscicore_la-sci_funptr.lo `test -f 'sci_gateway/cpp/sci_funptr.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_funptr.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_funptr.Tpo sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_funptr.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='sci_gateway/cpp/sci_funptr.cpp' object='sci_gateway/cpp/libscicore_la-sci_funptr.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sci_gateway/cpp/libscicore_la-sci_funptr.lo `test -f 'sci_gateway/cpp/sci_funptr.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_funptr.cpp
+
sci_gateway/cpp/libscicore_la-sci_banner.lo: sci_gateway/cpp/sci_banner.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sci_gateway/cpp/libscicore_la-sci_banner.lo -MD -MP -MF sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_banner.Tpo -c -o sci_gateway/cpp/libscicore_la-sci_banner.lo `test -f 'sci_gateway/cpp/sci_banner.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_banner.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_banner.Tpo sci_gateway/cpp/$(DEPDIR)/libscicore_la-sci_banner.Plo
CPP_GATEWAY_PROTOTYPE(sci_getmemory);
CPP_GATEWAY_PROTOTYPE(sci_errclear);
CPP_GATEWAY_PROTOTYPE(sci_intppty);
+CPP_GATEWAY_PROTOTYPE(sci_newfun);
+CPP_GATEWAY_PROTOTYPE(sci_clearfun);
+CPP_GATEWAY_PROTOTYPE(sci_funptr);
#endif /* __CORE_GW_HXX__ */
//C_GATEWAY_PROTOTYPE(sci_typename); -> c++
int C2F(sci_funcprot)(char *fname, void* pvApiCtx);
-int C2F(sci_newfun)(char *fname, void* pvApiCtx);
+//int C2F(sci_newfun)(char *fname, void* pvApiCtx); -> C++
//Yasp
C_GATEWAY_PROTOTYPE(sci_type);
+++ /dev/null
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2006 - INRIA - Allan CORNET
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
- *
- */
-#include "gw_core.h"
-#include "stack-c.h"
-#include "stack-def.h"
-#include "MALLOC.h"
-#include "hashtable_core.h"
-#include "Scierror.h"
-#include "Funtab.h"
-#include "localization.h"
-/*--------------------------------------------------------------------------*/
-int C2F(sci_clearfun)(char *fname, unsigned long fname_len)
-{
- static int l1 = 0, n1 = 0, m1 = 0;
- int *Status = NULL;
-
- CheckRhs(1, 1);
- CheckLhs(1, 1);
-
- if (GetType(1) == sci_strings)
- {
- char *VarName = NULL;
- int id[nsiz];
- int zero = 0;
- int fptr = 0;
- int job = 0;
-
- GetRhsVar(1, STRING_DATATYPE, &m1, &n1, &l1);
- VarName = cstk(l1);
-
- Status = (int*)MALLOC(sizeof(int));
-
- C2F(cvname)(id, VarName, &zero, (unsigned long)strlen(VarName));
- job = SCI_HFUNCTIONS_FIND; /* Find function & returns fptr value */
- C2F(funtab)(id, &fptr, &job, "NULL_NAME", 0);
-
- if (fptr != 0)
- {
- job = SCI_HFUNCTIONS_DELETE; /* delete function entry */
- C2F(funtab)(id, &fptr, &job, "NULL_NAME", 0);
- *Status = TRUE;
- }
- else /* fptr = 0 function doesn't exist */
- {
- *Status = FALSE;
- }
- m1 = 1;
- n1 = 1;
- CreateVarFromPtr(Rhs + 1, MATRIX_OF_BOOLEAN_DATATYPE, &n1, &n1, &Status);
- LhsVar(1) = Rhs + 1;
-
- if (Status)
- {
- FREE(Status);
- Status = NULL;
- }
- PutLhsVar();
- }
- else
- {
- Scierror(999, _("%s: Wrong type for input argument #%d: String expected.\n"), fname, 1);
- return 0;
- }
-
- return 0;
-}
-/*--------------------------------------------------------------------------*/
-
+++ /dev/null
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2006 - INRIA - Allan CORNET
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
- *
- */
-#include "gw_core.h"
-#include "stack-c.h"
-#include "localization.h"
-#include "hashtable_core.h"
-#include "Scierror.h"
-#include "Funtab.h"
-#include "stack-def.h"
-/*--------------------------------------------------------------------------*/
-int C2F(sci_funptr) (char *fname, unsigned long fname_len)
-{
- CheckRhs(1, 1);
- CheckLhs(1, 1);
-
- if ( GetType(1) == sci_strings )
- {
- char *VarName = NULL;
- int m1 = 0, n1 = 0, l1 = 0;
- int id[nsiz];
- int funptr = 0;
- int zero = 0;
- int one = 1;
- int job = SCI_HFUNCTIONS_FIND; /* Find function & returns fptr value */
-
- GetRhsVar(1, STRING_DATATYPE, &m1, &n1, &l1);
- VarName = cstk(l1);
-
- C2F(cvname)(id, VarName, &zero, (unsigned long)strlen(VarName));
- C2F(funtab)(id, &funptr, &job, "NULL_NAME", 0);
-
- CreateVar(Rhs + 1, MATRIX_OF_INTEGER_DATATYPE, &one, &one, &l1);
- *istk(l1) = funptr;
-
- LhsVar(1) = Rhs + 1;
- PutLhsVar();
- }
- else
- {
- Scierror(999, _("%s: Wrong type for input argument #%d: String expected.\n"), fname, 1);
- }
- return 0;
-}
-/*--------------------------------------------------------------------------*/
+++ /dev/null
-/*
-* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-* Copyright (C) 2006 - 2008 - INRIA - Allan CORNET
-* Copyright (C) 2008 - INRIA - Bruno JOFRET
-* Copyright (C) 2009 - DIGITEO - Allan CORNET
-*
-* This file must be used under the terms of the CeCILL.
-* This source file is licensed as described in the file COPYING, which
-* you should have received as part of this distribution. The terms
-* are also available at
-* http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
-*
-*/
-#include <string.h>
-#include <ctype.h>
-#include "gw_core.h"
-#include "BOOL.h"
-#include "api_scilab.h"
-#include "Funtab.h"
-#include "IsAScalar.h"
-#include "hashtable_core.h"
-#include "Scierror.h"
-#include "localization.h"
-#include "MALLOC.h"
-/*--------------------------------------------------------------------------*/
-static BOOL Is_a_correct_function_name(char *functionname);
-/*--------------------------------------------------------------------------*/
-int C2F(sci_newfun) (char *fname, void* pvApiCtx)
-{
- SciErr sciErr;
- int m1 = 0, n1 = 0;
- int iType1 = 0;
- int *piAddressVarOne = NULL;
- char *pStVarOne = NULL;
- int lenStVarOne = 0;
-
- int m2 = 0, n2 = 0;
- int iType2 = 0;
- int *piAddressVarTwo = NULL;
- double *pdVarTwo = NULL;
-
- int ifptr = 0;
-
- CheckRhs(2, 2);
- CheckLhs(1, 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 = 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, piAddressVarOne, &iType1);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
- 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 ( iType1 != sci_strings )
- {
- Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 1);
- return 0;
- }
-
- if ( iType2 != sci_matrix )
- {
- Scierror(999, _("%s: Wrong type for input argument #%d: A scalar expected.\n"), fname, 2);
- return 0;
- }
-
- sciErr = getMatrixOfString(pvApiCtx, piAddressVarOne, &m1, &n1, &lenStVarOne, NULL);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
- return 0;
- }
-
- if ( (m1 != 1) || (n1 != 1) )
- {
- Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), fname, 1);
- return 0;
- }
-
- sciErr = getMatrixOfDouble(pvApiCtx, piAddressVarTwo, &m2, &n2, &pdVarTwo);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
- return 0;
- }
-
- if ( (m2 != 1) || (n2 != 1) )
- {
- Scierror(999, _("%s: Wrong size for input argument #%d: A scalar expected.\n"), fname, 1);
- return 0;
- }
-
- ifptr = (int) * pdVarTwo;
- if (*pdVarTwo != (double)ifptr)
- {
- Scierror(999, _("%s: Wrong value for input argument #%d: An integer expected.\n"), fname, 2);
- return 0;
- }
-
- pStVarOne = (char*)MALLOC(sizeof(char) * (lenStVarOne + 1));
- if (pStVarOne)
- {
- sciErr = getMatrixOfString(pvApiCtx, piAddressVarOne, &m1, &n1, &lenStVarOne, &pStVarOne);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
- return 0;
- }
- }
- else
- {
- Scierror(999, _("%s: Memory allocation error.\n"), fname);
- return 0;
- }
-
- if (ifptr > 0)
- {
- if (Is_a_correct_function_name(pStVarOne))
- {
- //int id[nsiz];
- //int i = 0;
- //int zero = 0;
- //int fptr = ifptr;
- //int job = 0 ;
-
- ///* initialize id */
- //for(i = 0; i < nsiz; i++) id[i] = 0;
-
- //C2F(cvname)(id, pStVarOne,&zero,(unsigned long)strlen(pStVarOne));
- //job = SCI_HFUNCTIONS_ENTER;
- //C2F(funtab)(id,&fptr,&job,pStVarOne,(unsigned long)strlen(pStVarOne));
- //if (pStVarOne) {FREE(pStVarOne); pStVarOne = NULL;};
-
- //LhsVar(1) = 0;
- //PutLhsVar();
- }
- else
- {
- if (pStVarOne)
- {
- FREE(pStVarOne);
- pStVarOne = NULL;
- };
- Scierror(999, _("%s: function-name is incorrect.\n"), fname);
- return 0;
- }
- }
- else
- {
- Scierror(999, _("%s: Wrong value for input argument #%d: Must be %s.\n"), fname, 2, "> 0");
- return 0;
- }
-
- return 0;
-}
-/*--------------------------------------------------------------------------*/
-static BOOL Is_a_correct_function_name(char *functionname)
-{
- // FIX ME
- return FALSE;
-}
-/*--------------------------------------------------------------------------*/
symbol::Context::getInstance()->addFunction(Function::createFunction(L"getmemory", &sci_getmemory, MODULE_NAME));
symbol::Context::getInstance()->addFunction(Function::createFunction(L"errclear", &sci_errclear, MODULE_NAME));
symbol::Context::getInstance()->addFunction(Function::createFunction(L"intppty", &sci_intppty, MODULE_NAME));
+ symbol::Context::getInstance()->addFunction(Function::createFunction(L"newfun", &sci_newfun, MODULE_NAME));
+ symbol::Context::getInstance()->addFunction(Function::createFunction(L"clearfun", &sci_clearfun, MODULE_NAME));
+ symbol::Context::getInstance()->addFunction(Function::createFunction(L"funptr", &sci_funptr, MODULE_NAME));
return 1;
}
</Link>
</ItemDefinitionGroup>
<ItemGroup>
+ <ClCompile Include="sci_clearfun.cpp" />
<ClCompile Include="sci_errclear.cpp" />
<ClCompile Include="sci_format.cpp" />
<ClCompile Include="sci_funcprot.cpp" />
+ <ClCompile Include="sci_funptr.cpp" />
<ClCompile Include="sci_getmemory.cpp" />
<ClCompile Include="sci_ieee.cpp" />
<ClCompile Include="sci_mode.cpp" />
+ <ClCompile Include="sci_newfun.cpp" />
<ClCompile Include="sci_sciargs.cpp" />
<ClCompile Include="..\c\sci_getdebuginfo.c" />
<ClCompile Include="..\c\sci_type.c" />
<ClCompile Include="sci_intppty.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="sci_newfun.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="sci_clearfun.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="sci_funptr.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\includes\banner.hxx">
Scierror(999, _("%s: Wrong size for input argument #%d: Single string expected.\n"), "clear", iWrongType);
return Function::Error;
}
- iWrongType++;
}
- for (inIterator = in.begin() ; inIterator != in.end() ; iWrongType++, inIterator++)
+ for (inIterator = in.begin() ; inIterator != in.end() ; inIterator++)
{
symbol::Context::getInstance()->remove(symbol::Symbol((*inIterator)->getAs<types::String>()->get(0, 0)));
}
--- /dev/null
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "core_gw.hxx"
+#include "function.hxx"
+#include "callable.hxx"
+#include "context.hxx"
+#include "string.hxx"
+#include "bool.hxx"
+
+extern "C"
+{
+#include "Scierror.h"
+#include "localization.h"
+#include "charEncoding.h"
+}
+
+using namespace types;
+
+Function::ReturnValue sci_clearfun(types::typed_list &in, int _iRetCount, types::typed_list &out)
+{
+ if (in.size() != 1)
+ {
+ Scierror(999, _("%s: Wrong number of input arguments: %d expected.\n"), "clearfun" , 1);
+ return Function::Error;
+ }
+
+ InternalType* pIT1 = in[0];
+ if (pIT1->isString() == false)
+ {
+ Scierror(999, _("%s: Wrong type for input argument #%d: String expected.\n"), "clearfun", 1);
+ return Function::Error;
+ }
+
+ String* pS1 = pIT1->getAs<String>();
+ if (pS1->isScalar() == false)
+ {
+ Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), "clearfun", 1);
+ return Function::Error;
+ }
+
+ wchar_t* pwcsName = pS1->get(0);
+
+ bool bDeleted = false;
+ symbol::Context* pCtx = symbol::Context::getInstance();
+
+ symbol::Variable* pVar = pCtx->getOrCreate(symbol::Symbol(pwcsName));
+ symbol::Variable::StackVar stack;
+
+ //unstack all elements and stack them in new stack ( reverse order )
+ while (pVar->empty() == false)
+ {
+ stack.push(pVar->top());
+ pVar->pop();
+ }
+
+ if (stack.empty() == false)
+ {
+ symbol::ScopedVariable* pSV = stack.top();
+ if (pSV->m_iLevel == 0 && pSV->m_pIT->isFunction())
+ {
+ //remove
+ pSV->m_pIT->DecreaseRef();
+ pSV->m_pIT->killMe();
+ stack.pop();
+ bDeleted = true;
+ }
+
+ //move all elements at orginal place and order
+ while (stack.empty() == false)
+ {
+ pSV = stack.top();
+ stack.pop();
+ pSV->m_pIT->DecreaseRef();
+ pVar->put(pSV->m_pIT, pSV->m_iLevel);
+ delete pSV;
+ }
+ }
+
+ out.push_back(new Bool(bDeleted ? 1 : 0));
+ return Function::OK;
+}
--- /dev/null
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "core_gw.hxx"
+#include "function.hxx"
+#include "callable.hxx"
+#include "context.hxx"
+#include "string.hxx"
+#include "bool.hxx"
+
+extern "C"
+{
+#include "Scierror.h"
+#include "localization.h"
+#include "charEncoding.h"
+}
+
+using namespace types;
+
+Function::ReturnValue sci_funptr(types::typed_list &in, int _iRetCount, types::typed_list &out)
+{
+ if (in.size() != 1)
+ {
+ Scierror(999, _("%s: Wrong number of input arguments: %d expected.\n"), "funptr" , 1);
+ return Function::Error;
+ }
+
+ InternalType* pIT1 = in[0];
+ if (pIT1->isString() == false)
+ {
+ Scierror(999, _("%s: Wrong type for input argument #%d: String expected.\n"), "funptr", 1);
+ return Function::Error;
+ }
+
+ String* pS1 = pIT1->getAs<String>();
+ if (pS1->isScalar() == false)
+ {
+ Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), "funptr", 1);
+ return Function::Error;
+ }
+
+ wchar_t* pwcsName = pS1->get(0);
+
+ symbol::Context* pCtx = symbol::Context::getInstance();
+
+ symbol::Variable* pVar = pCtx->getOrCreate(symbol::Symbol(pwcsName));
+ symbol::Variable::StackVar stack;
+ bool bExist = false;
+
+ while (pVar->empty() == false)
+ {
+ stack.push(pVar->top());
+ pVar->pop();
+ }
+
+ if (stack.empty() == false)
+ {
+ symbol::ScopedVariable* pSV = stack.top();
+ if (pSV->m_iLevel == 0 && pSV->m_pIT->isFunction())
+ {
+ bExist = true;
+ }
+
+ //move all elements at orginal place and order
+ while (stack.empty() == false)
+ {
+ pSV = stack.top();
+ stack.pop();
+ pSV->m_pIT->DecreaseRef();
+ pVar->put(pSV->m_pIT, pSV->m_iLevel);
+ delete pSV;
+ }
+ }
+
+ if (bExist)
+ {
+ out.push_back(new String(pwcsName));
+ }
+ else
+ {
+ out.push_back(new Double(0));
+ }
+
+ return Function::OK;
+}
\ No newline at end of file
--- /dev/null
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
+*
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution. The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+*
+*/
+
+#include "core_gw.hxx"
+#include "configvariable.hxx"
+#include "double.hxx"
+#include "string.hxx"
+#include "function.hxx"
+#include "context.hxx"
+
+extern "C"
+{
+#include "Scierror.h"
+#include "localization.h"
+}
+
+using namespace types;
+/*--------------------------------------------------------------------------*/
+bool isValidName(wchar_t* _pwstName)
+{
+ if (_pwstName == NULL)
+ {
+ return false;
+ }
+
+ if (isdigit(_pwstName[0]))
+ {
+ return false;
+ }
+
+ int size = (int)wcslen(_pwstName);
+ for (int i = 1 ; i < size ; ++i)
+ {
+ wchar_t c = _pwstName[i];
+ if (c != L'_' && c != L'?' && c != L'!' && isalnum(c) == false)
+ {
+ return false;
+ }
+
+ }
+ return true;
+}
+/*--------------------------------------------------------------------------*/
+Function::ReturnValue sci_newfun(types::typed_list &in, int _iRetCount, types::typed_list &out)
+{
+ if (in.size() != 2)
+ {
+ Scierror(999, _("%s: Wrong number of input arguments: %d expected.\n"), "newfun" , 2);
+ return Function::Error;
+ }
+
+ InternalType* pIT1 = in[0];
+ InternalType* pIT2 = in[1];
+
+ if (pIT1->isString() == false)
+ {
+ Scierror(999, _("%s: Wrong type for input argument #%d: String expected.\n"), "newfun", 1);
+ return Function::Error;
+ }
+
+ String* pS1 = pIT1->getAs<String>();
+ if (pS1->isScalar() == false)
+ {
+ Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), "newfun", 1);
+ return Function::Error;
+ }
+
+ wchar_t* pwcsNewName = pS1->get(0);
+
+ //check is a valid name
+ if (isValidName(pwcsNewName) == false)
+ {
+ Scierror(999, _("%s: Wrong value for input argument #%d: Valid function name expected.\n"), "newfun", 1);
+ return Function::Error;
+ }
+
+ if (pIT2->isString() == false)
+ {
+ Scierror(999, _("%s: Wrong type for input argument #%d: String expected.\n"), "newfun", 2);
+ return Function::Error;
+ }
+
+ String* pS2 = pIT2->getAs<String>();
+ if (pS2->isScalar() == false)
+ {
+ Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), "newfun", 2);
+ return Function::Error;
+ }
+
+ wchar_t* pwcsName = pS2->get(0);
+
+ Function* pFunc = NULL;
+ symbol::Context* pCtx = symbol::Context::getInstance();
+
+ symbol::Variable* pVar = pCtx->getOrCreate(symbol::Symbol(pwcsName));
+ symbol::Variable::StackVar stack;
+
+ //get original function
+
+ //unstack all elements and stack them in new stack ( reverse order )
+ while (pVar->empty() == false)
+ {
+ stack.push(pVar->top());
+ pVar->pop();
+ }
+
+ if (stack.empty() == false)
+ {
+ symbol::ScopedVariable* pSV = stack.top();
+ if (pSV->m_iLevel == 0 && pSV->m_pIT->isFunction())
+ {
+ pFunc = pSV->m_pIT->getAs<Function>();
+ }
+
+ //move all elements at orginal place and order
+ while (stack.empty() == false)
+ {
+ pSV = stack.top();
+ stack.pop();
+ pSV->m_pIT->DecreaseRef();
+ pVar->put(pSV->m_pIT, pSV->m_iLevel);
+ delete pSV;
+ }
+ }
+
+ if (pFunc == NULL)
+ {
+ Scierror(999, _("%s: function-name is incorrect.\n"), "newfun");
+ return Function::Error;
+ }
+
+ //new function
+ pVar = pCtx->getOrCreate(symbol::Symbol(pwcsNewName));
+ if (pVar->empty())
+ {
+ pVar->put(pFunc, 0);
+ }
+ else
+ {
+ //unstack all elements and stack them in new stack ( reverse order )
+ while (pVar->empty() == false)
+ {
+ stack.push(pVar->top());
+ pVar->pop();
+ }
+
+ symbol::ScopedVariable* pSV = stack.top();
+ if (pSV->m_iLevel == 0)
+ {
+ stack.pop();
+ //clear current var and insert new one
+ InternalType* pIT = pSV->m_pIT;
+ pIT->DecreaseRef();
+ pIT->killMe();
+ }
+
+ pVar->put(pFunc, 0);
+
+ //move all elements at orginal place and order
+ while (stack.empty() == false)
+ {
+ pSV = stack.top();
+ stack.pop();
+ pSV->m_pIT->DecreaseRef();
+ pVar->put(pSV->m_pIT, pSV->m_iLevel);
+ delete pSV;
+ }
+ }
+ return Function::OK;
+}
+/*--------------------------------------------------------------------------*/
//================================================
ptr = funptr('pwd');
newfun("MY_PWD",ptr);
-if clearfun("MY_PWD") <> %T then bugmes();quit;end
+assert_checktrue(clearfun("MY_PWD"));
//================================================
-ierr = execstr('a = clearfun(2);','errcatch');
-if ierr <> 999 then bugmes();quit;end
+errmsg = msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"), "clearfun", 1);
+assert_checkerror('a = clearfun(2);', errmsg);
ptr = funptr('pwd');
newfun("MY_PWD",ptr);
-if clearfun("MY_PWD") <> %T then pause,end
+assert_checktrue(clearfun("MY_PWD"));
//================================================
-
-ierr = execstr('a = clearfun(2);','errcatch');
-if ierr <> 999 then pause,end
+errmsg = msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"), "clearfun", 1);
+assert_checkerror('a = clearfun(2);', errmsg);
//================================================
// test funptr
//================================================
-ptr = funptr('pwd');
-if ptr <> 34031 then bugmes();quit;end
-ierr = execstr('ptr = funptr(1)','errcatch');
-if ierr <> 999 then bugmes();quit;end
+errmsg = msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"), "funptr", 1);
+assert_checkerror('ptr = funptr(1)', errmsg);
+ptr = funptr("pwd");
+assert_checkequal(ptr, "pwd");
ptr = funptr('FCT_NOT_IN_SCILAB');
-if ptr <> 0 then bugmes();quit;end
+assert_checkequal(ptr, 0);
//================================================
//================================================
// test funptr
//================================================
-ptr = funptr('pwd');
-if ptr <> 34031 then pause,end
+errmsg = msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"), "funptr", 1);
+assert_checkerror('ptr = funptr(1)', errmsg);
-ierr = execstr('ptr = funptr(1)','errcatch');
-if ierr <> 999 then pause,end
+ptr = funptr("pwd");
+assert_checkequal(ptr, "pwd");
ptr = funptr('FCT_NOT_IN_SCILAB');
-if ptr <> 0 then pause,end
+assert_checkequal(ptr, 0);
//================================================
// =============================================================================
fptr_cos = funptr("cos");
newfun("cosAlias",fptr_cos);
-if cos(2*%pi) <> cosAlias(2*%pi) then bugmes();quit;end
-if clearfun("cosAlias") <> %T then bugmes();quit;end
+assert_checkequal(cos(2*%pi), cosAlias(2*%pi));
+assert_checktrue(clearfun("cosAlias"));
if execstr("cosAlias(2*%pi)","errcatch") == 0 then bugmes();quit;end
-ierr = execstr('newfun(''more_than_twenty_four_characters_function_name'',fptr_cos)','errcatch');
-if ierr <> 999 then bugmes();quit;end
-ierr = execstr('newfun(''1_function_name'',fptr_cos)','errcatch');
-if ierr <> 999 then bugmes();quit;end
-ierr = execstr('newfun(''new_function_name'',[fptr_cos,fptr_cos])','errcatch');
-if ierr <> 999 then bugmes();quit;end
-ierr = execstr('newfun([''new_function_name'',''new_function_name''],[fptr_cos,fptr_cos])','errcatch');
-if ierr <> 999 then bugmes();quit;end
-ierr = execstr('newfun(1,[fptr_cos,fptr_cos])','errcatch');
-if ierr <> 999 then bugmes();quit;end
-ierr = execstr('newfun(1,''fptr_cos'')','errcatch');
-if ierr <> 999 then bugmes();quit;end
+errmsg = msprintf(gettext("%s: Wrong value for input argument #%d: Valid function name expected.\n"), "newfun", 1);
+assert_checkerror('newfun(''1_function_name'',fptr_cos)', errmsg);
+errmsg = msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n"), "newfun", 2);
+assert_checkerror('newfun(''new_function_name'',[fptr_cos,fptr_cos])', errmsg);
+errmsg = msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n"), "newfun", 1);
+assert_checkerror('newfun([''new_function_name'',''new_function_name''],[fptr_cos,fptr_cos])', errmsg);
+errmsg = msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"), "newfun", 1);
+assert_checkerror('newfun(1,[fptr_cos,fptr_cos])', errmsg);
+function test_1(x)
+ newfun(x, "cos");
+ assert_checkequal(eval(x + "(1)"), cos(1));
+endfunction
+test_1("cosAlias");
+assert_checkequal(cosAlias(1), cos(1));
+assert_checktrue(clearfun("cosAlias"));
+function test_2(x)
+ test_1(x);
+ assert_checkequal(eval(x + "(1)"), cos(1));
+endfunction
+test_2("cosAlias");
+assert_checkequal(cosAlias(1), cos(1));
+assert_checktrue(clearfun("cosAlias"));
+function test_3(x)
+ test_2(x);
+ assert_checkequal(eval(x + "(1)"), cos(1));
+endfunction
+test_3("cosAlias");
+assert_checkequal(cosAlias(1), cos(1));
+assert_checktrue(clearfun("cosAlias"));
+myvar = 3;
+newfun("myvar", fptr_cos);
+assert_checkequal(myvar, 3);
+clear myvar
+assert_checkequal(myvar(0), cos(0));
//
// This file is distributed under the same license as the Scilab package.
// =============================================================================
-
fptr_cos = funptr("cos");
newfun("cosAlias",fptr_cos);
-if cos(2*%pi) <> cosAlias(2*%pi) then pause,end
-if clearfun("cosAlias") <> %T then pause,end
+assert_checkequal(cos(2*%pi), cosAlias(2*%pi));
+assert_checktrue(clearfun("cosAlias"));
if execstr("cosAlias(2*%pi)","errcatch") == 0 then pause,end
-ierr = execstr('newfun(''more_than_twenty_four_characters_function_name'',fptr_cos)','errcatch');
-if ierr <> 999 then pause,end
+errmsg = msprintf(gettext("%s: Wrong value for input argument #%d: Valid function name expected.\n"), "newfun", 1);
+assert_checkerror('newfun(''1_function_name'',fptr_cos)', errmsg);
+
+errmsg = msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n"), "newfun", 2);
+assert_checkerror('newfun(''new_function_name'',[fptr_cos,fptr_cos])', errmsg);
+
+errmsg = msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n"), "newfun", 1);
+assert_checkerror('newfun([''new_function_name'',''new_function_name''],[fptr_cos,fptr_cos])', errmsg);
+
+errmsg = msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"), "newfun", 1);
+assert_checkerror('newfun(1,[fptr_cos,fptr_cos])', errmsg);
+
+function test_1(x)
+ newfun(x, "cos");
+ assert_checkequal(eval(x + "(1)"), cos(1));
+endfunction
+
+test_1("cosAlias");
+assert_checkequal(cosAlias(1), cos(1));
+assert_checktrue(clearfun("cosAlias"));
+
+function test_2(x)
+ test_1(x);
+ assert_checkequal(eval(x + "(1)"), cos(1));
+endfunction
-ierr = execstr('newfun(''1_function_name'',fptr_cos)','errcatch');
-if ierr <> 999 then pause,end
+test_2("cosAlias");
+assert_checkequal(cosAlias(1), cos(1));
+assert_checktrue(clearfun("cosAlias"));
-ierr = execstr('newfun(''new_function_name'',[fptr_cos,fptr_cos])','errcatch');
-if ierr <> 999 then pause,end
+function test_3(x)
+ test_2(x);
+ assert_checkequal(eval(x + "(1)"), cos(1));
+endfunction
-ierr = execstr('newfun([''new_function_name'',''new_function_name''],[fptr_cos,fptr_cos])','errcatch');
-if ierr <> 999 then pause,end
+test_3("cosAlias");
+assert_checkequal(cosAlias(1), cos(1));
+assert_checktrue(clearfun("cosAlias"));
-ierr = execstr('newfun(1,[fptr_cos,fptr_cos])','errcatch');
-if ierr <> 999 then pause,end
-ierr = execstr('newfun(1,''fptr_cos'')','errcatch');
-if ierr <> 999 then pause,end
+myvar = 3;
+newfun("myvar", fptr_cos);
+assert_checkequal(myvar, 3);
+clear myvar
+assert_checkequal(myvar(0), cos(0));
stk(top)=list(op(2),"0")
m=%f
elseif type(stk(top)(1))==10 then
- testOK = (op(4)=="1" & ~funptr(op(2)) & ~exists(op(2)))
+ testOK = (op(4)=="1" & funptr(op(2)) == 0 & ~exists(op(2)))
if ~testOK then
testOK = execstr("tmp = evstr(op(2))", "errcatch")==0
if testOK