def init_class(self, z): """Initializes a class z""" if not z.pds in self.decls_reg: self.register_ti(z.pds) # register the class if not done so z.include() funs = [] try: funs.extend(z.constructors()) except RuntimeError: pass try: funs.extend(z.mem_funs()) except RuntimeError: pass try: funs.extend(z.operators()) except RuntimeError: pass _c.init_transformers(funs) z._funs = funs _c.add_decl_desc(z)
def init_class(self, z): """Initializes a class z""" if not z.pds in self.decls_reg: self.register_ti(z.pds) # register the class if not done so z.include() funs = [] try: funs.extend(z.constructors()) except RuntimeError: pass try: funs.extend(z.mem_funs()) except RuntimeError: pass try: funs.extend(z.operators()) except RuntimeError: pass _c.init_transformers(funs) z._funs = funs _c.add_decl_desc(z)
def __init__(self, module_name, include_paths=[], number_of_files=1): self.module_name = module_name self.number_of_files = number_of_files _c.current_sb = self self.mb = None self.cc = None self.funs = None self.dummy_struct = None self.decls_reg = {} # package directory self.pkg_dir = _op.join(_op.split(_op.abspath(__file__))[0], '..', 'src', 'package') # create an instance of class that will help you to expose your declarations self.mb = _pp.module_builder.module_builder_t([module_name+"_wrapper.hpp"], gccxml_path=r"M:/utils/gccxml/bin/gccxml.exe", include_paths=include_paths+[ _op.join(self.pkg_dir, "extras", "core"), _op.join(self.pkg_dir, "extras", "sdopencv"), _op.join(self.pkg_dir, module_name+"_ext"), r"M:\programming\builders\MinGW\gcc\gcc-4.4.0-mingw\lib\gcc\mingw32\4.4.0\include\c++", r"M:\programming\builders\MinGW\gcc\gcc-4.4.0-mingw\lib\gcc\mingw32\4.4.0\include\c++\mingw32", r"M:\programming\builders\MinGW\gcc\gcc-4.4.0-mingw\lib\gcc\mingw32\4.4.0\include", ]) # create a Python file self.cc = open(_op.join(self.pkg_dir, 'pyopencv', self.module_name+'.py'), 'w') self.cc.write('''#!/usr/bin/env python # PyOpenCV - A Python wrapper for OpenCV 2.x using Boost.Python and NumPy # Copyright (c) 2009, Minh-Tri Pham # All rights reserved. # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. # * Neither the name of pyopencv's copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. #THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # For further inquiries, please contact Minh-Tri Pham at [email protected]. # ---------------------------------------------------------------------------- import common as _c import MODULE_NAME_ext as _ext from MODULE_NAME_ext import * '''.replace("MODULE_NAME", module_name)) # Well, don't you want to see what is going on? # self.mb.print_declarations() -- too many declarations # Disable every declarations first self.mb.decls().exclude() # disable some warnings # self.mb.decls().disable_warnings(messages.W1027, messages.W1025) # expose 'this' try: self.mb.classes().expose_this = True except RuntimeError: pass # expose all enumerations # try: # self.mb.enums().include() # except RuntimeError: # pass # except some weird enums # for z in ('_', 'VARENUM', 'GUARANTEE', 'NLS_FUNCTION', 'POWER_ACTION', # 'PROPSETFLAG', 'PROXY_PHASE', 'PROXY_PHASE', 'SYS', 'XLAT_SIDE', # 'STUB_PHASE', # ): # try: # self.mb.enums(lambda x: x.name.startswith(z)).exclude() # except RuntimeError: # pass # for z in ('::std', '::tag'): # try: # self.mb.enums(lambda x: x.decl_string.startswith(z)).exclude() # except RuntimeError: # pass # add 'pds' attribute to every class for z in self.mb.classes(): z.pds = _c.unique_pds(z.partial_decl_string) if z.name.startswith('vector'): z.set_already_exposed(True) # dummy struct z = self.mb.class_(module_name+"_dummy_struct") self.dummy_struct = z z.include() z.decls().exclude() z.class_('dummy_struct2').include() z.rename("__"+z.name) z._reg_code = "" # turn on 'most' of the constants for z in ('IPL_', 'CV_'): try: self.mb.decls(lambda decl: decl.name.startswith(z)).include() except RuntimeError: pass # initialise the list of free functions try: self.funs = self.mb.free_funs() except RuntimeError: self.funs = [] _c.init_transformers(self.funs) # make sure size_t is still size_t -- for 64-bit support z = self.mb.decl('size_t') z.type = _FT.size_t_t()
def __init__(self, module_name, include_paths=[], number_of_files=1): self.module_name = module_name self.number_of_files = number_of_files _c.current_sb = self self.mb = None self.cc = None self.funs = None self.dummy_struct = None self.decls_reg = {} # package directory self.pkg_dir = _op.join( _op.split(_op.abspath(__file__))[0], '..', 'src', 'package') # create an instance of class that will help you to expose your declarations self.mb = _pp.module_builder.module_builder_t( [module_name + "_wrapper.hpp"], gccxml_path=r"M:/utils/gccxml/bin/gccxml.exe", include_paths=include_paths + [ _op.join(self.pkg_dir, "extras", "core"), _op.join(self.pkg_dir, "extras", "sdopencv"), _op.join(self.pkg_dir, module_name + "_ext"), r"M:\programming\builders\MinGW\gcc\gcc-4.4.0-mingw\lib\gcc\mingw32\4.4.0\include\c++", r"M:\programming\builders\MinGW\gcc\gcc-4.4.0-mingw\lib\gcc\mingw32\4.4.0\include\c++\mingw32", r"M:\programming\builders\MinGW\gcc\gcc-4.4.0-mingw\lib\gcc\mingw32\4.4.0\include", ]) # create a Python file self.cc = open( _op.join(self.pkg_dir, 'pyopencv', self.module_name + '.py'), 'w') self.cc.write('''#!/usr/bin/env python # PyOpenCV - A Python wrapper for OpenCV 2.x using Boost.Python and NumPy # Copyright (c) 2009, Minh-Tri Pham # All rights reserved. # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. # * Neither the name of pyopencv's copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. #THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # For further inquiries, please contact Minh-Tri Pham at [email protected]. # ---------------------------------------------------------------------------- import common as _c import MODULE_NAME_ext as _ext from MODULE_NAME_ext import * '''.replace("MODULE_NAME", module_name)) # Well, don't you want to see what is going on? # self.mb.print_declarations() -- too many declarations # Disable every declarations first self.mb.decls().exclude() # disable some warnings # self.mb.decls().disable_warnings(messages.W1027, messages.W1025) # expose 'this' try: self.mb.classes().expose_this = True except RuntimeError: pass # expose all enumerations # try: # self.mb.enums().include() # except RuntimeError: # pass # except some weird enums # for z in ('_', 'VARENUM', 'GUARANTEE', 'NLS_FUNCTION', 'POWER_ACTION', # 'PROPSETFLAG', 'PROXY_PHASE', 'PROXY_PHASE', 'SYS', 'XLAT_SIDE', # 'STUB_PHASE', # ): # try: # self.mb.enums(lambda x: x.name.startswith(z)).exclude() # except RuntimeError: # pass # for z in ('::std', '::tag'): # try: # self.mb.enums(lambda x: x.decl_string.startswith(z)).exclude() # except RuntimeError: # pass # add 'pds' attribute to every class for z in self.mb.classes(): z.pds = _c.unique_pds(z.partial_decl_string) if z.name.startswith('vector'): z.set_already_exposed(True) # dummy struct z = self.mb.class_(module_name + "_dummy_struct") self.dummy_struct = z z.include() z.decls().exclude() z.class_('dummy_struct2').include() z.rename("__" + z.name) z._reg_code = "" # turn on 'most' of the constants for z in ('IPL_', 'CV_'): try: self.mb.decls(lambda decl: decl.name.startswith(z)).include() except RuntimeError: pass # initialise the list of free functions try: self.funs = self.mb.free_funs() except RuntimeError: self.funs = [] _c.init_transformers(self.funs) # make sure size_t is still size_t -- for 64-bit support z = self.mb.decl('size_t') z.type = _FT.size_t_t()