some missing features

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@11962 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Baozeng Ding 2010-04-02 07:55:17 +00:00
commit 57c3d28aaf
4 changed files with 467 additions and 21 deletions

View file

@ -0,0 +1,6 @@
/* File: example.h */
typedef struct {
int x,y;
} Point;

View file

@ -16,7 +16,7 @@ fvar_set (3.14159);
dvar_set (2.1828); dvar_set (2.1828);
strvar_set("Hello World"); strvar_set("Hello World");
iptrvar= new_int(37); //iptrvar= new_int(37);
ptptr = new_Point(37,42); ptptr = new_Point(37,42);
name_set ("Bill"); name_set ("Bill");
// Now print out the values of the variables // Now print out the values of the variables
@ -36,7 +36,7 @@ printf("dvar = %f\n", dvar_get());
printf("cvar = %s\n", cvar_get()); printf("cvar = %s\n", cvar_get());
printf("strvar = %s\n", strvar_get()); printf("strvar = %s\n", strvar_get());
iptrvar //iptrvar
printf("name = %s\n", name_get()); printf("name = %s\n", name_get());
printf("ptptr = %s\n", Point_print(ptptr)); printf("ptptr = %s\n", Point_print(ptptr));
printf("\nVariables (values printed from C)\n"); printf("\nVariables (values printed from C)\n");

File diff suppressed because it is too large Load diff

View file

@ -60,6 +60,7 @@ or you can use the %apply directive :
unsigned long *INPUT (int *piAddrVar, int iRows, int iCols, unsigned long temp), unsigned long *INPUT (int *piAddrVar, int iRows, int iCols, unsigned long temp),
float *INPUT (int *piAddrVar, int iRows, int iCols, float temp), float *INPUT (int *piAddrVar, int iRows, int iCols, float temp),
double *INPUT (int *piAddrVar, int iRows, int iCols, double temp) { double *INPUT (int *piAddrVar, int iRows, int iCols, double temp) {
int iType;
double *_piData; double *_piData;
int typearg; int typearg;
sciErr = getVarAddressFromPosition(pvApiCtx, $argnum, &piAddrVar); sciErr = getVarAddressFromPosition(pvApiCtx, $argnum, &piAddrVar);
@ -68,11 +69,19 @@ or you can use the %apply directive :
return 0; return 0;
} }
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
if (sciErr.iErr || iType != sci_matrix) {
Scierror(999, _("%s: Wrong type for input argument #%d: A real expected.\n"), fname, $argnum);
printError(&sciErr, 0);
return 0;
}
sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &_piData); sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &_piData);
if (sciErr.iErr) { if (sciErr.iErr || iRows * iCols != 1) {
printError(&sciErr, 0); Scierror(999, _("%s: Wrong size for input argument #%d: A real expected.\n"), fname, $argnum);
return 0; printError(&sciErr, 0);
} return 0;
}
temp = ($*1_ltype)*_piData; temp = ($*1_ltype)*_piData;
$1 = &temp; $1 = &temp;
} }