Add Javascript (JSC) support for type conversion
Fix types_directive testcase to ensure the %types code is actually called and not just cast from one type to the other.
This commit is contained in:
parent
9739be60d0
commit
6aef217438
3 changed files with 17 additions and 17 deletions
|
|
@ -19,10 +19,11 @@ struct Date {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Time1 {
|
struct Time1 {
|
||||||
Time1(unsigned int year, unsigned int month, unsigned int day, unsigned int seconds) : date(year, month, day), seconds(seconds) {}
|
Time1(unsigned int year, unsigned int month, unsigned int day, unsigned int seconds) : padding(), date(year, month, day), seconds(seconds) {}
|
||||||
Date &dateFromTime() {
|
Date &dateFromTime() {
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
unsigned int padding; // so that memory layout is not the same as Date
|
||||||
Date date;
|
Date date;
|
||||||
unsigned int seconds;
|
unsigned int seconds;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -117,27 +117,25 @@ SWIGRUNTIME int SWIG_JSC_ConvertInstancePtr(JSContextRef context, JSObjectRef ob
|
||||||
SwigPrivData *cdata;
|
SwigPrivData *cdata;
|
||||||
|
|
||||||
cdata = (SwigPrivData *) JSObjectGetPrivate(objRef);
|
cdata = (SwigPrivData *) JSObjectGetPrivate(objRef);
|
||||||
if(cdata == NULL) {
|
if (cdata == NULL) {
|
||||||
return SWIG_ERROR;
|
return SWIG_ERROR;
|
||||||
}
|
}
|
||||||
if(cdata->info != info) {
|
assert(ptr);
|
||||||
bool type_valid = false;
|
*ptr = NULL;
|
||||||
swig_cast_info *t = info->cast;
|
if (cdata->info == info) {
|
||||||
while(t != NULL) {
|
*ptr = cdata->swigCObject;
|
||||||
if(t->type == cdata->info) {
|
} else {
|
||||||
type_valid = true;
|
swig_cast_info *tc = SWIG_TypeCheckStruct(cdata->info, info);
|
||||||
break;
|
if (tc) {
|
||||||
}
|
int newmemory = 0;
|
||||||
t = t->next;
|
*ptr = SWIG_TypeCast(tc, cdata->swigCObject, &newmemory);
|
||||||
}
|
assert(!newmemory); /* newmemory handling not yet implemented */
|
||||||
if(!type_valid) {
|
} else {
|
||||||
return SWIG_TypeError;
|
return SWIG_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*ptr = cdata->swigCObject;
|
if (flags & SWIG_POINTER_DISOWN) {
|
||||||
|
|
||||||
if(flags & SWIG_POINTER_DISOWN) {
|
|
||||||
cdata->swigCMemOwn = false;
|
cdata->swigCMemOwn = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <assert.h>
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%insert(runtime) "swigrun.swg"; /* SWIG API */
|
%insert(runtime) "swigrun.swg"; /* SWIG API */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue