當前位置: 首頁>>代碼示例>>Python>>正文


Python codesink.MemoryCodeSink方法代碼示例

本文整理匯總了Python中pybindgen.typehandlers.codesink.MemoryCodeSink方法的典型用法代碼示例。如果您正苦於以下問題:Python codesink.MemoryCodeSink方法的具體用法?Python codesink.MemoryCodeSink怎麽用?Python codesink.MemoryCodeSink使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pybindgen.typehandlers.codesink的用法示例。


在下文中一共展示了codesink.MemoryCodeSink方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: generate

# 需要導入模塊: from pybindgen.typehandlers import codesink [as 別名]
# 或者: from pybindgen.typehandlers.codesink import MemoryCodeSink [as 別名]
def generate(self, code_sink):
        """
        code_sink -- a CodeSink instance that will receive the generated code
        """
        
        tmp_sink = codesink.MemoryCodeSink()
        self.generate_body(tmp_sink)
        code_sink.writeln("static PyObject* %s(%s *self)" % (self.c_function_name,
                                                             self.container.iter_pystruct))
        code_sink.writeln('{')
        code_sink.indent()
        tmp_sink.flush_to(code_sink)
        code_sink.unindent()
        code_sink.writeln('}') 
開發者ID:KTH,項目名稱:royal-chaos,代碼行數:16,代碼來源:cppclass_container.py

示例2: generate_forward_declarations

# 需要導入模塊: from pybindgen.typehandlers import codesink [as 別名]
# 或者: from pybindgen.typehandlers.codesink import MemoryCodeSink [as 別名]
def generate_forward_declarations(self, code_sink_param):
        """
        Generate the proxy class (declaration only) to a given code sink
        """
        code_sink = MemoryCodeSink()
        if self._generate_forward_declarations(code_sink):
            code_sink.flush_to(code_sink_param)
        else:
            self.cannot_be_constructed = True 
開發者ID:KTH,項目名稱:royal-chaos,代碼行數:11,代碼來源:cppclass.py

示例3: __init__

# 需要導入模塊: from pybindgen.typehandlers import codesink [as 別名]
# 或者: from pybindgen.typehandlers.codesink import MemoryCodeSink [as 別名]
def __init__(self, error_return, declarations, predecessor=None):
        '''
        CodeBlock constructor

        >>> block = CodeBlock("return NULL;", DeclarationsScope())
        >>> block.write_code("foo();")
        >>> cleanup1 = block.add_cleanup_code("clean1();")
        >>> cleanup2 = block.add_cleanup_code("clean2();")
        >>> cleanup3 = block.add_cleanup_code("clean3();")
        >>> cleanup2.cancel()
        >>> block.write_error_check("error()", "error_clean()")
        >>> block.write_code("bar();")
        >>> block.write_cleanup()
        >>> print block.sink.flush().rstrip()
        foo();
        if (error()) {
            error_clean()
            clean3();
            clean1();
            return NULL;
        }
        bar();
        clean3();
        clean1();

        :param error_return: code that is generated on error conditions
                           (detected by write_error_check()); normally
                           it returns from the wrapper function,
                           e.g. return NULL;
        :param predecessor: optional predecessor code block; a
                          predecessor is used to search for additional
                          cleanup actions.
        '''
        assert isinstance(declarations, DeclarationsScope)
        assert predecessor is None or isinstance(predecessor, CodeBlock)
        self.sink = codesink.MemoryCodeSink()
        self.predecessor = predecessor
        self._cleanup_actions = {}
        self._last_cleanup_position = 0
        self.error_return = error_return
        self.declarations = declarations 
開發者ID:KTH,項目名稱:royal-chaos,代碼行數:43,代碼來源:base.py

示例4: clear

# 需要導入模塊: from pybindgen.typehandlers import codesink [as 別名]
# 或者: from pybindgen.typehandlers.codesink import MemoryCodeSink [as 別名]
def clear(self):
        self._cleanup_actions = {}
        self._last_cleanup_position = 0
        self.sink = codesink.MemoryCodeSink() 
開發者ID:KTH,項目名稱:royal-chaos,代碼行數:6,代碼來源:base.py

示例5: get_code_sink

# 需要導入模塊: from pybindgen.typehandlers import codesink [as 別名]
# 或者: from pybindgen.typehandlers.codesink import MemoryCodeSink [as 別名]
def get_code_sink(self):
        """Returns the internal MemoryCodeSink that holds all declararions."""
        return self._declarations 
開發者ID:KTH,項目名稱:royal-chaos,代碼行數:5,代碼來源:base.py

示例6: generate

# 需要導入模塊: from pybindgen.typehandlers import codesink [as 別名]
# 或者: from pybindgen.typehandlers.codesink import MemoryCodeSink [as 別名]
def generate(self, code_sink, wrapper_name=None, extra_wrapper_params=()):
        """
        Generates the wrapper code

        :param code_sink: a CodeSink instance that will receive the generated code
        :param wrapper_name: name of wrapper function
        """

        if self.throw: # Bug #780945
            self.return_value.REQUIRES_ASSIGNMENT_CONSTRUCTOR = False
            self.reset_code_generation_state()

        if wrapper_name is None:
            self.wrapper_actual_name = self.wrapper_base_name
        else:
            self.wrapper_actual_name = wrapper_name
        tmp_sink = codesink.MemoryCodeSink()
        self.generate_body(tmp_sink)

        flags = self.get_py_method_def_flags()
        self.wrapper_args = []
        if 'METH_VARARGS' in flags:
            if self.self_parameter_pystruct is None:
                self_param = 'PyObject * PYBINDGEN_UNUSED(dummy)'
            else:
                self_param = '%s *self' % self.self_parameter_pystruct
            self.wrapper_args.append(self_param)
            self.wrapper_args.append("PyObject *args")
            if 'METH_KEYWORDS' in flags:
                self.wrapper_args.append("PyObject *kwargs")
        self.wrapper_args.extend(extra_wrapper_params)
        self.wrapper_return = "PyObject *"
        self.write_open_wrapper(code_sink)
        tmp_sink.flush_to(code_sink)
        self.write_close_wrapper(code_sink) 
開發者ID:KTH,項目名稱:royal-chaos,代碼行數:37,代碼來源:function.py

示例7: generate

# 需要導入模塊: from pybindgen.typehandlers import codesink [as 別名]
# 或者: from pybindgen.typehandlers.codesink import MemoryCodeSink [as 別名]
def generate(self, code_sink):
        """
        code_sink -- a CodeSink instance that will receive the generated code
        """

        tmp_sink = codesink.MemoryCodeSink()
        self.generate_body(tmp_sink)
        code_sink.writeln("static PyObject* %s(%s *self)" % (self.c_function_name,
                                                             self.container.iter_pystruct))
        code_sink.writeln('{')
        code_sink.indent()
        tmp_sink.flush_to(code_sink)
        code_sink.unindent()
        code_sink.writeln('}') 
開發者ID:KTH,項目名稱:royal-chaos,代碼行數:16,代碼來源:container.py

示例8: generate

# 需要導入模塊: from pybindgen.typehandlers import codesink [as 別名]
# 或者: from pybindgen.typehandlers.codesink import MemoryCodeSink [as 別名]
def generate(self, code_sink):
        """
        :param code_sink: a CodeSink instance that will receive the generated code
        """
        tmp_sink = codesink.MemoryCodeSink()
        self.generate_body(tmp_sink)
        code_sink.writeln("static PyObject* %s(%s *self, void * PYBINDGEN_UNUSED(closure))"
                          % (self.c_function_name, self.class_.pystruct))
        code_sink.writeln('{')
        code_sink.indent()
        tmp_sink.flush_to(code_sink)
        code_sink.unindent()
        code_sink.writeln('}') 
開發者ID:KTH,項目名稱:royal-chaos,代碼行數:15,代碼來源:cppattribute.py

示例9: __init__

# 需要導入模塊: from pybindgen.typehandlers import codesink [as 別名]
# 或者: from pybindgen.typehandlers.codesink import MemoryCodeSink [as 別名]
def __init__(self, code_sink):
        super(_MonolithicSinkManager, self).__init__()
        self.final_code_sink = code_sink
        self.null_sink = NullCodeSink()
        self.includes = MemoryCodeSink()
        self.code_sink = MemoryCodeSink()

        utils.write_preamble(code_sink) 
開發者ID:KTH,項目名稱:royal-chaos,代碼行數:10,代碼來源:module.py

示例10: generate

# 需要導入模塊: from pybindgen.typehandlers import codesink [as 別名]
# 或者: from pybindgen.typehandlers.codesink import MemoryCodeSink [as 別名]
def generate(self, code_sink, wrapper_name=None, extra_wrapper_params=()):
        """
        Generates the wrapper code
        :param code_sink: a CodeSink instance that will receive the generated code
        :returns: the wrapper function name.

        """

        if self.visibility == 'private':
            raise utils.SkipWrapper("Class %r has a private constructor ->"
                                    " cannot generate a constructor for it" % self._class.full_name)
        elif self.visibility == 'protected':
            if self._class.helper_class is None:
                raise utils.SkipWrapper("Class %r has a protected constructor and no helper class"
                                        " -> cannot generate a constructor for it" % self._class.full_name)

        #assert isinstance(class_, CppClass)
        tmp_sink = codesink.MemoryCodeSink()

        assert self._class is not None
        self.generate_body(tmp_sink, gen_call_params=[self._class])

        assert ((self.parse_params.get_parameters() == ['""'])
                or self.parse_params.get_keywords() is not None), \
               ("something went wrong with the type handlers;"
                " constructors need parameter names, "
                "yet no names were given for the class %s constructor"
                % self._class.name)

        if wrapper_name is None:
            self.wrapper_actual_name = self.wrapper_base_name
        else:
            self.wrapper_actual_name = wrapper_name

        self.wrapper_return = 'static int'
        self.wrapper_args = ["%s *self" % self._class.pystruct,
                             "PyObject *args", "PyObject *kwargs"]
        self.wrapper_args.extend(extra_wrapper_params)

        self.write_open_wrapper(code_sink)
        tmp_sink.flush_to(code_sink)
        code_sink.writeln('return 0;')
        self.write_close_wrapper(code_sink) 
開發者ID:KTH,項目名稱:royal-chaos,代碼行數:45,代碼來源:cppmethod.py


注:本文中的pybindgen.typehandlers.codesink.MemoryCodeSink方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。