Cosmetic Python changes and replace DOH types

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12608 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2011-04-04 20:13:14 +00:00
parent 96ec495858
commit 5f6389ab31
4 changed files with 7 additions and 43 deletions

View File

@ -318,14 +318,5 @@
%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
#if defined(SWIGPYTHON_BUILTIN)
%typemap(builtin_init, fragment="SWIG_null_deleter_python") 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));
}
#endif
%enddef

View File

@ -388,7 +388,7 @@ SWIG_init(void) {
/* All objects have a 'this' attribute */
static PyGetSetDef this_getset_def = {
(char*) "this", SwigPyBuiltin_ThisClosure, NULL, NULL, NULL
(char *)"this", SwigPyBuiltin_ThisClosure, NULL, NULL, NULL
};
PyObject *this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def);
@ -398,7 +398,7 @@ SWIG_init(void) {
(PyCFunction) SwigPyObject_own
};
static PyGetSetDef thisown_getset_def = {
const_cast<char*>("thisown"), SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure
(char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure
};
PyObject *thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def);

View File

@ -88,12 +88,6 @@
$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);
@ -105,24 +99,3 @@
}
}
/* -------------------------------------------------------------
* Output typemap for the __init__ method of a built-in type.
* ------------------------------------------------------------ */
/* Pointers, references */
/*
%typemap(builtin_init,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE[] {
%set_output(SWIG_Python_NewBuiltinObj(self, %as_voidptr($1), $descriptor, $owner | %newpointer_flags));
}
*/
/*
%typemap(builtin_init, noblock=1) SWIGTYPE *const& {
%set_output(SWIG_Python_NewBuiltinObj(self, %as_voidptr(*$1), $*descriptor, $owner | %newpointer_flags));
}
*/
/* Return by value */
/*
%typemap(builtin_init, noblock=1) SWIGTYPE {
%set_output(SWIG_Python_NewBuiltinObj(self, %new_copy($1, $ltype), $&descriptor, $owner | %newpointer_flags));
}
*/

View File

@ -171,14 +171,14 @@ static String *getSlot(Node *n = NULL, const char *key = NULL) {
return val ? val : slot_default;
}
static void printSlot (File *f, DOH const *slotval, DOH const *slotname, DOH const *functype = NULL, bool comma=true) {
if (functype)
slotval = NewStringf("(%s) %s", functype, slotval);
static void printSlot(File *f, const String *slotval, const char *slotname, const char *functype = NULL, bool comma=true) {
String *slotval_override = functype ? NewStringf("(%s) %s", functype, slotval) : 0;
if (slotval_override)
slotval = slotval_override;
int len = Len(slotval);
int fieldwidth = len > 40 ? 0 : 40 - len;
Printf(f, " %s%s%*s/* %s */\n", slotval, comma ? "," : "", fieldwidth, "", slotname);
if (functype)
Delete((DOH*) slotval);
Delete(slotval_override);
}
static String *getClosure(String *functype, String *wrapper, int funpack = 0) {