|
|
@@ -30,89 +30,114 @@ class FunctionRemap;
|
|
|
class InterfaceMakerPythonNative : public InterfaceMakerPython
|
|
|
{
|
|
|
public:
|
|
|
- InterfaceMakerPythonNative(InterrogateModuleDef *def);
|
|
|
- virtual ~InterfaceMakerPythonNative();
|
|
|
-
|
|
|
-
|
|
|
- virtual void write_prototypes(ostream &out,ostream *out_h);
|
|
|
- void write_prototypes_class(ostream &out,ostream *out_h, Object * obj) ;
|
|
|
- void write_prototypes_class_external(ostream &out, Object * obj);
|
|
|
-
|
|
|
- virtual void write_functions(ostream &out);
|
|
|
-
|
|
|
- virtual void write_module(ostream &out,ostream *out_h, InterrogateModuleDef *def);
|
|
|
- virtual void write_module_support(ostream &out, ostream *out_h,InterrogateModuleDef *moduledefdef);
|
|
|
-
|
|
|
- void write_module_class(ostream &out, Object *cls);
|
|
|
- virtual void write_sub_module(ostream &out, Object *obj);
|
|
|
-
|
|
|
- virtual bool synthesize_this_parameter();
|
|
|
-
|
|
|
- virtual Object *record_object(TypeIndex type_index);
|
|
|
-
|
|
|
+ InterfaceMakerPythonNative(InterrogateModuleDef *def);
|
|
|
+ virtual ~InterfaceMakerPythonNative();
|
|
|
+
|
|
|
+
|
|
|
+ virtual void write_prototypes(ostream &out,ostream *out_h);
|
|
|
+ void write_prototypes_class(ostream &out,ostream *out_h, Object * obj) ;
|
|
|
+ void write_prototypes_class_external(ostream &out, Object * obj);
|
|
|
+
|
|
|
+ virtual void write_functions(ostream &out);
|
|
|
+
|
|
|
+ virtual void write_module(ostream &out,ostream *out_h, InterrogateModuleDef *def);
|
|
|
+ virtual void write_module_support(ostream &out, ostream *out_h,InterrogateModuleDef *moduledefdef);
|
|
|
+
|
|
|
+ void write_module_class(ostream &out, Object *cls);
|
|
|
+ virtual void write_sub_module(ostream &out, Object *obj);
|
|
|
+
|
|
|
+ virtual bool synthesize_this_parameter();
|
|
|
+
|
|
|
+ virtual Object *record_object(TypeIndex type_index);
|
|
|
+
|
|
|
protected:
|
|
|
- virtual string get_wrapper_prefix();
|
|
|
- virtual string get_unique_prefix();
|
|
|
- virtual void record_function_wrapper(InterrogateFunction &ifunc,
|
|
|
- FunctionWrapperIndex wrapper_index);
|
|
|
-
|
|
|
- virtual void generate_wrappers();
|
|
|
-
|
|
|
+ virtual string get_wrapper_prefix();
|
|
|
+ virtual string get_unique_prefix();
|
|
|
+ virtual void record_function_wrapper(InterrogateFunction &ifunc,
|
|
|
+ FunctionWrapperIndex wrapper_index);
|
|
|
+
|
|
|
+ virtual void generate_wrappers();
|
|
|
+
|
|
|
private:
|
|
|
- void write_prototype_for_name(ostream &out, Function *func, const std::string &name);
|
|
|
- void write_prototype_for(ostream &out, Function *func);
|
|
|
- void write_function_for_name(ostream &out, Function *func, const std::string &name, const std::string &PreProcess, const std::string &ClassName);
|
|
|
- void write_function_for_top(ostream &out, Function *func, const std::string &PreProcess);
|
|
|
- void write_function_instance(ostream &out, Function *func,
|
|
|
- FunctionRemap *remap , string &expected_params, int indent_level, bool errors_fatal, ostream &forwarddecl, const std::string &functionnamestr, bool inplace ) ;
|
|
|
-
|
|
|
- void write_function_forset(ostream &out, InterfaceMaker::Function *func,
|
|
|
- std::set< FunctionRemap *> &remaps, string &expected_params, int indent_level , ostream &forwarddecl,const std::string &functionname, bool inplace) ;
|
|
|
-
|
|
|
- void pack_return_value(ostream &out, int indent_level,
|
|
|
- FunctionRemap *remap, std::string return_expr , ostream &forwarddecl, bool in_place);
|
|
|
-
|
|
|
- void pack_return_value_tnit(ostream &out, int indent_level,
|
|
|
- FunctionRemap *remap, string return_expr) ;
|
|
|
-
|
|
|
- void write_class_prototypes(ostream &out) ;
|
|
|
- void write_ClasseDeclarations(ostream &out , ostream *out_h,Object * obj);
|
|
|
- void write_ClasseDetails(ostream &out, Object * obj);
|
|
|
-
|
|
|
- void do_assert_init(ostream &out, int indent_level, bool constructor) const;
|
|
|
+ // This enum defines the various prototypes that must be generated
|
|
|
+ // for the specialty functions that Python requires, especially for
|
|
|
+ // the slotted functions.
|
|
|
+ enum WrapperType {
|
|
|
+ WT_none,
|
|
|
+ WT_no_params,
|
|
|
+ WT_one_param,
|
|
|
+ WT_numeric_operator,
|
|
|
+ WT_setattr,
|
|
|
+ WT_getattr,
|
|
|
+ WT_sequence_getitem,
|
|
|
+ WT_sequence_setitem,
|
|
|
+ WT_sequence_size,
|
|
|
+ WT_mapping_setitem,
|
|
|
+ };
|
|
|
+
|
|
|
+ class SlottedFunctionDef {
|
|
|
+ public:
|
|
|
+ string _answer_location;
|
|
|
+ WrapperType _wrapper_type;
|
|
|
+ };
|
|
|
+
|
|
|
+ static bool get_slotted_function_def(Object *obj, Function *func, SlottedFunctionDef &def);
|
|
|
+
|
|
|
+ void write_prototype_for_name(ostream &out, Function *func, const std::string &name);
|
|
|
+ void write_prototype_for(ostream &out, Function *func);
|
|
|
+ void write_function_for_name(ostream &out, Object *obj, Function *func, const std::string &name, const std::string &PreProcess, const std::string &ClassName);
|
|
|
+ void write_function_for_top(ostream &out, Object *obj, Function *func, const std::string &PreProcess);
|
|
|
+ void write_function_instance(ostream &out, Object *obj, Function *func,
|
|
|
+ FunctionRemap *remap, string &expected_params,
|
|
|
+ int indent_level, bool errors_fatal,
|
|
|
+ ostream &forwarddecl, const std::string &functionnamestr,
|
|
|
+ bool is_inplace, bool coercion_possible);
|
|
|
+
|
|
|
+ void write_function_forset(ostream &out, Object *obj, Function *func,
|
|
|
+ std::set< FunctionRemap *> &remaps, string &expected_params, int indent_level , ostream &forwarddecl,const std::string &functionname, bool inplace) ;
|
|
|
+
|
|
|
+ void pack_return_value(ostream &out, int indent_level,
|
|
|
+ FunctionRemap *remap, std::string return_expr , ostream &forwarddecl, bool in_place);
|
|
|
+
|
|
|
+ void write_make_seq(ostream &out, Object *obj, const std::string &ClassName,
|
|
|
+ MakeSeq *make_seq);
|
|
|
+
|
|
|
+ void write_class_prototypes(ostream &out) ;
|
|
|
+ void write_ClasseDeclarations(ostream &out , ostream *out_h,Object * obj);
|
|
|
+ void write_ClasseDetails(ostream &out, Object * obj);
|
|
|
+
|
|
|
+ void do_assert_init(ostream &out, int indent_level, bool constructor) const;
|
|
|
public:
|
|
|
- bool isRemapLegal( FunctionRemap &remap);
|
|
|
- bool isFunctionLegal( Function *func);
|
|
|
- bool isCppTypeLegal(CPPType *ctype);
|
|
|
- bool isExportThisRun(CPPType *ctype);
|
|
|
- bool isExportThisRun(Function *func);
|
|
|
- bool isFunctionWithThis( Function *func);
|
|
|
- bool IsRunTimeTyped(const InterrogateType &itype);
|
|
|
-
|
|
|
- // comunicates the cast capabilites among methods..
|
|
|
- struct CastDetails
|
|
|
- {
|
|
|
- CPPStructType *_structType;
|
|
|
- std::string _to_class_name;
|
|
|
- std::string _up_cast_string;
|
|
|
- bool _can_downcast;
|
|
|
- bool _is_legal_py_class;
|
|
|
- };
|
|
|
-
|
|
|
- void GetValideChildClasses( std::map< std::string ,CastDetails > &answer, CPPStructType * inclass, const std::string &up_cast_seed = "", bool downcastposible = true);
|
|
|
- bool DoesInheritFromIsClass( const CPPStructType * inclass, const std::string &name);
|
|
|
- bool IsPandaTypedObject(CPPStructType * inclass) { return DoesInheritFromIsClass(inclass,"TypedObject"); };
|
|
|
- void WriteReturnInstance(ostream &out, int indent_level, std::string &return_expr, std::string &ows_memory_flag,const std::string &class_name, CPPType *ctype, bool inplace, const std::string &const_flag);
|
|
|
- bool HasAGetKeyFunction(const InterrogateType &itype_class);
|
|
|
- bool HasAGetClassTypeFunction(const InterrogateType &itype_class);
|
|
|
- int NeedsAStrFunction(const InterrogateType &itype_class);
|
|
|
- int NeedsAReprFunction(const InterrogateType &itype_class);
|
|
|
-
|
|
|
- void output_quoted(ostream &out, int indent_level, const std::string &str);
|
|
|
-
|
|
|
- // stash the forwad declarations for this compile pass..
|
|
|
- std::set< std::string > _external_imports;
|
|
|
-
|
|
|
+ bool isRemapLegal( FunctionRemap &remap);
|
|
|
+ bool isFunctionLegal( Function *func);
|
|
|
+ bool isCppTypeLegal(CPPType *ctype);
|
|
|
+ bool isExportThisRun(CPPType *ctype);
|
|
|
+ bool isExportThisRun(Function *func);
|
|
|
+ bool isFunctionWithThis( Function *func);
|
|
|
+ bool IsRunTimeTyped(const InterrogateType &itype);
|
|
|
+
|
|
|
+ // comunicates the cast capabilites among methods..
|
|
|
+ struct CastDetails {
|
|
|
+ CPPStructType *_structType;
|
|
|
+ std::string _to_class_name;
|
|
|
+ std::string _up_cast_string;
|
|
|
+ bool _can_downcast;
|
|
|
+ bool _is_legal_py_class;
|
|
|
+ };
|
|
|
+
|
|
|
+ void GetValideChildClasses( std::map< std::string ,CastDetails > &answer, CPPStructType * inclass, const std::string &up_cast_seed = "", bool downcastposible = true);
|
|
|
+ bool DoesInheritFromIsClass( const CPPStructType * inclass, const std::string &name);
|
|
|
+ bool IsPandaTypedObject(CPPStructType * inclass) { return DoesInheritFromIsClass(inclass,"TypedObject"); };
|
|
|
+ void WriteReturnInstance(ostream &out, int indent_level, std::string &return_expr, std::string &ows_memory_flag,const std::string &class_name, CPPType *ctype, bool inplace, const std::string &const_flag);
|
|
|
+ bool HasAGetKeyFunction(const InterrogateType &itype_class);
|
|
|
+ bool HasAGetClassTypeFunction(const InterrogateType &itype_class);
|
|
|
+ int NeedsAStrFunction(const InterrogateType &itype_class);
|
|
|
+ int NeedsAReprFunction(const InterrogateType &itype_class);
|
|
|
+
|
|
|
+ void output_quoted(ostream &out, int indent_level, const std::string &str);
|
|
|
+
|
|
|
+ // stash the forwad declarations for this compile pass..
|
|
|
+ std::set< std::string > _external_imports;
|
|
|
};
|
|
|
|
|
|
#endif
|