Skip to content

Commit

Permalink
improve support of varargs
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Marchetto committed Jun 23, 2015
1 parent 05cfa06 commit b05f005
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Lib/scilab/scirun.swg
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,13 @@ static void SWIG_Scilab_SetApiContext(void *apiCtx) {

#if SWIG_SCILAB_VERSION >= 540
#define SWIG_CheckInputArgument(pvApiCtx, minInputArgument, maxInputArgument) CheckInputArgument(pvApiCtx, minInputArgument, maxInputArgument)
#define SWIG_CheckInputArgumentAtLeast(pvApiCtx, minInputArgument) CheckInputArgumentAtLeast(pvApiCtx, minInputArgument)
#define SWIG_CheckOutputArgument(pvApiCtx, minOutputArgument, maxOutputArgument) CheckOutputArgument(pvApiCtx, minOutputArgument, maxOutputArgument)
#define SWIG_NbInputArgument(pvApiCtx) nbInputArgument(pvApiCtx)
#define SWIG_AssignOutputArgument(pvApiCtx, outputArgumentPos, argumentPos) AssignOutputVariable(pvApiCtx, outputArgumentPos) = argumentPos
#else
#define SWIG_CheckInputArgument(pvApiCtx, minInputArgument, maxInputArgument) CheckRhs(minInputArgument, maxInputArgument)
#define SWIG_CheckInputArgumentAtLeast(pvApiCtx, minInputArgument) CheckRhs(minInputArgument, 256)
#define SWIG_CheckOutputArgument(pvApiCtx, minOutputArgument, maxOutputArgument) CheckLhs(minOutputArgument, maxOutputArgument)
#define SWIG_NbInputArgument(pvApiCtx) Rhs
#define SWIG_AssignOutputArgument(pvApiCtx, outputArgumentPos, argumentPos) LhsVar(outputArgumentPos) = argumentPos
Expand Down
10 changes: 7 additions & 3 deletions Source/Modules/scilab.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,18 @@ class SCILAB:public Language {
emit_attach_parmmaps(functionParamsList, wrapper);
Setattr(node, "wrap:parms", functionParamsList);

/* Check arguments */
/* Check input/output arguments count */
int maxInputArguments = emit_num_arguments(functionParamsList);
int minInputArguments = emit_num_required(functionParamsList);
int minOutputArguments = 0;
int maxOutputArguments = 0;

/* Insert calls to CheckInputArgument and CheckOutputArgument */
Printf(wrapper->code, "SWIG_CheckInputArgument(pvApiCtx, $mininputarguments, $maxinputarguments);\n");
if (!emit_isvarargs(functionParamsList)) {
Printf(wrapper->code, "SWIG_CheckInputArgument(pvApiCtx, $mininputarguments, $maxinputarguments);\n");
}
else {
Printf(wrapper->code, "SWIG_CheckInputArgumentAtLeast(pvApiCtx, $mininputarguments-1);\n");
}
Printf(wrapper->code, "SWIG_CheckOutputArgument(pvApiCtx, $minoutputarguments, $maxoutputarguments);\n");

/* Set context */
Expand Down

0 comments on commit b05f005

Please sign in to comment.