class doc strings

This commit is contained in:
David Rose 2005-09-10 00:02:12 +00:00
parent 59ceb897ed
commit f2d34a6022
3 changed files with 388 additions and 390 deletions

View File

@ -42,7 +42,7 @@ extern std::string EXPORT_IMPORT_PREFEX;
#define CLASS_PREFEX "Dtool_" #define CLASS_PREFEX "Dtool_"
#define INSTANCE_PREFEX "Dtool_" #define INSTANCE_PREFEX "Dtool_"
#define BASE_INSTANCE_NAME "Dtool_PyInstDef" #define BASE_INSTANCE_NAME "Dtool_PyInstDef"
#define MAX_COMMENT_SIZE 1024 #define MAX_COMMENT_SIZE 6144
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
@ -323,10 +323,8 @@ std::string methodNameFromCppName(std::string cppName, const std::string &class
/////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////
std::string make_safe_comment(const std::string & name_in) std::string
{ make_safe_comment(const std::string & name_in) {
std::string name(name_in.substr(0,MAX_COMMENT_SIZE)); std::string name(name_in.substr(0,MAX_COMMENT_SIZE));
static const char safe_chars2[] = ",.[](){}:;'`~!@#$%^&*+\\=/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_- "; static const char safe_chars2[] = ",.[](){}:;'`~!@#$%^&*+\\=/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_- ";
@ -1149,9 +1147,8 @@ bool GetSlotedFunctinDef(const std::string &thimputstring, std::string &answer_l
///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
// Function :write_module_class // Function :write_module_class
///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
void InterfaceMakerPythonNative::write_module_class(ostream &out, Object *obj) void InterfaceMakerPythonNative::
{ write_module_class(ostream &out, Object *obj) {
bool has_local_hash = false; bool has_local_hash = false;
bool has_local_repr = false; bool has_local_repr = false;
bool has_local_str = false; bool has_local_str = false;
@ -1370,7 +1367,7 @@ void InterfaceMakerPythonNative::write_module_class(ostream &out, Object *obj)
out << " {\n"; out << " {\n";
out << " ostringstream os;\n"; out << " ostringstream os;\n";
out << " local_this->output(os);\n"; out << " local_this->output(os);\n";
// out << " return PyString_FromString(os.str().c_str());\n"; // out << " return PyString_FromString(os.str().c_str());\n";
out << " std::string ss = os.str();\n"; out << " std::string ss = os.str();\n";
out << " return PyString_FromStringAndSize(ss.data(),ss.length());\n"; out << " return PyString_FromStringAndSize(ss.data(),ss.length());\n";
out << " };\n"; out << " };\n";
@ -1397,7 +1394,7 @@ void InterfaceMakerPythonNative::write_module_class(ostream &out, Object *obj)
out << " local_this->write(os,0);\n"; out << " local_this->write(os,0);\n";
else else
out << " local_this->write(os);\n"; out << " local_this->write(os);\n";
// out << " return PyString_FromString(os.str().c_str());\n"; // out << " return PyString_FromString(os.str().c_str());\n";
out << " std::string ss = os.str();\n"; out << " std::string ss = os.str();\n";
out << " return PyString_FromStringAndSize(ss.data(),ss.length());\n"; out << " return PyString_FromStringAndSize(ss.data(),ss.length());\n";
out << " };\n"; out << " };\n";
@ -1418,11 +1415,19 @@ void InterfaceMakerPythonNative::write_module_class(ostream &out, Object *obj)
out << " if(!initdone)\n"; out << " if(!initdone)\n";
out << " {\n"; out << " {\n";
out << " initdone = true;\n"; out << " initdone = true;\n";
// out << " memset(Dtool_"<< ClassName << ".As_PyTypeObject().tp_as_number,0,sizeof(PyNumberMethods));\n"; // out << " memset(Dtool_"<< ClassName << ".As_PyTypeObject().tp_as_number,0,sizeof(PyNumberMethods));\n";
// out << " memset(Dtool_"<< ClassName << ".As_PyTypeObject().tp_as_mapping,0,sizeof(PyMappingMethods));\n"; // out << " memset(Dtool_"<< ClassName << ".As_PyTypeObject().tp_as_mapping,0,sizeof(PyMappingMethods));\n";
// out << " static Dtool_PyTypedObject *InheritsFrom[] = {"; // out << " static Dtool_PyTypedObject *InheritsFrom[] = {";
// add doc string
if (obj->_itype.has_comment()) {
out << "#ifndef NDEBUG\n";
out << " // Class documentation string\n";
out << " Dtool_" << ClassName
<< ".As_PyTypeObject().tp_doc = \""
<< make_safe_comment(obj->_itype.get_comment()) << "\";\n";
out << "#endif\n";
}
// add bases/// // add bases///
if(bases.size() > 0) if(bases.size() > 0)

View File

@ -58,12 +58,6 @@ void DTOOL_Call_ExtractThisPointerForType(PyObject *self, Dtool_PyTypedObject *
answer = NULL; answer = NULL;
}; };
void *
DTOOL_Call_GetPointerThisClass(PyObject *self, Dtool_PyTypedObject *classdef) {
return DTOOL_Call_GetPointerThisClass(self, classdef, 0, "unknown");
}
void * void *
DTOOL_Call_GetPointerThisClass(PyObject *self, Dtool_PyTypedObject *classdef, DTOOL_Call_GetPointerThisClass(PyObject *self, Dtool_PyTypedObject *classdef,
int param, const string &function_name) { int param, const string &function_name) {

View File

@ -304,7 +304,6 @@ EXPCL_DTOOLCONFIG bool DtoolCanThisBeAPandaInstance(PyObject *self);
EXPCL_DTOOLCONFIG void DTOOL_Call_ExtractThisPointerForType(PyObject *self, Dtool_PyTypedObject * classdef, void ** answer); EXPCL_DTOOLCONFIG void DTOOL_Call_ExtractThisPointerForType(PyObject *self, Dtool_PyTypedObject * classdef, void ** answer);
EXPCL_DTOOLCONFIG void * DTOOL_Call_GetPointerThisClass(PyObject *self, Dtool_PyTypedObject *classdef);
EXPCL_DTOOLCONFIG void * DTOOL_Call_GetPointerThisClass(PyObject *self, Dtool_PyTypedObject *classdef, int param, const string &function_name); EXPCL_DTOOLCONFIG void * DTOOL_Call_GetPointerThisClass(PyObject *self, Dtool_PyTypedObject *classdef, int param, const string &function_name);
EXPCL_DTOOLCONFIG void * DTOOL_Call_GetPointerThis(PyObject *self); EXPCL_DTOOLCONFIG void * DTOOL_Call_GetPointerThis(PyObject *self);