Merged trunk through revision 12591

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12592 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Stefan Zager 2011-04-03 03:14:19 +00:00
commit f759999f40
38 changed files with 521 additions and 112 deletions

View file

@ -35,10 +35,10 @@
// note: char is treated as a seperate special type
// signed char & unsigned char are numbers
%typemap(consttab) char
{ SWIG_LUA_CHAR, (char *)"$symname", (long)$value, 0, 0, 0}
{ SWIG_LUA_CHAR, (char *)"$symname", (long)$value, 0, 0, 0}
%typemap(consttab) long long, unsigned long long
{ SWIG_LUA_STRING, (char *) "$symname", 0, 0, (void *)"$value", 0}
{ SWIG_LUA_STRING, (char *) "$symname", 0, 0, (void *)"$value", 0}
%typemap(consttab) SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &, SWIGTYPE []
{ SWIG_LUA_POINTER, (char *)"$symname", 0, 0, (void *)$value, &$1_descriptor}

View file

@ -170,12 +170,12 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
order to allow for use of CHARSXP caches. */
Rf_protect(t = Rf_allocVector(STRSXP, 1));
#if R_VERSION >= R_Version(2,7,0)
%#if R_VERSION >= R_Version(2,7,0)
c = Rf_mkCharLen(carray, size);
#else
%#else
c = Rf_allocVector(CHARSXP, size);
strncpy((char *)CHAR(c), carray, size);
#endif
%#endif
SET_STRING_ELT(t, 0, c);
Rf_unprotect(1);
return t;

View file

@ -49,6 +49,7 @@ typedef struct swig_class {
struct swig_class **bases;
const char **base_names;
swig_module_info *module;
Tcl_HashTable hashtable;
} swig_class;
typedef struct swig_instance {

View file

@ -67,6 +67,28 @@ SWIG_Tcl_InstallConstants(Tcl_Interp *interp, swig_const_info constants[]) {
}
}
/* Create fast method lookup tables */
SWIGINTERN void
SWIG_Tcl_InstallMethodLookupTables(Tcl_Interp *interp) {
int i;
for (i = 0; i < swig_module.size; ++i) {
swig_type_info *type = swig_module.type_initial[i];
if (type->clientdata) {
swig_class* klass = (swig_class*) type->clientdata;
Tcl_InitHashTable(&(klass->hashtable), TCL_STRING_KEYS);
swig_method* meth = klass->methods;
while (meth && meth->name) {
int newEntry;
Tcl_HashEntry* hashentry = Tcl_CreateHashEntry(&(klass->hashtable), meth->name, &newEntry);
Tcl_SetHashValue(hashentry, (ClientData)meth->method);
++meth;
}
}
}
}
#ifdef __cplusplus
}
#endif
@ -113,6 +135,7 @@ SWIGEXPORT int SWIG_init(Tcl_Interp *interp) {
}
SWIG_Tcl_InstallConstants(interp, swig_constants);
SWIG_Tcl_InstallMethodLookupTables(interp);
%}

View file

@ -367,19 +367,17 @@ SWIG_Tcl_MethodCommand(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_
}
cls_stack_bi[cls_stack_top]++;
meth = cls->methods;
/* Check for methods */
while (meth && meth->name) {
if (strcmp(meth->name,method) == 0) {
Tcl_HashEntry* hashentry = Tcl_FindHashEntry(&(cls->hashtable), method);
if (hashentry) {
ClientData cd = Tcl_GetHashValue(hashentry);
swig_wrapper method_wrapper = (swig_wrapper)cd;
oldarg = objv[1];
objv[1] = inst->thisptr;
Tcl_IncrRefCount(inst->thisptr);
rcode = (*meth->method)(clientData,interp,objc,objv);
rcode = (method_wrapper)(clientData,interp,objc,objv);
objv[1] = oldarg;
Tcl_DecrRefCount(inst->thisptr);
return rcode;
}
meth++;
}
/* Check class methods for a match */
if (strcmp(method,"cget") == 0) {
@ -486,7 +484,7 @@ SWIGRUNTIME Tcl_Obj *
SWIG_Tcl_NewInstanceObj(Tcl_Interp *interp, void *thisvalue, swig_type_info *type, int flags) {
Tcl_Obj *robj = SWIG_NewPointerObj(thisvalue, type,0);
/* Check to see if this pointer belongs to a class or not */
if ((type->clientdata) && (interp)) {
if (thisvalue && (type->clientdata) && (interp)) {
Tcl_CmdInfo ci;
char *name;
name = Tcl_GetStringFromObj(robj,NULL);