Commit 318c6a60 authored by Brad King's avatar Brad King
Browse files

ENH: Adding bool support to VTK wrappers.

parent e93e5562
......@@ -834,6 +834,32 @@ JNIEXPORT jarray vtkJavaMakeJArrayOfCharFromChar(JNIEnv *env, char *ptr, int siz
return ret;
}
JNIEXPORT jarray vtkJavaMakeJArrayOfIntFromBool(JNIEnv *env, bool *ptr,int size)
{
cout.flush();
jintArray ret;
int i;
jint *array;
ret = env->NewIntArray(size);
if (ret == 0)
{
// should throw an exception here
return 0;
}
array = env->GetIntArrayElements(ret,NULL);
// copy the data
for (i = 0; i < size; i++)
{
array[i] = ptr[i];
}
env->ReleaseIntArrayElements(ret,array,0);
return ret;
}
JNIEXPORT char *vtkJavaUTFToChar(JNIEnv *env, jstring in)
{
char *result;
......
This diff is collapsed.
......@@ -176,6 +176,7 @@ Modify lex.yy.c:
"double" return(DOUBLE);
"void" return(VOID);
"char" return(CHAR);
"bool" return(BOOL);
"virtual" return(VIRTUAL);
"const" return(CONST);
"operator" return(OPERATOR);
......
This diff is collapsed.
......@@ -220,6 +220,7 @@ char *vtkstrdup(const char *in)
%token VOID
%token CHAR
%token SIGNED_CHAR
%token BOOL
%token CLASS_REF
%token OTHER
%token CONST
......@@ -507,7 +508,8 @@ type_primitive:
IdType { postSig("vtkIdType "); $<integer>$ = 0xA;} |
LONG_LONG { postSig("long long "); $<integer>$ = 0xB;} |
INT64__ { postSig("__int64 "); $<integer>$ = 0xC;} |
SIGNED_CHAR { postSig("signed char "); $<integer>$ = 0xD;};
SIGNED_CHAR { postSig("signed char "); $<integer>$ = 0xD;} |
BOOL { postSig("bool "); $<integer>$ = 0xE;};
optional_scope: | ':' scope_list;
......
......@@ -54,6 +54,7 @@ void output_temp(FILE *fp,int i)
case 0xB: fprintf(fp,"int "); break;
case 0xC: fprintf(fp,"int "); break;
case 0xD: fprintf(fp,"char "); break;
case 0xE: fprintf(fp,"boolean "); break;
case 0x2: fprintf(fp,"void "); break;
case 0x3: fprintf(fp,"char "); break;
case 0x9: fprintf(fp,"%s ",currentFunction->ArgClasses[i]); break;
......@@ -82,6 +83,9 @@ void return_result(FILE *fp)
case 0x13: case 0x14: case 0x15: case 0x16: case 0x1A: case 0x1B: case 0x1C:
fprintf(fp,"int ");
break;
case 0xE:
fprintf(fp,"boolean ");
break;
case 0x303: fprintf(fp,"String "); break;
case 0x109:
case 0x309:
......@@ -99,6 +103,8 @@ void return_result(FILE *fp)
case 0x304: case 0x305: case 0x306: case 0x30A: case 0x30B: case 0x30C: case 0x30D:
case 0x314: case 0x315: case 0x316: case 0x31A: case 0x31B: case 0x31C:
fprintf(fp,"int[] "); break;
case 0x30E:
fprintf(fp,"boolean[] "); break;
}
}
......@@ -437,7 +443,7 @@ void outputFunction(FILE *fp, FileInfo *data)
{
case 0x301: case 0x302: case 0x307:
case 0x304: case 0x305: case 0x306:
case 0x30A: case 0x30B: case 0x30C:
case 0x30A: case 0x30B: case 0x30C: case 0x30D: case 0x30E:
case 0x313:
args_ok = currentFunction->HaveHint;
break;
......
......@@ -74,6 +74,7 @@ void output_proto_vars(FILE *fp, int i)
case 0xB: fprintf(fp,"jint "); break;
case 0xC: fprintf(fp,"jint "); break;
case 0xD: fprintf(fp,"jint "); break;
case 0xE: fprintf(fp,"jboolean "); break;
case 0x2: fprintf(fp,"void "); break;
case 0x3: fprintf(fp,"jchar "); break;
case 0x9: fprintf(fp,"jobject "); break;
......@@ -133,6 +134,10 @@ void use_hints(FILE *fp)
fprintf(fp," return vtkJavaMakeJArrayOfIntFromSignedChar(env,temp%i,%i);\n",
MAX_ARGS, currentFunction->HintSize);
break;
case 0x30E:
fprintf(fp," return vtkJavaMakeJArrayOfIntFromBool(env,temp%i,%i);\n",
MAX_ARGS, currentFunction->HintSize);
break;
case 0x305: case 0x306: case 0x314: case 0x315: case 0x316:
case 0x31A: case 0x31B: case 0x31C:
break;
......@@ -151,6 +156,9 @@ void return_result(FILE *fp)
case 0x13: case 0x14: case 0x15: case 0x16: case 0x1A: case 0x1B: case 0x1C:
fprintf(fp,"jint ");
break;
case 0xE:
fprintf(fp,"jboolean ");
break;
case 0x303: fprintf(fp,"jstring "); break;
case 0x109:
case 0x309:
......@@ -158,7 +166,7 @@ void return_result(FILE *fp)
case 0x301: case 0x307: case 0x313:
case 0x304: case 0x305: case 0x306: case 0x30A: case 0x30B: case 0x30C:
case 0x30D: case 0x31A: case 0x31B: case 0x31C:
case 0x30D: case 0x30E: case 0x31A: case 0x31B: case 0x31C:
fprintf(fp,"jarray "); break;
}
}
......@@ -207,6 +215,7 @@ void output_temp(FILE *fp, int i, int aType, char *Id, int aCount)
case 0xB: fprintf(fp,"long long "); break;
case 0xC: fprintf(fp,"__int64 "); break;
case 0xD: fprintf(fp,"signed char "); break;
case 0xE: fprintf(fp,"bool "); break;
case 0x9:
fprintf(fp,"%s ",Id); break;
case 0x8: return;
......@@ -290,6 +299,7 @@ void get_args(FILE *fp, int i)
case 0x30B:
case 0x30C:
case 0x30D:
case 0x30E:
fprintf(fp," tempArray%i = (void *)(env->GetIntArrayElements(id%i,NULL));\n",i,i);
for (j = 0; j < currentFunction->ArgCounts[i]; j++)
{
......@@ -336,6 +346,7 @@ void copy_and_release_args(FILE *fp, int i)
case 0x30B:
case 0x30C:
case 0x30D:
case 0x30E:
for (j = 0; j < currentFunction->ArgCounts[i]; j++)
{
fprintf(fp," ((jint *)tempArray%i)[%i] = temp%i[%i];\n",i,j,i,j);
......@@ -386,7 +397,7 @@ void do_return(FILE *fp)
/* this is done by looking them up in a hint file */
case 0x301: case 0x307: case 0x313:
case 0x304: case 0x305: case 0x306:
case 0x30A: case 0x30B: case 0x30C: case 0x30D:
case 0x30A: case 0x30B: case 0x30C: case 0x30D: case 0x30E:
use_hints(fp);
break;
default: fprintf(fp," return temp%i;\n", MAX_ARGS); break;
......@@ -791,7 +802,7 @@ void outputFunction(FILE *fp, FileInfo *data)
{
case 0x301: case 0x302: case 0x307:
case 0x304: case 0x305: case 0x306:
case 0x30A: case 0x30B: case 0x30C: case 0x30D:
case 0x30A: case 0x30B: case 0x30C: case 0x30D: case 0x30E:
case 0x313:
args_ok = currentFunction->HaveHint;
break;
......
......@@ -65,6 +65,16 @@ void use_hints(FILE *fp)
}
fprintf(fp,");\n");
break;
case 0x30E:
fprintf(fp," return Py_BuildValue((char*)\"");
for (i = 0; i < currentFunction->HintSize; i++) fprintf(fp,"b");
fprintf(fp,"\"");
for (i = 0; i < currentFunction->HintSize; i++)
{
fprintf(fp,",(int)temp%i[%d]",MAX_ARGS,i);
}
fprintf(fp,");\n");
break;
case 0x30A:
fprintf(fp," return Py_BuildValue((char*)\"");
#ifdef VTK_USE_64BIT_IDS
......@@ -149,6 +159,7 @@ void output_temp(FILE *fp, int i, int aType, char *Id, int aCount)
case 0xB: fprintf(fp,"long long "); break;
case 0xC: fprintf(fp,"__int64 "); break;
case 0xD: fprintf(fp,"signed char "); break;
case 0xE: fprintf(fp,"bool "); break;
case 0x8: return;
}
......@@ -220,7 +231,7 @@ void do_return(FILE *fp)
/* handle functions returning vectors */
/* this is done by looking them up in a hint file */
case 0x301: case 0x307: case 0x30A: case 0x30B: case 0x30C: case 0x30D:
case 0x304: case 0x305: case 0x306:
case 0x304: case 0x305: case 0x306: case 0x30E:
use_hints(fp);
break;
case 0x302:
......@@ -251,6 +262,11 @@ void do_return(FILE *fp)
fprintf(fp," return PyInt_FromLong(temp%i);\n", MAX_ARGS);
break;
}
case 0xE:
{
fprintf(fp," return PyBool_FromLong(temp%i);\n", MAX_ARGS);
break;
}
case 0x16:
{
#if (PY_VERSION_HEX >= 0x02020000)
......@@ -461,6 +477,7 @@ char *get_format_string()
case 0xD: result[currPos] = 'i'; currPos++; break;
case 0x3: result[currPos] = 'c'; currPos++; break;
case 0x13: result[currPos] = 'b'; currPos++; break;
case 0xE: result[currPos] = 'b'; currPos++; break;
}
}
......@@ -577,6 +594,7 @@ void get_python_signature()
case 0x6: add_to_sig(result,"int",&currPos); break;
case 0x3: add_to_sig(result,"char",&currPos); break;
case 0x13: add_to_sig(result,"int",&currPos); break;
case 0xE: add_to_sig(result,"bool",&currPos); break;
}
}
......@@ -664,6 +682,7 @@ void get_python_signature()
case 0x5:
case 0x6: add_to_sig(result,"int",&currPos); break;
case 0x3: add_to_sig(result,"char",&currPos); break;
case 0xE: add_to_sig(result,"bool",&currPos); break;
}
}
......@@ -1189,7 +1208,7 @@ void outputFunction(FILE *fp, FileInfo *data)
/* if we need a return type hint make sure we have one */
switch (currentFunction->ReturnType % 0x1000)
{
case 0x301: case 0x307: case 0x30A: case 0x30B: case 0x30C: case 0x30D:
case 0x301: case 0x307: case 0x30A: case 0x30B: case 0x30C: case 0x30D: case 0x30E:
case 0x304: case 0x305: case 0x306:
args_ok = currentFunction->HaveHint;
break;
......
......@@ -67,6 +67,7 @@ void output_temp(FILE *fp, int i, int aType, char *Id, int count)
case 0xB: fprintf(fp,"long long "); break;
case 0xC: fprintf(fp,"__int64 "); break;
case 0xD: fprintf(fp,"signed char "); break;
case 0xE: fprintf(fp,"bool "); break;
case 0x8: return;
}
......@@ -133,6 +134,21 @@ void use_hints(FILE *fp)
fprintf(fp,");\n");
fprintf(fp," Tcl_SetResult(interp, tempResult, TCL_VOLATILE);\n");
break;
case 0x30E:
fprintf(fp," char tempResult[1024];\n");
fprintf(fp," sprintf(tempResult,\"");
for (i = 0; i < currentFunction->HintSize; i++)
{
fprintf(fp,"%%i ");
}
fprintf(fp,"\"");
for (i = 0; i < currentFunction->HintSize; i++)
{
fprintf(fp,",(int)temp%i[%i]",MAX_ARGS,i);
}
fprintf(fp,");\n");
fprintf(fp," Tcl_SetResult(interp, tempResult, TCL_VOLATILE);\n");
break;
case 0x306:
fprintf(fp," char tempResult[1024];\n");
fprintf(fp," sprintf(tempResult,\"");
......@@ -309,6 +325,12 @@ void return_result(FILE *fp)
MAX_ARGS);
fprintf(fp," Tcl_SetResult(interp, tempResult, TCL_VOLATILE);\n");
break;
case 0xE:
fprintf(fp," char tempResult[1024];\n");
fprintf(fp," sprintf(tempResult,\"%%i\",(int)temp%i);\n",
MAX_ARGS);
fprintf(fp," Tcl_SetResult(interp, tempResult, TCL_VOLATILE);\n");
break;
case 0x5:
fprintf(fp," char tempResult[1024];\n");
fprintf(fp," sprintf(tempResult,\"%%hi\",temp%i);\n",
......@@ -417,7 +439,7 @@ void return_result(FILE *fp)
/* handle functions returning vectors */
/* this is done by looking them up in a hint file */
case 0x301: case 0x307:
case 0x304: case 0x305: case 0x306: case 0x30A: case 0x30B: case 0x30C: case 0x30D:
case 0x304: case 0x305: case 0x306: case 0x30A: case 0x30B: case 0x30C: case 0x30D: case 0x30E:
case 0x313: case 0x314: case 0x315: case 0x316: case 0x31A: case 0x31B: case 0x31C:
use_hints(fp);
break;
......@@ -467,6 +489,11 @@ void get_args(FILE *fp, int i)
start_arg);
fprintf(fp," temp%i = tempi;\n",i);
break;
case 0xE:
fprintf(fp," if (Tcl_GetInt(interp,argv[%i],&tempi) != TCL_OK) error = 1;\n",
start_arg);
fprintf(fp," temp%i = tempi? true:false;\n",i,j);
break;
case 0x3:
fprintf(fp," temp%i = *(argv[%i]);\n",i,start_arg);
break;
......@@ -519,6 +546,11 @@ void get_args(FILE *fp, int i)
start_arg);
fprintf(fp," temp%i[%i] = tempi;\n",i,j);
break;
case 0xE:
fprintf(fp," if (Tcl_GetInt(interp,argv[%i],&tempi) != TCL_OK) error = 1;\n",
start_arg);
fprintf(fp," temp%i[%i] = tempi? true:false;\n",i,j);
break;
case 0x3:
fprintf(fp," temp%i[%i] = *(argv[%i]);\n",i,j,start_arg);
break;
......@@ -605,7 +637,7 @@ void outputFunction(FILE *fp, FileInfo *data)
switch (currentFunction->ReturnType % 0x1000)
{
case 0x301: case 0x307:
case 0x304: case 0x305: case 0x306: case 0x30A: case 0x30B: case 0x30C: case 0x30D:
case 0x304: case 0x305: case 0x306: case 0x30A: case 0x30B: case 0x30C: case 0x30D: case 0x30E:
case 0x313: case 0x314: case 0x315: case 0x316: case 0x31A: case 0x31B: case 0x31C:
args_ok = currentFunction->HaveHint;
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment