Many modifications needed to make allprotected test work
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12369 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
adcb79c680
commit
ee812c1c86
4 changed files with 241 additions and 25 deletions
118
Lib/scilab/sciprimtypes.swg
Normal file
118
Lib/scilab/sciprimtypes.swg
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
%fragment("SWIG_AsCharPtrAndSize","header") {
|
||||
SWIGINTERN int
|
||||
SWIG_AsCharPtrAndSize(int iPos, char** cptr, size_t* psize, int *alloc)
|
||||
{
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int *piAddrVar = NULL;
|
||||
char *_pstStrings = NULL;
|
||||
int _piLength = 0;
|
||||
int iCols = 0;
|
||||
int iRows = 0;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iPos, &piAddrVar);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr || iType != sci_strings)
|
||||
{
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), "SWIG_AsCharPtrAndSize", iPos);
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, &_piLength, NULL);
|
||||
if (sciErr.iErr || iRows * iCols != 1)
|
||||
{
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), "SWIG_AsCharPtrAndSize", iPos);
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
|
||||
_pstStrings = (char *)malloc(sizeof(char) * _piLength + 1);
|
||||
sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, &_piLength, (char**)&_pstStrings);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (cptr)
|
||||
{
|
||||
*cptr = _pstStrings;
|
||||
}
|
||||
if (psize)
|
||||
{
|
||||
*psize = _piLength + 1;
|
||||
}
|
||||
if (alloc)
|
||||
{
|
||||
*alloc = SWIG_OLDOBJ;
|
||||
}
|
||||
return SWIG_OK;
|
||||
|
||||
}
|
||||
}
|
||||
%fragment("SWIG_FromCharPtrAndSize","header") {
|
||||
SWIGINTERNINLINE int
|
||||
SWIG_FromCharPtrAndSize(const char* carray, size_t size)
|
||||
{
|
||||
SciErr sciErr;
|
||||
int iVarOut = Rhs + 1; // TODO is this always true?
|
||||
sciErr = createMatrixOfString(pvApiCtx, iVarOut, 1, 1, (char **)&carray);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_frag(long),"header") {
|
||||
SWIGINTERN int SWIG_AsVal_dec(long)(int iPos, long* val)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*%fragment(SWIG_AsPtr_frag(std::string),"header") {
|
||||
SWIGINTERN int
|
||||
SWIG_AsPtr_std_string(int iPos, std::string **val)
|
||||
{
|
||||
char* buf = 0;
|
||||
size_t size = 0;
|
||||
int alloc = SWIG_OLDOBJ;
|
||||
|
||||
if (SWIG_IsOK((SWIG_AsCharPtrAndSize(iPos, &buf, &size, &alloc))))
|
||||
{
|
||||
if (buf)
|
||||
{
|
||||
if (val)
|
||||
{
|
||||
*val = new std::string(buf, size - 1);
|
||||
}
|
||||
if (alloc == SWIG_NEWOBJ)
|
||||
{
|
||||
delete[] buf;
|
||||
}
|
||||
return SWIG_NEWOBJ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (val)
|
||||
{
|
||||
*val = 0;
|
||||
}
|
||||
return SWIG_OLDOBJ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
|
@ -24,5 +24,54 @@ void SWIG_Error(int code, const char *msg)
|
|||
#endif
|
||||
|
||||
#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(999, msg); } else
|
||||
#define SWIG_fail return 0
|
||||
|
||||
#define SWIG_ConvertPtr(obj, vptr, descriptor, flags) SWIG_Scilab_ConvertPtr(pvApiCtx, obj, vptr, descriptor, flags)
|
||||
#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Scilab_NewPointerObj(pvApiCtx, iVarOut, ptr, type, flags)
|
||||
|
||||
/* Convert a pointer value */
|
||||
SWIGRUNTIMEINLINE int
|
||||
SWIG_Scilab_ConvertPtr(StrCtx* pvApiCtx, int obj, void **ptr, swig_type_info* descriptor, int flags) {
|
||||
SciErr sciErr;
|
||||
int* piAddrVar = NULL;
|
||||
int iType = 0;
|
||||
void *_piData = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piAddrVar);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr || iType != sci_pointer)
|
||||
{
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: Pointer expected.\n"), "SWIG_Scilab_ConvertPtr", obj);
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getPointer(pvApiCtx, piAddrVar, ptr);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
/* Create a new pointer object */
|
||||
SWIGRUNTIMEINLINE int
|
||||
SWIG_Scilab_NewPointerObj(StrCtx* pvApiCtx, int iVarOut, void *ptr, swig_type_info *type, int flags) {
|
||||
SciErr sciErr;
|
||||
sciErr = createPointer(pvApiCtx, iVarOut, (void *)ptr);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return 0;
|
||||
}
|
||||
return iVarOut;
|
||||
}
|
||||
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,25 @@
|
|||
// Scilab fragments for primitive types
|
||||
%include <sciprimtypes.swg>
|
||||
|
||||
// Include fundamental fragments definitions
|
||||
%include <typemaps/fragments.swg>
|
||||
// Scilab types
|
||||
#define SWIG_Object int
|
||||
#define VOID_Object int
|
||||
|
||||
// Append output
|
||||
#define SWIG_AppendOutput(result, obj) SWIG_Scilab_AppendOutput(result, obj)
|
||||
|
||||
// Set constant
|
||||
#define SWIG_SetConstant(name, obj) SWIG_Scilab_SetConstant(module_ns,name,obj)
|
||||
|
||||
// Raise
|
||||
#define SWIG_Scilab_Raise(OBJ, TYPE, DESC) error("C++ side threw an exception of type " TYPE)
|
||||
#define SWIG_Raise(obj, type, desc) SWIG_Scilab_Raise(obj, type, desc)
|
||||
|
||||
// Include the unified typemap library
|
||||
%include <typemaps/swigtypemaps.swg>
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* --- Input arguments ---
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -121,7 +143,7 @@
|
|||
$1 = ($1_ltype)_piData;
|
||||
}
|
||||
|
||||
%typemap(in) char * (int iRows, int iCols) {
|
||||
/*%typemap(in) char * (int iRows, int iCols) {
|
||||
int iType = 0;
|
||||
int *piAddrVar = NULL;
|
||||
char *_pstStrings = NULL;
|
||||
|
|
@ -160,7 +182,7 @@
|
|||
$1 = ($1_ltype)strdup(_pstStrings);
|
||||
|
||||
free(_pstStrings);
|
||||
}
|
||||
}*/
|
||||
|
||||
%define SCILAB_IN_INTEGERVECTOR(CTYPE, INTTYPE, SCIAPIFUNCTION)
|
||||
int iPrec = 0;
|
||||
|
|
@ -479,7 +501,7 @@
|
|||
$1 = ($1_ltype)*_piData;
|
||||
}
|
||||
|
||||
%typemap(in) SWIGTYPE *,
|
||||
/*%typemap(in) SWIGTYPE *,
|
||||
SWIGTYPE [] {
|
||||
int iType = 0;
|
||||
int *piAddrVar = NULL;
|
||||
|
|
@ -507,7 +529,7 @@
|
|||
return 0;
|
||||
}
|
||||
$1 = ($1_ltype)_piData;
|
||||
}
|
||||
}*/
|
||||
|
||||
%typemap(in) SWIGTYPE {
|
||||
int iType = 0;
|
||||
|
|
@ -689,7 +711,7 @@
|
|||
iVarOut++;
|
||||
}
|
||||
|
||||
%typemap(out) SWIGTYPE * {
|
||||
/*%typemap(out) SWIGTYPE * {
|
||||
sciErr = createPointer(pvApiCtx, iVarOut, (void *)$result);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
|
|
@ -700,9 +722,9 @@
|
|||
LhsVar(iOutNum) = iVarOut;
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
}*/
|
||||
|
||||
%typemap(out) SWIGTYPE {
|
||||
/*%typemap(out) SWIGTYPE {
|
||||
sciErr = createPointer(pvApiCtx, iVarOut, %new_copy($result, $1_ltype));
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
|
|
@ -713,7 +735,7 @@
|
|||
LhsVar(iOutNum) = iVarOut;
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
}*/
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* --- Variable input ---
|
||||
|
|
@ -898,7 +920,7 @@
|
|||
return 0;
|
||||
}
|
||||
|
||||
for (ii = 0; ii < (size_t)$1_dim0; ii++)
|
||||
for (ii = 0; ii < (size_t) (iRows * iCols); ii++)
|
||||
{
|
||||
$1[ii] = ($*1_ltype)_piData[ii];
|
||||
}
|
||||
|
|
@ -1010,7 +1032,7 @@
|
|||
}
|
||||
|
||||
_piLength = (int*)malloc(sizeof(int) * iRows * iCols);
|
||||
sciErr = getMatrixOfString(pvApiCtxpiAddrVar, &iRows, &iCols, _piLength, NULL);
|
||||
sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, _piLength, NULL);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
|
|
@ -1389,12 +1411,23 @@
|
|||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
%typemap(varout,noblock=1) int [ANY] {
|
||||
sciErr = createMatrixOfInteger32(pvApiCtx, iVarOut, 1, $1_dim0, (int *)$result);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LhsVar(iOutNum) = iVarOut;
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
%typemap(varout,noblock=1) signed char [ANY] { SCILAB_VAROUT(char, createMatrixOfInteger8, 1, $1_dim0) }
|
||||
%typemap(varout,noblock=1) unsigned char [ANY] { SCILAB_VAROUT(unsigned char, createMatrixOfUnsignedInteger8, 1, $1_dim0) }
|
||||
%typemap(varout,noblock=1) short [ANY] { SCILAB_VAROUT(short, createMatrixOfInteger16, 1, $1_dim0) }
|
||||
%typemap(varout,noblock=1) unsigned short [ANY] { SCILAB_VAROUT(unsigned short, createMatrixOfUnsignedInteger16, 1, $1_dim0) }
|
||||
%typemap(varout,noblock=1) int [ANY], long [ANY] { SCILAB_VAROUT(int, createMatrixOfInteger32, 1, $1_dim0) }
|
||||
//%typemap(varout,noblock=1) int [ANY], long [ANY] { SCILAB_VAROUT(int, createMatrixOfInteger32, 1, $1_dim0) }
|
||||
%typemap(varout,noblock=1) unsigned int [ANY], unsigned long [ANY] { SCILAB_VAROUT(int, createMatrixOfUnsignedInteger32, 1, $1_dim0) }
|
||||
%typemap(varout,noblock=1) long long [ANY] { SCILAB_VAROUT(long long, createMatrixOfInteger64, 1, $1_dim0) }
|
||||
%typemap(varout,noblock=1) unsigned long long [ANY] { SCILAB_VAROUT(unsigned long long, createMatrixOfUnsignedInteger64, 1, $1_dim0) }
|
||||
|
|
|
|||
|
|
@ -239,9 +239,15 @@ public:
|
|||
Setattr(p, "emit:input", source);
|
||||
Replaceall(tm, "$input", Getattr(p, "emit:input"));
|
||||
|
||||
if (Getattr(p, "wrap:disown") || (Getattr(p, "tmap:in:disown"))) {
|
||||
Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN");
|
||||
} else {
|
||||
Replaceall(tm, "$disown", "0");
|
||||
}
|
||||
|
||||
String *getargs = NewString("");
|
||||
|
||||
/* The paremeter is variable */
|
||||
/* The parameter is variable */
|
||||
if (j >= num_required) {
|
||||
Printf(getargs, "if (Rhs > %d) {\n%s\n}", j, tm);
|
||||
} else {
|
||||
|
|
@ -270,19 +276,30 @@ public:
|
|||
/* Insert the return variable */
|
||||
emit_return_variable(n, d, f);
|
||||
|
||||
Wrapper_add_local(f, "_outv", "int _outv");
|
||||
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
Replaceall(tm, "$result", "result");
|
||||
|
||||
/* There are more than one output */
|
||||
if (out_required > 0) {
|
||||
Printf(f->code, "LhsVar(iOutNum) = iVarOut;\n");
|
||||
Printf(f->code, "iOutNum ++;\niVarOut ++;\n");
|
||||
}
|
||||
Printf(f->code, "%s\n", tm);
|
||||
if (strlen(Char(tm)) != 0) {
|
||||
out_required ++;
|
||||
}
|
||||
}
|
||||
Replaceall(tm, "$source", "result");
|
||||
Replaceall(tm, "$target", "_outv");
|
||||
Replaceall(tm, "$result", "_outv");
|
||||
|
||||
if (GetFlag(n, "feature:new"))
|
||||
Replaceall(tm, "$owner", "1");
|
||||
else
|
||||
Replaceall(tm, "$owner", "0");
|
||||
|
||||
/* There are more than one output */
|
||||
if (out_required > 0) {
|
||||
Printf(f->code, "LhsVar(iOutNum) = iVarOut;\n");
|
||||
Printf(f->code, "iOutNum ++;\niVarOut ++;\n");
|
||||
}
|
||||
Printf(f->code, "%s\n", tm);
|
||||
if ((strlen(Char(tm)) != 0) && (out_required <= 0)) {
|
||||
Printf(f->code, "LhsVar(iOutNum) = iVarOut;\n");
|
||||
Printf(f->code, "iOutNum ++;\niVarOut ++;\n");
|
||||
out_required ++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(d, 0), iname);
|
||||
}
|
||||
|
|
@ -356,7 +373,6 @@ public:
|
|||
|
||||
/* Finish the the code for the function */
|
||||
//if (flag)
|
||||
Printf(f->code, "//PutLhsVar();\n");
|
||||
Printf(f->code, "return 0;\n");
|
||||
Printf(f->code, "}\n");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue