mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
fix a crash with the python-obj, python and c interface makers
This commit is contained in:
parent
c3e862a842
commit
52e4acc0ce
@ -156,22 +156,24 @@ check_protocols() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now are there any make_seq requests within this class?
|
// Now are there any make_seq requests within this class?
|
||||||
CPPStructType *stype = _itype._cpptype->as_struct_type();
|
if (_itype._cpptype != NULL) {
|
||||||
if (stype != (CPPStructType *)NULL) {
|
CPPStructType *stype = _itype._cpptype->as_struct_type();
|
||||||
CPPScope *scope = stype->get_scope();
|
if (stype != (CPPStructType *)NULL) {
|
||||||
if (scope != (CPPScope *)NULL) {
|
CPPScope *scope = stype->get_scope();
|
||||||
CPPScope::Declarations::iterator di;
|
if (scope != (CPPScope *)NULL) {
|
||||||
for (di = scope->_declarations.begin(); di != scope->_declarations.end(); ++di) {
|
CPPScope::Declarations::iterator di;
|
||||||
CPPMakeSeq *cpp_make_seq = (*di)->as_make_seq();
|
for (di = scope->_declarations.begin(); di != scope->_declarations.end(); ++di) {
|
||||||
if (cpp_make_seq != (CPPMakeSeq *)NULL) {
|
CPPMakeSeq *cpp_make_seq = (*di)->as_make_seq();
|
||||||
string class_name = _itype.get_scoped_name();
|
if (cpp_make_seq != (CPPMakeSeq *)NULL) {
|
||||||
string clean_name = InterrogateBuilder::clean_identifier(class_name);
|
string class_name = _itype.get_scoped_name();
|
||||||
string wrapper_name = "MakeSeq_" + clean_name + "_" + cpp_make_seq->_seq_name;
|
string clean_name = InterrogateBuilder::clean_identifier(class_name);
|
||||||
MakeSeq *make_seq = new MakeSeq(wrapper_name, cpp_make_seq);
|
string wrapper_name = "MakeSeq_" + clean_name + "_" + cpp_make_seq->_seq_name;
|
||||||
_make_seqs.push_back(make_seq);
|
MakeSeq *make_seq = new MakeSeq(wrapper_name, cpp_make_seq);
|
||||||
|
_make_seqs.push_back(make_seq);
|
||||||
|
|
||||||
// Also add to the interrogate database.
|
// Also add to the interrogate database.
|
||||||
builder.get_make_seq(cpp_make_seq, stype);
|
builder.get_make_seq(cpp_make_seq, stype);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -246,26 +248,20 @@ void InterfaceMaker::
|
|||||||
generate_wrappers() {
|
generate_wrappers() {
|
||||||
InterrogateDatabase *idb = InterrogateDatabase::get_ptr();
|
InterrogateDatabase *idb = InterrogateDatabase::get_ptr();
|
||||||
|
|
||||||
|
|
||||||
// We use a while loop rather than a simple for loop, because we
|
// We use a while loop rather than a simple for loop, because we
|
||||||
// might increase the number of types recursively during the
|
// might increase the number of types recursively during the
|
||||||
// traversal.
|
// traversal.
|
||||||
int ti = 0;
|
int ti = 0;
|
||||||
while (ti < idb->get_num_all_types())
|
while (ti < idb->get_num_all_types()) {
|
||||||
{
|
TypeIndex type_index = idb->get_all_type(ti);
|
||||||
TypeIndex type_index = idb->get_all_type(ti);
|
record_object(type_index);
|
||||||
record_object(type_index);
|
|
||||||
|
|
||||||
|
|
||||||
if(interrogate_type_is_enum(ti))
|
|
||||||
{
|
|
||||||
int enum_count = interrogate_type_number_of_enum_values(ti);
|
|
||||||
for(int xx = 0; xx< enum_count; xx++)
|
|
||||||
{
|
|
||||||
// printf(" PyModule_AddIntConstant(module,\"%s\",%d)\n",interrogate_type_enum_value_name(ti,xx),interrogate_type_enum_value(ti,xx));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (interrogate_type_is_enum(ti)) {
|
||||||
|
int enum_count = interrogate_type_number_of_enum_values(ti);
|
||||||
|
for (int xx = 0; xx < enum_count; ++xx) {
|
||||||
|
// printf(" PyModule_AddIntConstant(module,\"%s\",%d)\n",interrogate_type_enum_value_name(ti,xx),interrogate_type_enum_value(ti,xx));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
++ti;
|
++ti;
|
||||||
// printf(" New Type %d\n",ti);
|
// printf(" New Type %d\n",ti);
|
||||||
@ -273,54 +269,43 @@ generate_wrappers() {
|
|||||||
|
|
||||||
int num_global_elements = idb->get_num_global_elements();
|
int num_global_elements = idb->get_num_global_elements();
|
||||||
for (int gi = 0; gi < num_global_elements; ++gi) {
|
for (int gi = 0; gi < num_global_elements; ++gi) {
|
||||||
printf(" Global Type = %d",gi);
|
printf(" Global Type = %d", gi);
|
||||||
TypeIndex type_index = idb->get_global_element(gi);
|
TypeIndex type_index = idb->get_global_element(gi);
|
||||||
record_object(type_index);
|
record_object(type_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
int num_functions = idb->get_num_global_functions();
|
int num_functions = idb->get_num_global_functions();
|
||||||
for (int fi = 0; fi < num_functions; fi++)
|
for (int fi = 0; fi < num_functions; fi++) {
|
||||||
{
|
|
||||||
FunctionIndex func_index = idb->get_global_function(fi);
|
FunctionIndex func_index = idb->get_global_function(fi);
|
||||||
record_function(dummy_type, func_index);
|
record_function(dummy_type, func_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int num_manifests = idb->get_num_global_manifests();
|
int num_manifests = idb->get_num_global_manifests();
|
||||||
for (int mi = 0; mi < num_manifests; mi++)
|
for (int mi = 0; mi < num_manifests; mi++) {
|
||||||
{
|
|
||||||
ManifestIndex manifest_index = idb->get_global_manifest(mi);
|
ManifestIndex manifest_index = idb->get_global_manifest(mi);
|
||||||
const InterrogateManifest &iman = idb->get_manifest(manifest_index);
|
const InterrogateManifest &iman = idb->get_manifest(manifest_index);
|
||||||
if (iman.has_getter())
|
if (iman.has_getter()) {
|
||||||
{
|
|
||||||
FunctionIndex func_index = iman.get_getter();
|
FunctionIndex func_index = iman.get_getter();
|
||||||
record_function(dummy_type, func_index);
|
record_function(dummy_type, func_index);
|
||||||
}
|
}
|
||||||
printf(" Manafests %d\n",mi);
|
printf(" Manifests %d\n", mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int num_elements = idb->get_num_global_elements();
|
int num_elements = idb->get_num_global_elements();
|
||||||
for (int ei = 0; ei < num_elements; ei++)
|
for (int ei = 0; ei < num_elements; ei++) {
|
||||||
{
|
printf(" Element %d\n", ei);
|
||||||
printf(" Element %d\n",ei);
|
|
||||||
|
|
||||||
ElementIndex element_index = idb->get_global_element(ei);
|
ElementIndex element_index = idb->get_global_element(ei);
|
||||||
const InterrogateElement &ielement = idb->get_element(element_index);
|
const InterrogateElement &ielement = idb->get_element(element_index);
|
||||||
if (ielement.has_getter())
|
if (ielement.has_getter()) {
|
||||||
{
|
|
||||||
FunctionIndex func_index = ielement.get_getter();
|
FunctionIndex func_index = ielement.get_getter();
|
||||||
record_function(dummy_type, func_index);
|
record_function(dummy_type, func_index);
|
||||||
}
|
}
|
||||||
if (ielement.has_setter())
|
if (ielement.has_setter()) {
|
||||||
{
|
|
||||||
FunctionIndex func_index = ielement.get_setter();
|
FunctionIndex func_index = ielement.get_setter();
|
||||||
record_function(dummy_type, func_index);
|
record_function(dummy_type, func_index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -491,6 +476,19 @@ separate_overloading() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: InterfaceMaker::wrap_global_functions
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: This method should be overridden and redefined to
|
||||||
|
// return false for interfaces that don't support
|
||||||
|
// global functions and should therefore will only
|
||||||
|
// accept function remaps that have a class associated.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool InterfaceMaker::
|
||||||
|
wrap_global_functions() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: InterfaceMaker::get_function_remaps
|
// Function: InterfaceMaker::get_function_remaps
|
||||||
// Access: Public
|
// Access: Public
|
||||||
@ -625,21 +623,17 @@ record_function(const InterrogateType &itype, FunctionIndex func_index) {
|
|||||||
Function *func = new Function(wrapper_name, itype, ifunc);
|
Function *func = new Function(wrapper_name, itype, ifunc);
|
||||||
_functions.push_back(func);
|
_functions.push_back(func);
|
||||||
|
|
||||||
|
// printf(" Function Name = %s\n", ifunc.get_name().c_str());
|
||||||
// printf(" Function Name = %s\n",ifunc.get_name().c_str());
|
|
||||||
|
|
||||||
// Now get all the valid FunctionRemaps for the function.
|
// Now get all the valid FunctionRemaps for the function.
|
||||||
if (ifunc._instances != (InterrogateFunction::Instances *)NULL)
|
if (ifunc._instances != (InterrogateFunction::Instances *)NULL) {
|
||||||
{
|
|
||||||
InterrogateFunction::Instances::const_iterator ii;
|
InterrogateFunction::Instances::const_iterator ii;
|
||||||
for (ii = ifunc._instances->begin();ii != ifunc._instances->end();++ii)
|
for (ii = ifunc._instances->begin(); ii != ifunc._instances->end(); ++ii) {
|
||||||
{
|
|
||||||
CPPInstance *cppfunc = (*ii).second;
|
CPPInstance *cppfunc = (*ii).second;
|
||||||
CPPFunctionType *ftype = cppfunc->_type->as_function_type();
|
CPPFunctionType *ftype = cppfunc->_type->as_function_type();
|
||||||
int max_default_parameters = 0;
|
int max_default_parameters = 0;
|
||||||
|
|
||||||
if (separate_overloading())
|
if (separate_overloading()) {
|
||||||
{
|
|
||||||
// Count up the number of default parameters this function might
|
// Count up the number of default parameters this function might
|
||||||
// take.
|
// take.
|
||||||
CPPParameterList *parameters = ftype->_parameters;
|
CPPParameterList *parameters = ftype->_parameters;
|
||||||
|
@ -54,14 +54,15 @@ public:
|
|||||||
virtual void write_includes(ostream &out);
|
virtual void write_includes(ostream &out);
|
||||||
virtual void write_prototypes(ostream &out, ostream *out_h);
|
virtual void write_prototypes(ostream &out, ostream *out_h);
|
||||||
virtual void write_functions(ostream &out);
|
virtual void write_functions(ostream &out);
|
||||||
virtual void write_module_support(ostream &out,ostream *out_h,InterrogateModuleDef *moduledefdef) {};
|
virtual void write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) {};
|
||||||
|
|
||||||
virtual void write_module(ostream &out, ostream *out_h,InterrogateModuleDef *def);
|
virtual void write_module(ostream &out, ostream *out_h, InterrogateModuleDef *def);
|
||||||
|
|
||||||
virtual ParameterRemap *remap_parameter(CPPType *struct_type, CPPType *param_type);
|
virtual ParameterRemap *remap_parameter(CPPType *struct_type, CPPType *param_type);
|
||||||
|
|
||||||
virtual bool synthesize_this_parameter();
|
virtual bool synthesize_this_parameter();
|
||||||
virtual bool separate_overloading();
|
virtual bool separate_overloading();
|
||||||
|
virtual bool wrap_global_functions();
|
||||||
|
|
||||||
void get_function_remaps(vector<FunctionRemap *> &remaps);
|
void get_function_remaps(vector<FunctionRemap *> &remaps);
|
||||||
|
|
||||||
@ -144,7 +145,7 @@ public:
|
|||||||
record_function_wrapper(InterrogateFunction &ifunc,
|
record_function_wrapper(InterrogateFunction &ifunc,
|
||||||
FunctionWrapperIndex wrapper_index);
|
FunctionWrapperIndex wrapper_index);
|
||||||
|
|
||||||
virtual Object * record_object(TypeIndex type_index);
|
virtual Object *record_object(TypeIndex type_index);
|
||||||
|
|
||||||
void hash_function_signature(FunctionRemap *remap);
|
void hash_function_signature(FunctionRemap *remap);
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ InterfaceMakerPythonObj::
|
|||||||
// write_functions().
|
// write_functions().
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void InterfaceMakerPythonObj::
|
void InterfaceMakerPythonObj::
|
||||||
write_prototypes(ostream &out,ostream *out_h) {
|
write_prototypes(ostream &out, ostream *out_h) {
|
||||||
Functions::iterator fi;
|
Functions::iterator fi;
|
||||||
for (fi = _functions.begin(); fi != _functions.end(); ++fi) {
|
for (fi = _functions.begin(); fi != _functions.end(); ++fi) {
|
||||||
Function *func = (*fi);
|
Function *func = (*fi);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user