mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 01:07:51 -04:00
support class method versions of MAKE_SEQ
This commit is contained in:
parent
94eeacbbe2
commit
aa76a9f59d
@ -177,6 +177,32 @@ check_protocols() {
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: InterfaceMaker::Object::is_static_method
|
||||
// Access: Public
|
||||
// Description: Returns true if the first method found with the
|
||||
// indicated name is a static method, false if it is an
|
||||
// instance method. This does not test all overloads of
|
||||
// the indicated name, merely the first one found.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool InterfaceMaker::Object::
|
||||
is_static_method(const string &name) {
|
||||
Functions::const_iterator fi;
|
||||
for (fi = _methods.begin(); fi != _methods.end(); ++fi) {
|
||||
Function *func = (*fi);
|
||||
if (!func->_remaps.empty()) {
|
||||
FunctionRemap *remap = func->_remaps.front();
|
||||
string method_name = remap->_cppfunc->get_simple_name();
|
||||
if (method_name == name) {
|
||||
return !func->_has_this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Didn't find the requested function.
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: InterfaceMaker::Constructor
|
||||
// Access: Public
|
||||
|
@ -103,6 +103,7 @@ public:
|
||||
~Object();
|
||||
|
||||
void check_protocols();
|
||||
bool is_static_method(const string &name);
|
||||
|
||||
const InterrogateType &_itype;
|
||||
Functions _constructors;
|
||||
|
@ -1259,9 +1259,13 @@ write_module_class(ostream &out, Object *obj) {
|
||||
|
||||
MakeSeqs::iterator msi;
|
||||
for (msi = obj->_make_seqs.begin(); msi != obj->_make_seqs.end(); ++msi) {
|
||||
string flags = "METH_NOARGS";
|
||||
if (obj->is_static_method((*msi)->_element_name)) {
|
||||
flags += "|METH_CLASS";
|
||||
}
|
||||
out << " { \""
|
||||
<< methodNameFromCppName((*msi)->_seq_name, export_calss_name)
|
||||
<< "\",(PyCFunction) &" << (*msi)->_name << ", METH_NOARGS, NULL},\n";
|
||||
<< "\",(PyCFunction) &" << (*msi)->_name << ", " << flags << ", NULL},\n";
|
||||
}
|
||||
|
||||
out << " { NULL, NULL }\n"
|
||||
|
Loading…
x
Reference in New Issue
Block a user