mirror of https://github.com/swig/swig
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
|
@ -19,10 +19,11 @@ struct Date {
|
|||
};
|
||||
|
||||
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() {
|
||||
return date;
|
||||
}
|
||||
unsigned int padding; // so that memory layout is not the same as Date
|
||||
Date date;
|
||||
unsigned int seconds;
|
||||
};
|
||||
|
|
|
@ -117,27 +117,25 @@ SWIGRUNTIME int SWIG_JSC_ConvertInstancePtr(JSContextRef context, JSObjectRef ob
|
|||
SwigPrivData *cdata;
|
||||
|
||||
cdata = (SwigPrivData *) JSObjectGetPrivate(objRef);
|
||||
if(cdata == NULL) {
|
||||
if (cdata == NULL) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if(cdata->info != info) {
|
||||
bool type_valid = false;
|
||||
swig_cast_info *t = info->cast;
|
||||
while(t != NULL) {
|
||||
if(t->type == cdata->info) {
|
||||
type_valid = true;
|
||||
break;
|
||||
}
|
||||
t = t->next;
|
||||
}
|
||||
if(!type_valid) {
|
||||
return SWIG_TypeError;
|
||||
assert(ptr);
|
||||
*ptr = NULL;
|
||||
if (cdata->info == info) {
|
||||
*ptr = cdata->swigCObject;
|
||||
} else {
|
||||
swig_cast_info *tc = SWIG_TypeCheckStruct(cdata->info, info);
|
||||
if (tc) {
|
||||
int newmemory = 0;
|
||||
*ptr = SWIG_TypeCast(tc, cdata->swigCObject, &newmemory);
|
||||
assert(!newmemory); /* newmemory handling not yet implemented */
|
||||
} else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
*ptr = cdata->swigCObject;
|
||||
|
||||
if(flags & SWIG_POINTER_DISOWN) {
|
||||
if (flags & SWIG_POINTER_DISOWN) {
|
||||
cdata->swigCMemOwn = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <assert.h>
|
||||
%}
|
||||
|
||||
%insert(runtime) "swigrun.swg"; /* SWIG API */
|
||||
|
|
Loading…
Reference in New Issue