Director issues should be mostly clean now.
Refactored some type initialization out of SWIG_init. Use __all__ attribute of module to define public interface. This is necessary to make available symbols starting with '_'. Now dying on li_boost_shared_ptr. Looks like it's gonna be ugly. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12373 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
b77b64944b
commit
8ac54d1d5e
7 changed files with 152 additions and 28 deletions
|
|
@ -39,6 +39,11 @@
|
|||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(builtin_init, noblock=1) CONST TYPE {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1));
|
||||
%set_output(SWIG_Python_NewBuiltinObj(self, %as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) CONST TYPE {
|
||||
void *argp = 0;
|
||||
int newmem = 0;
|
||||
|
|
@ -79,6 +84,10 @@
|
|||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0;
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), $owner | SWIG_POINTER_OWN));
|
||||
}
|
||||
%typemap(builtin_init, fragment="SWIG_null_deleter") CONST TYPE * {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0;
|
||||
%set_output(SWIG_Python_NewBuiltinObj(self, %as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), $owner | SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) CONST TYPE * {
|
||||
void *argp = 0;
|
||||
|
|
@ -123,6 +132,10 @@
|
|||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner);
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
%typemap(builtin_init, fragment="SWIG_null_deleter") CONST TYPE & {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner);
|
||||
%set_output(SWIG_Python_NewBuiltinObj(self, %as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) CONST TYPE & {
|
||||
void *argp = 0;
|
||||
|
|
@ -167,6 +180,10 @@
|
|||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner);
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
%typemap(builtin_init, fragment="SWIG_null_deleter") TYPE *CONST& {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner);
|
||||
%set_output(SWIG_Python_NewBuiltinObj(self, %as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) TYPE *CONST& %{
|
||||
#error "varin typemap not implemented"
|
||||
|
|
@ -189,6 +206,10 @@
|
|||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0;
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
%typemap(builtin_init) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0;
|
||||
%set_output(SWIG_Python_NewBuiltinObj(self, %as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||
int newmem = 0;
|
||||
|
|
@ -224,6 +245,10 @@
|
|||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0;
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
%typemap(builtin_init) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0;
|
||||
%set_output(SWIG_Python_NewBuiltinObj(self, %as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{
|
||||
#error "varin typemap not implemented"
|
||||
|
|
@ -252,6 +277,11 @@
|
|||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
if ($owner) delete $1;
|
||||
}
|
||||
%typemap(builtin_init) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 && *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0;
|
||||
%set_output(SWIG_Python_NewBuiltinObj(self, %as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
if ($owner) delete $1;
|
||||
}
|
||||
|
||||
%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{
|
||||
#error "varin typemap not implemented"
|
||||
|
|
@ -276,6 +306,10 @@
|
|||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 && **$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0;
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
%typemap(builtin_init) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 && **$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0;
|
||||
%set_output(SWIG_Python_NewBuiltinObj(self, %as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{
|
||||
#error "varin typemap not implemented"
|
||||
|
|
|
|||
|
|
@ -369,3 +369,25 @@ SwigPyStaticVar_new_getset (PyTypeObject *type, PyGetSetDef *getset)
|
|||
}
|
||||
return descr;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <vector>
|
||||
|
||||
SWIGINTERN void
|
||||
pyswig_builtin_init_bases (PyTypeObject *type, std::vector<PyTypeObject*>& bases)
|
||||
{
|
||||
if (!bases.size())
|
||||
bases.push_back(SwigPyObject_type());
|
||||
type->tp_base = bases[0];
|
||||
Py_INCREF((PyObject*) bases[0]);
|
||||
PyObject *tuple = PyTuple_New(bases.size());
|
||||
int i;
|
||||
for (i = 0; i < bases.size(); ++i) {
|
||||
PyTuple_SET_ITEM(tuple, i, (PyObject*) bases[i]);
|
||||
Py_INCREF((PyObject*) bases[i]);
|
||||
}
|
||||
type->tp_bases = tuple;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -467,7 +467,7 @@ namespace Swig {
|
|||
sobj->own = 0;
|
||||
Director *d = SWIG_DIRECTOR_CAST(reinterpret_cast<_Tp*>(sobj->ptr));
|
||||
if (d) d->swig_disown();
|
||||
return SWIG_Py_Void();
|
||||
return PyWeakref_NewProxy(pyobj, NULL);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -350,7 +350,6 @@ SWIG_init(void) {
|
|||
int i;
|
||||
|
||||
// metatype is used to implement static member variables.
|
||||
|
||||
PyObject *metatype_args = Py_BuildValue("(s(O){})", "SwigPyObjectType", &PyType_Type);
|
||||
assert(metatype_args);
|
||||
PyTypeObject *metatype = (PyTypeObject*) PyType_Type.tp_call((PyObject*) &PyType_Type, metatype_args, NULL);
|
||||
|
|
@ -359,6 +358,16 @@ SWIG_init(void) {
|
|||
metatype->tp_setattro = (setattrofunc) &SwigPyObjectType_setattro;
|
||||
assert(PyType_Ready(metatype) >= 0);
|
||||
|
||||
// All objects have a 'thisown' attribute
|
||||
static SwigPyGetSet thisown_getset_closure = {
|
||||
(PyCFunction) SwigPyObject_own,
|
||||
(PyCFunction) SwigPyObject_own
|
||||
};
|
||||
static PyGetSetDef thisown_getset_def = {
|
||||
const_cast<char*>("thisown"), pyswig_getter_closure, pyswig_setter_closure, NULL, &thisown_getset_closure
|
||||
};
|
||||
PyObject *thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def);
|
||||
|
||||
SWIG_Python_builtin_imports();
|
||||
#endif
|
||||
|
||||
|
|
@ -371,9 +380,20 @@ SWIG_init(void) {
|
|||
m = Py_InitModule((char *) SWIG_name, SwigMethods);
|
||||
#endif
|
||||
md = d = PyModule_GetDict(m);
|
||||
|
||||
|
||||
SWIG_InitializeModule(0);
|
||||
SWIG_InstallConstants(d,swig_const_table);
|
||||
|
||||
#if defined(SWIGPYTHON_BUILTIN)
|
||||
PyObject *public_interface = PyList_New(0);
|
||||
PyObject *public_symbol = 0;
|
||||
PyDict_SetItemString(md, "__all__", public_interface);
|
||||
Py_DECREF(public_interface);
|
||||
for (i = 0; SwigMethods[i].ml_name != NULL; ++i)
|
||||
pyswig_add_public_symbol(public_interface, SwigMethods[i].ml_name);
|
||||
for (i = 0; swig_const_table[i].name != 0; ++i)
|
||||
pyswig_add_public_symbol(public_interface, swig_const_table[i].name);
|
||||
#endif
|
||||
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,12 +71,33 @@ SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {
|
|||
|
||||
/* Set a constant value */
|
||||
|
||||
#if defined(SWIGPYTHON_BUILTIN)
|
||||
|
||||
SWIGINTERN void
|
||||
pyswig_add_public_symbol (PyObject *seq, const char *key) {
|
||||
PyObject *s = PyString_InternFromString(key);
|
||||
PyList_Append(seq, s);
|
||||
Py_DECREF(s);
|
||||
}
|
||||
|
||||
SWIGINTERN void
|
||||
SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) {
|
||||
PyDict_SetItemString(d, (char*) name, obj);
|
||||
Py_DECREF(obj);
|
||||
if (public_interface)
|
||||
pyswig_add_public_symbol(public_interface, name);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SWIGINTERN void
|
||||
SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {
|
||||
PyDict_SetItemString(d, (char*) name, obj);
|
||||
Py_DECREF(obj);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Append a value to the result obj */
|
||||
|
||||
SWIGINTERN PyObject*
|
||||
|
|
|
|||
|
|
@ -51,7 +51,11 @@
|
|||
#define SWIG_AppendOutput(result, obj) SWIG_Python_AppendOutput(result, obj)
|
||||
|
||||
/* set constant */
|
||||
#define SWIG_SetConstant(name, obj) SWIG_Python_SetConstant(d, name,obj)
|
||||
#if defined(SWIGPYTHON_BUILTIN)
|
||||
#define SWIG_SetConstant(name, obj) SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, name,obj)
|
||||
#else
|
||||
#define SWIG_SetConstant(name, obj) SWIG_Python_SetConstant(d, name,obj)
|
||||
#endif
|
||||
|
||||
/* raise */
|
||||
#define SWIG_Raise(obj, type, desc) SWIG_Python_Raise(obj, type, desc)
|
||||
|
|
@ -84,6 +88,10 @@
|
|||
$result = SWIG_NewPointerObj(%new_copy(*$1, $*ltype), $descriptor, SWIG_POINTER_OWN | %newpointer_flags);
|
||||
}
|
||||
|
||||
%typemap(builtin_init,noblock=1) const SWIGTYPE & SMARTPOINTER {
|
||||
$result = SWIG_NewBuiltinObj(self, %new_copy(*$1, $*ltype), $descriptor, SWIG_POINTER_OWN | %newpointer_flags);
|
||||
}
|
||||
|
||||
%typemap(ret,noblock=1) const SWIGTYPE & SMARTPOINTER, SWIGTYPE SMARTPOINTER {
|
||||
if ($result) {
|
||||
PyObject *robj = PyObject_CallMethod($result, (char *)"__deref__", NULL);
|
||||
|
|
|
|||
|
|
@ -469,8 +469,10 @@ public:
|
|||
py3 = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-builtin") == 0) {
|
||||
builtin = 1;
|
||||
Preprocessor_define("SWIGPYTHON_BUILTIN", 0);
|
||||
if (CPlusPlus) {
|
||||
builtin = 1;
|
||||
Preprocessor_define("SWIGPYTHON_BUILTIN", 0);
|
||||
}
|
||||
Swig_mark_arg(i);
|
||||
}
|
||||
|
||||
|
|
@ -2616,6 +2618,8 @@ public:
|
|||
|
||||
if (!have_globals) {
|
||||
Printf(f_init, "\t PyDict_SetItemString(md,(char*)\"%s\", SWIG_globals());\n", global_name);
|
||||
if (builtin)
|
||||
Printf(f_init, "\t pyswig_add_public_symbol(public_interface, \"%s\");\n", global_name);
|
||||
have_globals = 1;
|
||||
if (!builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER))) {
|
||||
Printf(f_shadow_stubs, "%s = %s.%s\n", global_name, module, global_name);
|
||||
|
|
@ -2698,9 +2702,11 @@ public:
|
|||
|
||||
/* Now add this to the variable linking mechanism */
|
||||
Printf(f_init, "\t SWIG_addvarlink(SWIG_globals(),(char*)\"%s\",%s, %s);\n", iname, vargetname, varsetname);
|
||||
if (builtin && shadow && !assignable && !in_class)
|
||||
Printf(f_init, "\t PyDict_SetItemString(md, (char*)\"%s\", PyObject_GetAttrString(SWIG_globals(), \"%s\"));\n",
|
||||
iname, iname);
|
||||
if (builtin && shadow && !assignable && !in_class) {
|
||||
Printf(f_init, "\t PyDict_SetItemString(md, (char*)\"%s\", PyObject_GetAttrString(SWIG_globals(), \"%s\"));\n",
|
||||
iname, iname);
|
||||
Printf(f_init, "\t pyswig_add_public_symbol(public_interface, \"%s\");\n", iname);
|
||||
}
|
||||
Delete(vargetname);
|
||||
Delete(varsetname);
|
||||
Delete(getname);
|
||||
|
|
@ -2984,7 +2990,9 @@ public:
|
|||
shadow = oldshadow;
|
||||
if (shadow) {
|
||||
if (builtin) {
|
||||
Printf(f_shadow, tab4 "{ \"__disown__\", (PyCFunction) Swig::Director::pyobj_disown< %s >, METH_NOARGS, \"\" },\n", real_classname);
|
||||
String *rname = SwigType_namestr(real_classname);
|
||||
Printf(f_shadow, tab4 "{ \"__disown__\", (PyCFunction) Swig::Director::pyobj_disown< %s >, METH_NOARGS, \"\" },\n", rname);
|
||||
Delete(rname);
|
||||
} else {
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *mrename = Swig_name_disown(NSPACE_TODO, symname); //Getattr(n, "name"));
|
||||
|
|
@ -3060,9 +3068,19 @@ public:
|
|||
* classHandler()
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
String* add_explicit_scope (String *s) {
|
||||
if (!Strstr(s, "::")) {
|
||||
String *ss = NewStringf("::%s", s);
|
||||
Delete(s);
|
||||
s = ss;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
void builtin_pre_decl(Node *n, Node *) {
|
||||
String *name = Getattr(n, "name");
|
||||
String *rname = SwigType_namestr(name);
|
||||
String *rname = add_explicit_scope(SwigType_namestr(name));
|
||||
Printf(f_init, "\n// type '%s'\n", rname);
|
||||
Printf(f_init, tab4 "builtin_pytype = &SwigPyBuiltin< %s >::pytype;\n", rname);
|
||||
Printf(f_init, tab4 "builtin_pytype->ob_type = metatype;\n");
|
||||
Printf(f_init, tab4 "builtin_pytype->tp_new = PyType_GenericNew;\n");
|
||||
|
|
@ -3076,23 +3094,16 @@ public:
|
|||
SwigType_add_pointer(base_name);
|
||||
String *base_mname = SwigType_manglestr(base_name);
|
||||
Printf(f_init, " builtin_basetype = SWIG_MangledTypeQuery(\"%s\");\n", base_mname);
|
||||
Printv(f_init, " if (builtin_basetype && builtin_basetype->clientdata && ((SwigPyClientData*) builtin_basetype->clientdata)->pytype)\n", NIL);
|
||||
Printv(f_init, " if (builtin_basetype && builtin_basetype->clientdata && ((SwigPyClientData*) builtin_basetype->clientdata)->pytype) {\n", NIL);
|
||||
Printv(f_init, " builtin_bases.push_back(((SwigPyClientData*) builtin_basetype->clientdata)->pytype);\n", NIL);
|
||||
Printv(f_init, " }\n", NIL);
|
||||
Delete(base_name);
|
||||
Delete(base_mname);
|
||||
}
|
||||
}
|
||||
Printv(f_init, " if (!builtin_bases.size())\n", NIL);
|
||||
Printv(f_init, " builtin_bases.push_back(SwigPyObject_type());\n", NIL);
|
||||
Printv(f_init, " builtin_pytype->tp_base = builtin_bases[0];\n", NIL);
|
||||
Printv(f_init, " Py_INCREF((PyObject*) builtin_bases[0]);\n", NIL);
|
||||
Printv(f_init, " tuple = PyTuple_New(builtin_bases.size());\n", NIL);
|
||||
Printv(f_init, " for (i = 0; i < builtin_bases.size(); ++i) {\n", NIL);
|
||||
Printv(f_init, " PyTuple_SET_ITEM(tuple, i, (PyObject*) builtin_bases[i]);\n", NIL);
|
||||
Printv(f_init, " Py_INCREF((PyObject*) builtin_bases[i]);\n", NIL);
|
||||
Printv(f_init, " }\n", NIL);
|
||||
Printv(f_init, " pyswig_builtin_init_bases(builtin_pytype, builtin_bases);\n", NIL);
|
||||
Printv(f_init, " builtin_bases.clear();\n", NIL);
|
||||
Printf(f_init, tab4 "builtin_pytype->tp_dict = d = PyDict_New();\n");
|
||||
Printf(f_init, " builtin_pytype->tp_dict = d = PyDict_New();\n");
|
||||
Delete(rname);
|
||||
}
|
||||
|
||||
|
|
@ -3115,7 +3126,7 @@ public:
|
|||
String *pname = Copy(name);
|
||||
SwigType_add_pointer(pname);
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *rname = SwigType_namestr(name);
|
||||
String *rname = add_explicit_scope(SwigType_namestr(name));
|
||||
String *templ = NewString("");
|
||||
Printf(templ, "SwigPyBuiltin< %s >", rname);
|
||||
char const *tp_init = builtin_tp_init ? Char(builtin_tp_init) : Swig_directorclass(n) ? "0" : "py_builtin_bad_init";
|
||||
|
|
@ -3131,6 +3142,11 @@ public:
|
|||
|
||||
String *getset_def = NewString("");
|
||||
Printf(getset_def, "template <> PyGetSetDef SwigPyBuiltin< %s >::getset[] = {\n", rname);
|
||||
|
||||
// All objects have a 'thisown' attribute
|
||||
Printv(f_init, "PyDict_SetItemString(d, \"thisown\", thisown_descr);\n", NIL);
|
||||
|
||||
// Now, the rest of the attributes
|
||||
for (DohIterator member_iter = First(builtin_getset); member_iter.item; member_iter = Next(member_iter)) {
|
||||
String *memname = member_iter.key;
|
||||
Hash *mgetset = member_iter.item;
|
||||
|
|
@ -3294,13 +3310,14 @@ public:
|
|||
|
||||
Printf(f, "template <> SwigPyClientData %s::clientdata = {0, 0, 0, 0, 0, 0, &%s::pytype};\n\n", templ, templ);
|
||||
|
||||
Printv(f_init, " d = md;\n", NIL);
|
||||
Printv(f_init, " if (PyType_Ready(builtin_pytype) < 0) {\n", NIL);
|
||||
Printf(f_init, " fprintf(stderr, \"Couldn't create type %s\");\n", symname);
|
||||
Printv(f_init, " return;\n", NIL);
|
||||
Printf(f_init, " PyErr_Format(PyExc_TypeError, \"Couldn't create type '.300%s'\");\n", symname);
|
||||
Printv(f_init, " return;\n", NIL);
|
||||
Printv(f_init, " }\n", NIL);
|
||||
Printv(f_init, " Py_INCREF(builtin_pytype);\n", NIL);
|
||||
Printf(f_init, " PyModule_AddObject(m, \"%s\", (PyObject*) builtin_pytype);\n", symname);
|
||||
Printf(f_init, " pyswig_add_public_symbol(public_interface, \"%s\");\n", symname);
|
||||
Printv(f_init, " d = md;\n", NIL);
|
||||
|
||||
Delete(clientdata);
|
||||
Delete(templ);
|
||||
|
|
@ -3396,7 +3413,9 @@ public:
|
|||
Printv(base_class, abcs, NIL);
|
||||
}
|
||||
|
||||
if (!builtin) {
|
||||
if (builtin) {
|
||||
|
||||
} else {
|
||||
Printv(f_shadow, "class ", class_name, NIL);
|
||||
|
||||
if (Len(base_class)) {
|
||||
|
|
@ -3545,7 +3564,7 @@ public:
|
|||
|
||||
if (builtin) {
|
||||
builtin_post_decl(f_builtins, n);
|
||||
String *rname = SwigType_namestr(real_classname);
|
||||
String *rname = add_explicit_scope(SwigType_namestr(real_classname));
|
||||
Printf(f_builtins, "template <> PyMethodDef SwigPyBuiltin< %s >::methods[] = {\n", rname);
|
||||
Delete(rname);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue