本文整理匯總了Python中wrapperbuilder.PyGccWrapperTypeObject.tp_methods方法的典型用法代碼示例。如果您正苦於以下問題:Python PyGccWrapperTypeObject.tp_methods方法的具體用法?Python PyGccWrapperTypeObject.tp_methods怎麽用?Python PyGccWrapperTypeObject.tp_methods使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類wrapperbuilder.PyGccWrapperTypeObject
的用法示例。
在下文中一共展示了PyGccWrapperTypeObject.tp_methods方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: generate_cfg
# 需要導入模塊: from wrapperbuilder import PyGccWrapperTypeObject [as 別名]
# 或者: from wrapperbuilder.PyGccWrapperTypeObject import tp_methods [as 別名]
def generate_cfg():
#
# Generate the gcc.Cfg class:
#
global modinit_preinit
global modinit_postinit
getsettable = PyGetSetDefTable('PyGccCfg_getset_table',
[PyGetSetDef('basic_blocks',
'PyGccCfg_get_basic_blocks',
None,
'The list of gcc.BasicBlock instances in this graph'),
PyGetSetDef('entry',
cu.add_simple_getter('PyGccCfg_get_entry',
'PyGccCfg',
'PyGccBasicBlock_New(gcc_cfg_get_entry(self->cfg))'),
None,
'The initial gcc.BasicBlock in this graph'),
PyGetSetDef('exit',
cu.add_simple_getter('PyGccCfg_get_exit',
'PyGccCfg',
'PyGccBasicBlock_New(gcc_cfg_get_exit(self->cfg))'),
None,
'The final gcc.BasicBlock in this graph'),
])
cu.add_defn(getsettable.c_defn())
pytype = PyGccWrapperTypeObject(identifier = 'PyGccCfg_TypeObj',
localname = 'Cfg',
tp_name = 'gcc.Cfg',
tp_dealloc = 'PyGccWrapper_Dealloc',
struct_name = 'PyGccCfg',
tp_new = 'PyType_GenericNew',
#tp_repr = '(reprfunc)PyGccCfg_repr',
#tp_str = '(reprfunc)PyGccCfg_repr',
tp_getset = getsettable.identifier,
)
methods = PyMethodTable('PyGccCfg_methods', [])
methods.add_method('get_block_for_label',
'PyGccCfg_get_block_for_label',
'METH_VARARGS',
"Given a gcc.LabelDecl, get the corresponding gcc.BasicBlock")
cu.add_defn(methods.c_defn())
pytype.tp_methods = methods.identifier
cu.add_defn(pytype.c_defn())
modinit_preinit += pytype.c_invoke_type_ready()
modinit_postinit += pytype.c_invoke_add_to_module()
示例2: generate_tree
# 需要導入模塊: from wrapperbuilder import PyGccWrapperTypeObject [as 別名]
# 或者: from wrapperbuilder.PyGccWrapperTypeObject import tp_methods [as 別名]
def generate_tree():
#
# Generate the gcc.Tree class:
#
global modinit_preinit
global modinit_postinit
cu.add_defn(
"""
static PyObject *
PyGccTree_get_type(struct PyGccTree *self, void *closure)
{
return PyGccTree_New(gcc_private_make_tree(TREE_TYPE(self->t.inner)));
}
static PyObject *
PyGccTree_get_addr(struct PyGccTree *self, void *closure)
{
return PyLong_FromVoidPtr(self->t.inner);
}
"""
)
getsettable = PyGetSetDefTable(
"PyGccTree_getset_table",
[
PyGetSetDef("type", "PyGccTree_get_type", None, "Instance of gcc.Tree giving the type of the node"),
PyGetSetDef("addr", "PyGccTree_get_addr", None, "The address of the underlying GCC object in memory"),
PyGetSetDef(
"str_no_uid",
"PyGccTree_get_str_no_uid",
None,
"A string representation of this object, like str(), but without including any internal UID",
),
],
identifier_prefix="PyGccTree",
typename="PyGccTree",
)
cu.add_defn(getsettable.c_defn())
pytype = PyGccWrapperTypeObject(
identifier="PyGccTree_TypeObj",
localname="Tree",
tp_name="gcc.Tree",
tp_dealloc="PyGccWrapper_Dealloc",
struct_name="PyGccTree",
tp_new="PyType_GenericNew",
tp_getset="PyGccTree_getset_table",
tp_hash="(hashfunc)PyGccTree_hash",
tp_str="(reprfunc)PyGccTree_str",
tp_richcompare="PyGccTree_richcompare",
)
methods = PyMethodTable("PyGccTree_methods", [])
methods.add_method("debug", "PyGccTree_debug", "METH_VARARGS", "Dump the tree to stderr")
cu.add_defn(
"""
PyObject*
PyGccTree_debug(PyObject *self, PyObject *args)
{
PyGccTree *tree_obj;
/* FIXME: type checking */
tree_obj = (PyGccTree *)self;
debug_tree(tree_obj->t.inner);
Py_RETURN_NONE;
}
"""
)
cu.add_defn(methods.c_defn())
pytype.tp_methods = methods.identifier
cu.add_defn(pytype.c_defn())
modinit_preinit += pytype.c_invoke_type_ready()
modinit_postinit += pytype.c_invoke_add_to_module()
示例3: generate_tree
# 需要導入模塊: from wrapperbuilder import PyGccWrapperTypeObject [as 別名]
# 或者: from wrapperbuilder.PyGccWrapperTypeObject import tp_methods [as 別名]
def generate_tree():
#
# Generate the gcc.Tree class:
#
global modinit_preinit
global modinit_postinit
cu.add_defn("""
static PyObject *
gcc_Tree_get_type(struct PyGccTree *self, void *closure)
{
return gcc_python_make_wrapper_tree(TREE_TYPE(self->t));
}
static PyObject *
gcc_Tree_get_addr(struct PyGccTree *self, void *closure)
{
return PyLong_FromVoidPtr(self->t);
}
""")
getsettable = PyGetSetDefTable('gcc_Tree_getset_table',
[PyGetSetDef('type', 'gcc_Tree_get_type', None,
'Instance of gcc.Tree giving the type of the node'),
PyGetSetDef('addr', 'gcc_Tree_get_addr', None,
'The address of the underlying GCC object in memory'),
PyGetSetDef('str_no_uid', 'gcc_Tree_get_str_no_uid', None,
'A string representation of this object, like str(), but without including any internal UID')],
identifier_prefix='gcc_Tree',
typename='PyGccTree')
cu.add_defn(getsettable.c_defn())
pytype = PyGccWrapperTypeObject(identifier = 'gcc_TreeType',
localname = 'Tree',
tp_name = 'gcc.Tree',
tp_dealloc = 'gcc_python_wrapper_dealloc',
struct_name = 'PyGccTree',
tp_new = 'PyType_GenericNew',
tp_getset = 'gcc_Tree_getset_table',
tp_hash = '(hashfunc)gcc_Tree_hash',
tp_str = '(reprfunc)gcc_Tree_str',
tp_richcompare = 'gcc_Tree_richcompare')
methods = PyMethodTable('gcc_Tree_methods', [])
methods.add_method('debug',
'gcc_Tree_debug',
'METH_VARARGS',
"Dump the tree to stderr")
cu.add_defn("""
PyObject*
gcc_Tree_debug(PyObject *self, PyObject *args)
{
PyGccTree *tree_obj;
/* FIXME: type checking */
tree_obj = (PyGccTree *)self;
debug_tree(tree_obj->t);
Py_RETURN_NONE;
}
""")
cu.add_defn(methods.c_defn())
pytype.tp_methods = methods.identifier
cu.add_defn(pytype.c_defn())
modinit_preinit += pytype.c_invoke_type_ready()
modinit_postinit += pytype.c_invoke_add_to_module()
示例4: generate_gimple
# 需要導入模塊: from wrapperbuilder import PyGccWrapperTypeObject [as 別名]
# 或者: from wrapperbuilder.PyGccWrapperTypeObject import tp_methods [as 別名]
def generate_gimple():
#
# Generate the gcc.Gimple class:
#
global modinit_preinit
global modinit_postinit
cu.add_defn("""
static PyObject *
PyGccGimple_get_location(struct PyGccGimple *self, void *closure)
{
return PyGccLocation_New(gcc_gimple_get_location(self->stmt));
}
static PyObject *
PyGccGimple_get_block(struct PyGccGimple *self, void *closure)
{
return PyGccTree_New(gcc_gimple_get_block(self->stmt));
}
""")
getsettable = PyGetSetDefTable('PyGccGimple_getset_table',
[PyGetSetDef('loc', 'PyGccGimple_get_location', None, 'Source code location of this statement, as a gcc.Location'),
PyGetSetDef('block', 'PyGccGimple_get_block', None, 'The lexical block holding this statement, as a gcc.Tree'),
PyGetSetDef('exprtype',
cu.add_simple_getter('PyGccGimple_get_exprtype',
'PyGccGimple',
'PyGccTree_New(gcc_gimple_get_expr_type(self->stmt))'),
None,
'The type of the main expression computed by this statement, as a gcc.Tree (which might be gcc.Void_TypeObj)'),
PyGetSetDef('str_no_uid',
'PyGccGimple_get_str_no_uid',
None,
'A string representation of this statement, like str(), but without including any internal UID'),
])
cu.add_defn(getsettable.c_defn())
pytype = PyGccWrapperTypeObject(identifier = 'PyGccGimple_TypeObj',
localname = 'Gimple',
tp_name = 'gcc.Gimple',
tp_dealloc = 'PyGccWrapper_Dealloc',
struct_name = 'PyGccGimple',
tp_new = 'PyType_GenericNew',
tp_getset = getsettable.identifier,
tp_repr = '(reprfunc)PyGccGimple_repr',
tp_str = '(reprfunc)PyGccGimple_str',
tp_hash = '(hashfunc)PyGccGimple_hash',
tp_richcompare = 'PyGccGimple_richcompare',
tp_flags = 'Py_TPFLAGS_BASETYPE',
)
methods = PyMethodTable('PyGccGimple_methods', [])
methods.add_method('walk_tree',
'(PyCFunction)PyGccGimple_walk_tree',
'METH_VARARGS | METH_KEYWORDS',
"Visit all gcc.Tree nodes associated with this statement")
cu.add_defn(methods.c_defn())
pytype.tp_methods = methods.identifier
cu.add_defn(pytype.c_defn())
modinit_preinit += pytype.c_invoke_type_ready()
modinit_postinit += pytype.c_invoke_add_to_module()
示例5: generate_gimple
# 需要導入模塊: from wrapperbuilder import PyGccWrapperTypeObject [as 別名]
# 或者: from wrapperbuilder.PyGccWrapperTypeObject import tp_methods [as 別名]
def generate_gimple():
#
# Generate the gcc.Gimple class:
#
global modinit_preinit
global modinit_postinit
cu.add_defn(
"""
static PyObject *
gcc_Gimple_get_location(struct PyGccGimple *self, void *closure)
{
return gcc_python_make_wrapper_location(gimple_location(self->stmt));
}
static PyObject *
gcc_Gimple_get_block(struct PyGccGimple *self, void *closure)
{
return gcc_python_make_wrapper_tree(gimple_block(self->stmt));
}
"""
)
getsettable = PyGetSetDefTable(
"gcc_Gimple_getset_table",
[
PyGetSetDef(
"loc", "gcc_Gimple_get_location", None, "Source code location of this statement, as a gcc.Location"
),
PyGetSetDef(
"block", "gcc_Gimple_get_block", None, "The lexical block holding this statement, as a gcc.Tree"
),
PyGetSetDef(
"exprtype",
cu.add_simple_getter(
"gcc_Gimple_get_exprtype",
"PyGccGimple",
"gcc_python_make_wrapper_tree(gimple_expr_type(self->stmt))",
),
None,
"The type of the main expression computed by this statement, as a gcc.Tree (which might be gcc.VoidType)",
),
PyGetSetDef(
"str_no_uid",
"gcc_Gimple_get_str_no_uid",
None,
"A string representation of this statement, like str(), but without including any internal UID",
),
],
)
cu.add_defn(getsettable.c_defn())
pytype = PyGccWrapperTypeObject(
identifier="gcc_GimpleType",
localname="Gimple",
tp_name="gcc.Gimple",
tp_dealloc="gcc_python_wrapper_dealloc",
struct_name="PyGccGimple",
tp_new="PyType_GenericNew",
tp_getset=getsettable.identifier,
tp_repr="(reprfunc)gcc_Gimple_repr",
tp_str="(reprfunc)gcc_Gimple_str",
tp_flags="Py_TPFLAGS_BASETYPE",
)
methods = PyMethodTable("gcc_Gimple_methods", [])
methods.add_method(
"walk_tree",
"(PyCFunction)gcc_Gimple_walk_tree",
"METH_VARARGS | METH_KEYWORDS",
"Visit all gcc.Tree nodes associated with this statement",
)
cu.add_defn(methods.c_defn())
pytype.tp_methods = methods.identifier
cu.add_defn(pytype.c_defn())
modinit_preinit += pytype.c_invoke_type_ready()
modinit_postinit += pytype.c_invoke_add_to_module()