fix for perl + multiple modules
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7863 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
1c7786574f
commit
4267a26ecd
4 changed files with 45 additions and 19 deletions
|
|
@ -77,11 +77,24 @@ extern "C" {
|
||||||
|
|
||||||
#define SWIG_MAYBE_PERL_OBJECT SWIG_PERL_OBJECT_DECL
|
#define SWIG_MAYBE_PERL_OBJECT SWIG_PERL_OBJECT_DECL
|
||||||
|
|
||||||
SWIGRUNTIME swig_cast_info *
|
SWIGRUNTIME const char *
|
||||||
SWIG_Perl_TypeCheckRV(SWIG_MAYBE_PERL_OBJECT SV *rv, swig_type_info *ty) {
|
SWIG_Perl_TypeProxyName(const swig_type_info *type) {
|
||||||
SWIG_TypeCheck_Template(sv_derived_from(rv, (char *) iter->type->name), ty);
|
if (!type) return NULL;
|
||||||
|
if (type->clientdata != NULL) {
|
||||||
|
return (const char*) type->clientdata;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return type->name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SWIGRUNTIME swig_cast_info *
|
||||||
|
SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) {
|
||||||
|
SWIG_TypeCheck_Template(( (!iter->type->clientdata && (strcmp((char*)iter->type->name, c) == 0))
|
||||||
|
|| (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0))), ty);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Function for getting a pointer value */
|
/* Function for getting a pointer value */
|
||||||
|
|
||||||
SWIGRUNTIME int
|
SWIGRUNTIME int
|
||||||
|
|
@ -131,8 +144,7 @@ SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *
|
||||||
if (_t) {
|
if (_t) {
|
||||||
/* Now see if the types match */
|
/* Now see if the types match */
|
||||||
char *_c = HvNAME(SvSTASH(SvRV(sv)));
|
char *_c = HvNAME(SvSTASH(SvRV(sv)));
|
||||||
|
tc = SWIG_TypeProxyCheck(_c,_t);
|
||||||
tc = SWIG_TypeCheck(_c,_t);
|
|
||||||
if (!tc) {
|
if (!tc) {
|
||||||
return SWIG_ERROR;
|
return SWIG_ERROR;
|
||||||
}
|
}
|
||||||
|
|
@ -171,7 +183,7 @@ SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, i
|
||||||
SV *obj=newSV(0);
|
SV *obj=newSV(0);
|
||||||
HV *hash=newHV();
|
HV *hash=newHV();
|
||||||
HV *stash;
|
HV *stash;
|
||||||
sv_setref_pv(obj, (char *) t->name, ptr);
|
sv_setref_pv(obj, (char *) SWIG_Perl_TypeProxyName(t), ptr);
|
||||||
stash=SvSTASH(SvRV(obj));
|
stash=SvSTASH(SvRV(obj));
|
||||||
if (flags & SWIG_POINTER_OWN) {
|
if (flags & SWIG_POINTER_OWN) {
|
||||||
HV *hv;
|
HV *hv;
|
||||||
|
|
@ -189,7 +201,7 @@ SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, i
|
||||||
sv_bless(sv, stash);
|
sv_bless(sv, stash);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sv_setref_pv(sv, (char *) t->name, ptr);
|
sv_setref_pv(sv, (char *) SWIG_Perl_TypeProxyName(t), ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -204,10 +216,10 @@ SWIGRUNTIME void
|
||||||
SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, int sz, swig_type_info *type) {
|
SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, int sz, swig_type_info *type) {
|
||||||
char result[1024];
|
char result[1024];
|
||||||
char *r = result;
|
char *r = result;
|
||||||
if ((2*sz + 1 + strlen(type->name)) > 1000) return;
|
if ((2*sz + 1 + strlen(SWIG_Perl_TypeProxyName(type))) > 1000) return;
|
||||||
*(r++) = '_';
|
*(r++) = '_';
|
||||||
r = SWIG_PackData(r,ptr,sz);
|
r = SWIG_PackData(r,ptr,sz);
|
||||||
strcpy(r,type->name);
|
strcpy(r,SWIG_Perl_TypeProxyName(type));
|
||||||
sv_setpv(sv, result);
|
sv_setpv(sv, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -325,27 +325,26 @@ public:
|
||||||
Printf(f_header,"%s\n", magic);
|
Printf(f_header,"%s\n", magic);
|
||||||
|
|
||||||
String *type_table = NewString("");
|
String *type_table = NewString("");
|
||||||
SwigType_emit_type_table(f_runtime,type_table);
|
|
||||||
|
|
||||||
/* Patch the type table to reflect the names used by shadow classes */
|
/* Patch the type table to reflect the names used by shadow classes */
|
||||||
if (blessed) {
|
if (blessed) {
|
||||||
Iterator cls;
|
Iterator cls;
|
||||||
for (cls = First(classlist); cls.item; cls = Next(cls)) {
|
for (cls = First(classlist); cls.item; cls = Next(cls)) {
|
||||||
if (Getattr(cls.item,"perl5:proxy")) {
|
String *pname = Getattr(cls.item,"perl5:proxy");
|
||||||
SwigType *type = Copy(Getattr(cls.item,"classtype"));
|
if (pname) {
|
||||||
|
SwigType *type = Getattr(cls.item,"classtypeobj");
|
||||||
if (!type) continue; /* If unnamed class, no type will be found */
|
if (!type) continue; /* If unnamed class, no type will be found */
|
||||||
|
type = Copy(type);
|
||||||
|
|
||||||
SwigType_add_pointer(type);
|
SwigType_add_pointer(type);
|
||||||
String *mangle = NewStringf("\"%s\"", SwigType_manglestr(type));
|
String *mangled = SwigType_manglestr(type);
|
||||||
String *rep = NewStringf("\"%s\"", Getattr(cls.item,"perl5:proxy"));
|
SwigType_remember_mangleddata(mangled, NewStringf("\"%s\"",pname));
|
||||||
Replaceall(type_table,mangle,rep);
|
|
||||||
Delete(mangle);
|
|
||||||
Delete(rep);
|
|
||||||
Delete(type);
|
Delete(type);
|
||||||
|
Delete(mangled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SwigType_emit_type_table(f_runtime,type_table);
|
||||||
|
|
||||||
Printf(f_wrappers,"%s",type_table);
|
Printf(f_wrappers,"%s",type_table);
|
||||||
Delete(type_table);
|
Delete(type_table);
|
||||||
|
|
|
||||||
|
|
@ -292,6 +292,7 @@ extern int SwigType_isclass(SwigType *t);
|
||||||
extern void SwigType_attach_symtab(Symtab *syms);
|
extern void SwigType_attach_symtab(Symtab *syms);
|
||||||
extern void SwigType_remember(SwigType *t);
|
extern void SwigType_remember(SwigType *t);
|
||||||
extern void SwigType_remember_clientdata(SwigType *t, const String_or_char *clientdata);
|
extern void SwigType_remember_clientdata(SwigType *t, const String_or_char *clientdata);
|
||||||
|
extern void SwigType_remember_mangleddata(String *mangled, const String_or_char *clientdata);
|
||||||
extern void (*SwigType_remember_trace(void (*tf)(SwigType *, String *, String *)))(SwigType *, String *, String *);
|
extern void (*SwigType_remember_trace(void (*tf)(SwigType *, String *, String *)))(SwigType *, String *, String *);
|
||||||
extern void SwigType_emit_type_table(File *f_headers, File *f_table);
|
extern void SwigType_emit_type_table(File *f_headers, File *f_table);
|
||||||
extern int SwigType_type(SwigType *t);
|
extern int SwigType_type(SwigType *t);
|
||||||
|
|
|
||||||
|
|
@ -1379,10 +1379,19 @@ static Hash *r_mangled = 0; /* Hash mapping mangled types to full
|
||||||
static Hash *r_resolved = 0; /* Hash mapping resolved types to mangled types */
|
static Hash *r_resolved = 0; /* Hash mapping resolved types to mangled types */
|
||||||
static Hash *r_ltype = 0; /* Hash mapping mangled names to their local c type */
|
static Hash *r_ltype = 0; /* Hash mapping mangled names to their local c type */
|
||||||
static Hash *r_clientdata = 0; /* Hash mapping resolved types to client data */
|
static Hash *r_clientdata = 0; /* Hash mapping resolved types to client data */
|
||||||
|
static Hash *r_mangleddata = 0; /* Hash mapping mangled types to client data */
|
||||||
static Hash *r_remembered = 0; /* Hash of types we remembered already */
|
static Hash *r_remembered = 0; /* Hash of types we remembered already */
|
||||||
|
|
||||||
static void (*r_tracefunc)(SwigType *t, String *mangled, String *clientdata) = 0;
|
static void (*r_tracefunc)(SwigType *t, String *mangled, String *clientdata) = 0;
|
||||||
|
|
||||||
|
void SwigType_remember_mangleddata(String *mangled, const String_or_char *clientdata) {
|
||||||
|
if (!r_mangleddata) {
|
||||||
|
r_mangleddata = NewHash();
|
||||||
|
}
|
||||||
|
Setattr(r_mangleddata, mangled, clientdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SwigType_remember_clientdata(SwigType *t, const String_or_char *clientdata) {
|
void SwigType_remember_clientdata(SwigType *t, const String_or_char *clientdata) {
|
||||||
String *mt;
|
String *mt;
|
||||||
SwigType *lt;
|
SwigType *lt;
|
||||||
|
|
@ -1566,6 +1575,11 @@ String *SwigType_clientdata_collect(String *ms) {
|
||||||
Hash *mh;
|
Hash *mh;
|
||||||
String *clientdata = 0;
|
String *clientdata = 0;
|
||||||
|
|
||||||
|
if (r_mangleddata) {
|
||||||
|
clientdata = Getattr(r_mangleddata,ms);
|
||||||
|
if (clientdata) return clientdata;
|
||||||
|
}
|
||||||
|
|
||||||
mh = Getattr(r_mangled,ms);
|
mh = Getattr(r_mangled,ms);
|
||||||
if (mh) {
|
if (mh) {
|
||||||
Iterator ki;
|
Iterator ki;
|
||||||
|
|
@ -1875,7 +1889,7 @@ SwigType_emit_type_table(File *f_forward, File *f_table) {
|
||||||
} else {
|
} else {
|
||||||
nt = NewStringf("%s|%s", rn, ln);
|
nt = NewStringf("%s|%s", rn, ln);
|
||||||
}
|
}
|
||||||
Printf(types, "\"%s\", \"%s\", 0, 0, %s, 0};\n", ki.item, nt, cd);
|
Printf(types, "\"%s\", \"%s\", 0, 0, (void*)%s, 0};\n", ki.item, nt, cd);
|
||||||
|
|
||||||
el = SwigType_equivalent_mangle(ki.item,0,0);
|
el = SwigType_equivalent_mangle(ki.item,0,0);
|
||||||
for (ei = First(el); ei.item; ei = Next(ei)) {
|
for (ei = First(el); ei.item; ei = Next(ei)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue