From 1d3719ccb73a4f627933f15c8d4c93bed3ea007d Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 13 Oct 2009 21:28:18 +0000 Subject: [PATCH] add tinyxml.h, fix char *NULL return value case --- .../interfaceMakerPythonNative.cxx | 10 +++ dtool/src/parser-inc/Sources.pp | 2 +- dtool/src/parser-inc/tinyxml.h | 71 +++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 dtool/src/parser-inc/tinyxml.h diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index f7ff85a3e2..600dd7c1a9 100755 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -2782,6 +2782,11 @@ void InterfaceMakerPythonNative::pack_return_value(ostream &out, int indent_leve if (remap->_return_type->new_type_is_atomic_string()) { if (TypeManager::is_char_pointer(orig_type)) { + indent(out, indent_level)<<"if("<< return_expr<< " == NULL)\n"; + indent(out, indent_level)<<"{\n"; + indent(out, indent_level)<<" Py_INCREF(Py_None);\n"; + indent(out, indent_level)<<" return Py_None;\n"; + indent(out, indent_level)<<"}\n"; indent(out, indent_level) << "return PyString_FromString(" << return_expr << ");\n"; @@ -2838,6 +2843,11 @@ void InterfaceMakerPythonNative::pack_return_value(ostream &out, int indent_leve << "return PyFloat_FromDouble(" << return_expr << ");\n"; } else if (TypeManager::is_char_pointer(type)) { + indent(out, indent_level)<<"if("<< return_expr<< " == NULL)\n"; + indent(out, indent_level)<<"{\n"; + indent(out, indent_level)<<" Py_INCREF(Py_None);\n"; + indent(out, indent_level)<<" return Py_None;\n"; + indent(out, indent_level)<<"}\n"; indent(out, indent_level) << "return PyString_FromString(" << return_expr << ");\n"; diff --git a/dtool/src/parser-inc/Sources.pp b/dtool/src/parser-inc/Sources.pp index 6c355084d4..942131c60f 100644 --- a/dtool/src/parser-inc/Sources.pp +++ b/dtool/src/parser-inc/Sources.pp @@ -12,7 +12,7 @@ cv.h cvtypes.h cxcore.h cxerror.h cxtypes.h highgui.h \ avcodec.h avformat.h avio.h avutil.h swscale.h integer.h \ intfloat_readwrite.h mathematics.h rational.h rtp.h \ - rtsp.h rtspcodes.h setjmp.h winsock2.h \ + rtsp.h rtspcodes.h setjmp.h tinyxml.h winsock2.h \ ode/ode.h collision_trimesh.h artools.h \ NxPhysics.h cloth/NxCloth.h fluids/NxFluid.h \ netinet/tcp.h netinet/ip.h sys/socket.h \ diff --git a/dtool/src/parser-inc/tinyxml.h b/dtool/src/parser-inc/tinyxml.h new file mode 100644 index 0000000000..562a850277 --- /dev/null +++ b/dtool/src/parser-inc/tinyxml.h @@ -0,0 +1,71 @@ +#ifndef TINYXML_H +#define TINYXML_H + +// A simple header to mirror the subset of the tinyxml interface we +// wish to expose to interrogate. This is intended to protect us from +// having to run interrogate directly on the tinyxml.h header file. + +class TiXmlBase; +class TiXmlNode; +class TiXmlElement; +class TiXmlDocument; + +class TiXmlBase { +}; + + +class TiXmlNode : public TiXmlBase { +public: + const char *Value() const; + void SetValue(const char *_value); + + TiXmlNode *InsertEndChild(const TiXmlNode &addThis); + bool RemoveChild( TiXmlNode* removeThis ); + + const TiXmlElement *NextSiblingElement() const; + TiXmlElement *NextSiblingElement(); + + const TiXmlElement* NextSiblingElement(const char *) const; + TiXmlElement* NextSiblingElement(const char *_next); + + const TiXmlElement* FirstChildElement() const; + TiXmlElement* FirstChildElement(); + + const TiXmlElement* FirstChildElement( const char * _value ) const; + TiXmlElement* FirstChildElement( const char * _value ); + + virtual TiXmlNode* Clone() const; +}; + + +class TiXmlElement : public TiXmlNode { +public: + TiXmlElement(const char * in_value); + TiXmlElement( const TiXmlElement& ); + + const char* Attribute( const char* name ) const; + void SetAttribute( const char* name, const char * _value ); + void RemoveAttribute( const char * name ); +}; + +class TiXmlDeclaration : public TiXmlNode { +public: + TiXmlDeclaration(const char* _version, + const char* _encoding, + const char* _standalone); +}; + + +class TiXmlDocument : public TiXmlNode { +public: + TiXmlDocument(); + TiXmlDocument(const char * documentName); + + bool LoadFile(); + bool SaveFile() const; + bool LoadFile(const char * filename); + bool SaveFile(const char * filename) const; +}; + + +#endif