clearer example - patch #1524059
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9287 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
edaadb60e7
commit
ce02b53196
1 changed files with 8 additions and 6 deletions
|
|
@ -18,27 +18,29 @@ Point *point_create(int x, int y) {
|
|||
return p;
|
||||
}
|
||||
|
||||
/* this function will be wrapped by SWIG */
|
||||
char *point_toString1(Point *p) {
|
||||
static char *point_toString(char *format, Point *p) {
|
||||
static char buf[80];
|
||||
|
||||
sprintf(buf, "(%d,%d)", p->x, p->y);
|
||||
sprintf(buf, format, p->x, p->y);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* this function will be wrapped by SWIG */
|
||||
char *point_toString1(Point *p) {
|
||||
return point_toString("(%d,%d)", p);
|
||||
}
|
||||
|
||||
/* this one we wrapped manually*/
|
||||
JNIEXPORT jstring JNICALL Java_exampleJNI_point_1toString2(JNIEnv *jenv, jclass jcls, jlong jpoint) {
|
||||
Point * p;
|
||||
char buf[80];
|
||||
jstring result;
|
||||
|
||||
(void)jcls;
|
||||
|
||||
p = *(Point **)&jpoint;
|
||||
sprintf(buf, "[%d,%d]", p->x, p->y);
|
||||
|
||||
result = (*jenv)->NewStringUTF(jenv, buf);
|
||||
result = (*jenv)->NewStringUTF(jenv, point_toString("[%d,%d]", p));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue