⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ambulantsupport.py

📁 彩信浏览器
💻 PY
📖 第 1 页 / 共 2 页
字号:
    def outputCheckConvertArg(self):        CxxMixin.outputCheckConvertArg(self)    def outputCompare(self):        Output()        Output("#define %s_compare NULL", self.prefix)    def outputHash(self):        Output()        Output("#define %s_hash NULL", self.prefix)audio_format_choices_object = audio_format_choicesObjectDefinition('audio_format_choices', 'audio_format_choicesObj', 'ambulant::net::audio_format_choices')methods_audio_format_choices = []module.addobject(audio_format_choices_object)class OpaqueByFunnyRefType(OpaqueByRefType):    def mkvalueArgs(self, name):        return "%s(&%s)" % (self.new, name)audio_format_choices = OpaqueByFunnyRefType('ambulant::net::audio_format_choices', 'audio_format_choicesObj')audio_format_choices_ptr = OpaqueByValueType('ambulant::net::audio_format_choices*', 'audio_format_choicesObj')const_audio_format_choices_ptr = OpaqueByValueType('const ambulant::net::audio_format_choices*', 'audio_format_choicesObj')# Some type synonymsnode_interface_ptr = node_ptrlib_node_ptr = node_ptrconst_node_interface_ptr = const_node_ptrmethods_node_interface = methods_nodelib_event_processor_ptr = event_processor_ptrambulant_lib_event_processor_ptr = event_processor_ptrlib_transition_info_ptr = transition_info_ptrcommon_duration = durationcommon_surface_ptr = surface_ptrcommon_playable_ptr = playable_ptrcommon_region_info_ptr = region_info_ptrcommon_gui_window_ptr = gui_window_ptrcommon_gui_events_ptr = gui_events_ptrcommon_bgrenderer_ptr = bgrenderer_ptrcommon_gui_player_ptr = gui_player_ptrcommon_playable_factory_ptr = playable_factory_ptrcommon_window_factory_ptr = window_factory_ptrlib_document_ptr = document_ptrlib_event_ptr = event_ptrambulant_lib_event_ptr = event_ptrlib_timer_ptr = timer_ptrlib_point = pointlib_size = sizelib_color_t = color_tlib_rect = rectcommon_zindex_t = zindex_tcommon_embedder_ptr = embedder_ptrplayable_notification_cookie_type = cookie_typecommon_playable_notification_cookie_type = cookie_typecommon_playable_notification_ptr = playable_notification_ptrnet_audio_datasource_ptr = audio_datasource_ptrambulant_net_url = net_urlurl = net_urlconst_ambulant_net_url_ref = net_urlposix_datasource_ptr = datasource_ptrstdio_datasource_ptr = datasource_ptrfilter_datasource_impl_ptr = datasource_ptrlib_global_parser_factory_ptr = global_parser_factory_ptrlib_node_factory_ptr = node_factory_ptrnet_datasource_factory_ptr = datasource_factory_ptrcommon_factories_ptr = factories_ptrprint "=== Testing availability of support for all needed C types ==="# Do the type testsexecfile("ambulanttypetest.py")print "=== Populating method and function lists ==="class AllowThreadMixin:    def beginallowthreads(self):        Output("PyThreadState *_save = PyEval_SaveThread();")            def endallowthreads(self):        Output("PyEval_RestoreThread(_save);")        class Function(AllowThreadMixin, FunctionGenerator):    passclass Method(AllowThreadMixin, CxxMethodGenerator):    passConstMethod = MethodConstructorMethod = CxxConstructorGenerator# Create and populate the listsexecfile(INPUTFILE)print "=== Adding methods to objects, resolving duplicates ==="# add the populated lists to the generator groups# (in a different wordl the scan program would generate this)for f in functions: module.add(f)for name, object in locals().items():    if name[-7:] == '_object':        methodlist_name = 'methods_' + name[:-7]        methodlist = locals()[methodlist_name]        for f in methodlist:            object.add(f)# Resolve duplicatesmodule.resolveduplicates()# ADD add forloop hereprint "=== Generating Python->C++ interface module ==="# generate output (open the output file as late as possible)SetOutputFileName(PY2CXXFILE)module.generate()# Now we start to get really gross. We want to reuse as much as possible# when generating the C++ wrapper classes around Python objects. So, we# redefine MyGlobalObjectDefinition, create a new module based on the# wrapper module, reread the object definitions file# (which will then create a whole new set of objects based on the new baseclass# and reinitialize the methodlists to be empty)# and call generate on this new module. Poof! We have the interface# the other way...from bgenBackSupport import *class BackVarInputBufferType(VarInputBufferType):        def getAuxDeclarations(self, name):        return []            def mkvalueArgs(self, name):        return "%s__in__, (int)%s__len__" % (name, name)InBuffer = BackVarInputBufferType('char', 'size_t', 'l')includestuff = """#define WITH_EXTERNAL_DOM 1"""finalstuff = ""execfile("ambulantincludegen.py")includestuff += """#include "ambulant/lib/node_navigator.h""""class MyGlobalObjectDefinition(BackObjectDefinition):    pass    class NoFunctionGenerator(FunctionGenerator):    def generate(self):        pass            def setClass(self, name):        pass            def generateDeclaration(self):        pass            def checkreturnvar(self):        pass            def checkgenerate(self):        return False            def generateAttributeExistenceTest(self):        pass        Function = NoFunctionGeneratorMethod = BackMethodGeneratorConstMethod = BackMethodGeneratorConstructorMethod = NoFunctionGeneratormodule = BackModule("pyambulant", includestuff, finalstuff)functions = []print "=== generating object definitions for callbacks ==="execfile("ambulantobjgen.py")print "=== declaring more types for callbacks ==="# Some type synonymsnode_interface_ptr = node_ptrlib_node_ptr = node_ptrconst_node_interface_ptr = const_node_ptrmethods_node_interface = methods_nodelib_event_processor_ptr = event_processor_ptrlib_event_ptr = event_ptrlib_timer_ptr = timer_ptrlib_point = pointlib_size = sizelib_color_t = color_tlib_rect = rectcommon_zindex_t = zindex_tnet_audio_datasource_ptr = audio_datasource_ptrgui_window_object.baseconstructors.append("ambulant::common::gui_window(0)")# We do not want callback support for audio_format__choices.del audio_format_choices_objectprint "=== Populating method and function lists for callbacks ==="#import pdb ; pdb.set_trace()execfile(INPUTFILE)print "=== Adding methods to objects, callbacks ==="for name, object in locals().items():    if name[-7:] == '_object':        methodlist_name = 'methods_' + name[:-7]        methodlist = locals()[methodlist_name]        for f in methodlist:            object.add(f)# Dummy versions of methods we cannot support:node_context_object.othermethods = [    "const custom_test_map* get_custom_tests() const { return NULL; }",]node_object.othermethods = [    "void get_children(const_node_list& l) const {ambulant::lib::node_navigator<const ambulant::lib::node>::get_children(this, l);}", # XXX for now    "void set_attributes(const char **attrs) { abort(); }", # XXX for now]node_factory_object.othermethods = [	"ambulant::lib::node *new_node(const char *local_name, const char **attrs = 0, const ambulant::lib::node_context *ctx = 0) { abort(); };",	"ambulant::lib::node *new_node(const ambulant::lib::xml_string& local_name, const char **attrs = 0, const ambulant::lib::node_context *ctx = 0) { abort(); };",]parser_factory_object.othermethods = [    "ambulant::lib::xml_parser* new_parser(ambulant::lib::sax_content_handler*, ambulant::lib::sax_error_handler*) { abort(); }", # XXX for now]xml_parser_object.othermethods = [    "void set_content_handler(ambulant::lib::sax_content_handler*) { abort(); }", #XXXX    "void set_error_handler(ambulant::lib::sax_error_handler*) { abort(); }", #XXXX]embedder_object.othermethods = [    "void show_file(const ambulant::net::url& url) { system_embedder::show_file(url); }"]renderer_object.othermethods = [    "void redraw(const ambulant::lib::rect&, ambulant::common::gui_window*) { abort(); }", # XXX    "void user_event(const ambulant::lib::point&, int) { abort(); }", # XXXX    "void transition_freeze_end(ambulant::lib::rect) { abort(); }", # XXX]bgrenderer_object.othermethods = [    "void redraw(const ambulant::lib::rect&, ambulant::common::gui_window*) { abort(); }", # XXX    "void user_event(const ambulant::lib::point&, int) { abort(); }", # XXXX    "void transition_freeze_end(ambulant::lib::rect) { abort(); }", # XXX]surface_object.othermethods = [    "ambulant::common::tile_positions get_tiles(ambulant::lib::size s, ambulant::lib::rect r) const { return surface::get_tiles(s, r); }",]surface_template_object.othermethods = [    "void animated() { abort(); }", # XXX]animation_destination_object.othermethods = [    "std::string get_name() const { return region_info::get_name(); }",    "ambulant::lib::rect get_rect() const { return region_info::get_rect(); }",    "ambulant::common::fit_t get_fit() const { return region_info::get_fit(); }",    "ambulant::lib::color_t get_bgcolor() const { return region_info::get_bgcolor(); }",    "bool get_transparent() const { return region_info::get_transparent(); }",    "ambulant::common::zindex_t get_zindex() const { return region_info::get_zindex(); }",    "bool get_showbackground() const { return region_info::get_showbackground(); }",    "bool is_subregion() const { return region_info::is_subregion(); }",    "double get_soundlevel() const { return region_info::get_soundlevel(); }",    "ambulant::common::sound_alignment get_soundalign() const { return region_info::get_soundalign(); }",    "ambulant::common::tiling get_tiling() const { return region_info::get_tiling(); }",    "const char* get_bgimage() const { return region_info::get_bgimage(); }",#    "ambulant::common::region_dim get_region_dim(const std::string&, bool = false) const { abort(); }",#    "void set_region_dim(const std::string&, const ambulant::common::region_dim&) { abort(); }",]global_playable_factory_object.othermethods = [    "ambulant::common::playable* new_playable(ambulant::common::playable_notification*, int, const ambulant::lib::node*, ambulant::lib::event_processor*) { abort(); }", # XXX    "ambulant::common::playable* new_aux_audio_playable(ambulant::common::playable_notification *context, int, const ambulant::lib::node *node, ambulant::lib::event_processor *evp, ambulant::net::audio_datasource *src) { abort(); }", # XXX]datasource_object.othermethods = [    "long add_ref() { return 1; }",    "long release() { return 1;}",    "long get_ref_count() const { return 1; }",    "char *get_read_ptr() { abort(); return NULL;}", # XXX]pkt_datasource_object.othermethods = [    "long add_ref() { return 1; }",    "long release() { return 1;}",    "long get_ref_count() const { return 1; }",    "char *get_read_ptr() { abort(); return NULL;}", # XXX    "ambulant::net::ts_packet_t get_ts_packet_t() { abort(); }", # XXX]print "=== Generating C++->Python callback interfaces (.h file) ==="# Generate the interfaceSetOutputFileName(CXX2PYDECLFILE)module.generateDeclaration()print "=== Generating C++->Python callback implementation (.cpp file) ==="# Generate the codemodule.includestuff = """#include "ambulantinterface.h"#include "ambulantutilities.h"#include "ambulantmodule.h"extern PyObject *audio_format_choicesObj_New(const ambulant::net::audio_format_choices *itself);extern int audio_format_choicesObj_Convert(PyObject *v, ambulant::net::audio_format_choices *p_itself);"""SetOutputFileName(CXX2PYFILE)module.generate()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -