Scilab: add %feature scilab:const (constants are wrapped by Scilab variables)
This commit is contained in:
parent
fcfb90219e
commit
2cf606c638
10 changed files with 159 additions and 17 deletions
|
|
@ -252,3 +252,37 @@ SwigScilabStringFromCharPtrArray(void *_pvApiCtx, int _iVarOut, char **_charPtrA
|
|||
return SWIG_NbInputArgument(pvApiCtx) + _iVarOut;
|
||||
}
|
||||
}
|
||||
%fragment(SWIG_CreateScilabVariable_frag(char), "wrapper") {
|
||||
SWIGINTERN int
|
||||
SWIG_CreateScilabVariable_dec(char)(void *_pvApiCtx, const char* _psVariableName, const char _cVariableValue) {
|
||||
SciErr sciErr;
|
||||
char sValue[2];
|
||||
const char* psStrings[1];
|
||||
|
||||
sValue[0] = _cVariableValue;
|
||||
sValue[1] = '\0';
|
||||
psStrings[0] = sValue;
|
||||
|
||||
sciErr = createNamedMatrixOfString(_pvApiCtx, _psVariableName, 1, 1, psStrings);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
%fragment(SWIG_CreateScilabVariable_frag(charptr), "wrapper") {
|
||||
SWIGINTERN int
|
||||
SWIG_CreateScilabVariable_dec(charptr)(void *_pvApiCtx, const char* _psVariableName, const char* _psVariableValue) {
|
||||
SciErr sciErr;
|
||||
const char* psStrings[1];
|
||||
psStrings[0] = _psVariableValue;
|
||||
|
||||
sciErr = createNamedMatrixOfString(_pvApiCtx, _psVariableName, 1, 1, psStrings);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,3 +118,15 @@ SWIG_SciDouble_FromDoubleArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows,
|
|||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
%fragment(SWIG_CreateScilabVariable_frag(double), "wrapper") {
|
||||
SWIGINTERN int
|
||||
SWIG_CreateScilabVariable_dec(double)(void *_pvApiCtx, const char* _psVariableName, const double _dVariableValue) {
|
||||
SciErr sciErr;
|
||||
sciErr = createNamedMatrixOfDouble(_pvApiCtx, _psVariableName, 1, 1, &_dVariableValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,3 +196,15 @@ SWIG_SciInt32_FromIntArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows, int
|
|||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
%fragment(SWIG_CreateScilabVariable_frag(int), "wrapper") {
|
||||
SWIGINTERN int
|
||||
SWIG_CreateScilabVariable_dec(int)(void *_pvApiCtx, const char* _psVariableName, const int _iVariableValue) {
|
||||
SciErr sciErr;
|
||||
sciErr = createNamedMatrixOfInteger32(_pvApiCtx, _psVariableName, 1, 1, &_iVariableValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
%include <typemaps/swigmacros.swg>
|
||||
%include <typemaps/fragments.swg>
|
||||
%include <scimacros.swg>
|
||||
%include <sciruntime.swg>
|
||||
%include <scitypemaps.swg>
|
||||
|
||||
|
|
|
|||
5
Lib/scilab/scimacros.swg
Normal file
5
Lib/scilab/scimacros.swg
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#define %scilabconst(flag) %feature("scilab:const","flag")
|
||||
|
||||
// Create Scilab variable
|
||||
#define SWIG_CreateScilabVariable_frag(Type...) %fragment_name(CreateScilabVariable, Type)
|
||||
#define SWIG_CreateScilabVariable_dec(Type...) %symbol_name(CreateScilabVariable, Type)
|
||||
|
|
@ -78,7 +78,6 @@ SWIG_Scilab_ErrorMsg(int code, const char *mesg)
|
|||
/* Used for C++ enums */
|
||||
//#define SWIG_AsVal_int(scilabValue, valuePointer) SWIG_SciDouble_AsInt(pvApiCtx, scilabValue, valuePointer, fname)
|
||||
|
||||
|
||||
#if SCILAB_VERSION_54_OR_HIGHER
|
||||
#define SWIG_CheckInputArgument(pvApiCtx, minInputArgument, maxInputArgument) CheckInputArgument(pvApiCtx, minInputArgument, maxInputArgument)
|
||||
#define SWIG_CheckOutputArgument(pvApiCtx, minOutputArgument, maxOutputArgument) CheckOutputArgument(pvApiCtx, minOutputArgument, maxOutputArgument)
|
||||
|
|
@ -272,6 +271,8 @@ SWIG_Scilab_SetModule(swig_module_info *swig_module)
|
|||
%init %{
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
int SWIG_Init(char *fname, unsigned long fname_len) {
|
||||
SWIG_InitializeModule(NULL);
|
||||
SWIG_CreateScilabVariables();
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -376,3 +376,31 @@
|
|||
%typecheck(SWIG_TYPECHECK_STRING_ARRAY) char ** { SCILAB_TYPECHECK(isStringType) }
|
||||
|
||||
//%apply int { size_t };
|
||||
|
||||
/* -----------------------------------------------------------------------------*/
|
||||
/* Constants
|
||||
/* -----------------------------------------------------------------------------*/
|
||||
|
||||
%typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(int)) int
|
||||
%{
|
||||
if (SWIG_CreateScilabVariable_int(pvApiCtx, "$result", $value) != SWIG_OK)
|
||||
return SWIG_ERROR;
|
||||
%}
|
||||
|
||||
%typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(double)) double
|
||||
%{
|
||||
if (SWIG_CreateScilabVariable_double(pvApiCtx, "$result", $value) != SWIG_OK)
|
||||
return SWIG_ERROR;
|
||||
%}
|
||||
|
||||
%typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(char)) char
|
||||
%{
|
||||
if (SWIG_CreateScilabVariable_char(pvApiCtx, "$result", $value) != SWIG_OK)
|
||||
return SWIG_ERROR;
|
||||
%}
|
||||
|
||||
%typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(charptr)) char *
|
||||
%{
|
||||
if (SWIG_CreateScilabVariable_charptr(pvApiCtx, "$result", $value) != SWIG_OK)
|
||||
return SWIG_ERROR;
|
||||
%}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue