本文整理匯總了Python中wrapperbuilder.PyGccWrapperTypeObject類的典型用法代碼示例。如果您正苦於以下問題:Python PyGccWrapperTypeObject類的具體用法?Python PyGccWrapperTypeObject怎麽用?Python PyGccWrapperTypeObject使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了PyGccWrapperTypeObject類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: generate_concrete_rtx_code_subclasses
def generate_concrete_rtx_code_subclasses():
global modinit_preinit
global modinit_postinit
for expr_type in rtl_expr_types:
cc = expr_type.camel_cased_string()
getsettable = None
if getsettable:
cu.add_defn(getsettable.c_defn())
pytype = PyGccWrapperTypeObject(identifier = 'PyGcc%s_TypeObj' % cc,
localname = cc,
tp_name = 'gcc.%s' % cc,
struct_name = 'PyGccRtl',
tp_new = 'PyType_GenericNew',
tp_base = ('&PyGccRtlClassType%s_TypeObj'
% camel_case(expr_type.CLASS)),
tp_getset = getsettable.identifier if getsettable else None,
tp_repr = '(reprfunc)PyGccRtl_repr',
tp_str = '(reprfunc)PyGccRtl_str',
)
cu.add_defn(pytype.c_defn())
modinit_preinit += pytype.c_invoke_type_ready()
modinit_postinit += pytype.c_invoke_add_to_module()
示例2: generate_variable
def generate_variable():
global modinit_preinit
global modinit_postinit
getsettable = PyGetSetDefTable('gcc_Variable_getset_table', [])
def add_simple_getter(name, c_expression, doc):
getsettable.add_gsdef(name,
cu.add_simple_getter('gcc_Variable_get_%s' % name,
'PyGccVariable',
c_expression),
None,
doc)
add_simple_getter('decl',
'gcc_python_make_wrapper_tree(self->var->decl)',
'The declaration of this variable, as a gcc.Tree')
cu.add_defn(getsettable.c_defn())
pytype = PyGccWrapperTypeObject(identifier = 'gcc_VariableType',
localname = 'Variable',
tp_name = 'gcc.Variable',
tp_dealloc = 'gcc_python_wrapper_dealloc',
struct_name = 'PyGccVariable',
tp_new = 'PyType_GenericNew',
tp_getset = getsettable.identifier,
#tp_repr = '(reprfunc)gcc_Variable_repr',
#tp_str = '(reprfunc)gcc_Variable_repr',
)
cu.add_defn(pytype.c_defn())
modinit_preinit += pytype.c_invoke_type_ready()
modinit_postinit += pytype.c_invoke_add_to_module()
示例3: generate_location
def generate_location():
#
# Generate the gcc.Location class:
#
global modinit_preinit
global modinit_postinit
cu.add_defn("""
static PyObject *
PyGccLocation_get_file(struct PyGccLocation *self, void *closure)
{
return PyGccString_FromString(gcc_location_get_filename(self->loc));
}
""")
cu.add_defn("""
static PyObject *
PyGccLocation_get_line(struct PyGccLocation *self, void *closure)
{
return PyGccInt_FromLong(gcc_location_get_line(self->loc));
}
""")
cu.add_defn("""
static PyObject *
PyGccLocation_get_column(struct PyGccLocation *self, void *closure)
{
return PyGccInt_FromLong(gcc_location_get_column(self->loc));
}
""")
getsettable = PyGetSetDefTable('PyGccLocation_getset_table',
[PyGetSetDef('file', 'PyGccLocation_get_file', None, 'Name of the source file'),
PyGetSetDef('line', 'PyGccLocation_get_line', None, 'Line number within source file'),
PyGetSetDef('column', 'PyGccLocation_get_column', None, 'Column number within source file'),
],
identifier_prefix='PyGccLocation',
typename='PyGccLocation')
getsettable.add_simple_getter(cu,
'in_system_header',
'PyBool_FromLong(gcc_location_in_system_header_at(self->loc))',
'Boolean: is this location within a system header?')
cu.add_defn(getsettable.c_defn())
pytype = PyGccWrapperTypeObject(identifier = 'PyGccLocation_TypeObj',
localname = 'Location',
tp_name = 'gcc.Location',
struct_name = 'PyGccLocation',
tp_new = 'PyType_GenericNew',
tp_getset = getsettable.identifier,
tp_hash = '(hashfunc)PyGccLocation_hash',
tp_repr = '(reprfunc)PyGccLocation_repr',
tp_str = '(reprfunc)PyGccLocation_str',
tp_richcompare = 'PyGccLocation_richcompare',
tp_dealloc = 'PyGccWrapper_Dealloc')
cu.add_defn(pytype.c_defn())
modinit_preinit += pytype.c_invoke_type_ready()
modinit_postinit += pytype.c_invoke_add_to_module()
示例4: generate_function
def generate_function():
#
# Generate the gcc.Function class:
#
global modinit_preinit
global modinit_postinit
cu.add_defn("\n"
"static PyObject *\n"
"PyGccFunction_get_cfg(struct PyGccFunction *self, void *closure)\n"
"{\n"
" return PyGccCfg_New(gcc_function_get_cfg(self->fun));\n"
"}\n"
"\n")
getsettable = PyGetSetDefTable('PyGccFunction_getset_table',
[PyGetSetDef('cfg', 'PyGccFunction_get_cfg', None,
'Instance of gcc.Cfg for this function (or None for early passes)'),
],
identifier_prefix='PyGccFunction',
typename='PyGccFunction')
getsettable.add_simple_getter(cu,
'decl',
'PyGccTree_New(gcc_function_decl_as_gcc_tree(gcc_function_get_decl(self->fun)))',
'The declaration of this function, as a gcc.FunctionDecl instance')
getsettable.add_simple_getter(cu,
'local_decls',
'VEC_tree_as_PyList(self->fun.inner->local_decls)',
"List of gcc.VarDecl for the function's local variables")
getsettable.add_simple_getter(cu,
'funcdef_no',
'PyGccInt_FromLong(gcc_function_get_index(self->fun))',
'Function sequence number for profiling, debugging, etc.')
getsettable.add_simple_getter(cu,
'start',
'PyGccLocation_New(gcc_function_get_start(self->fun))',
'Location of the start of the function')
getsettable.add_simple_getter(cu,
'end',
'PyGccLocation_New(gcc_function_get_end(self->fun))',
'Location of the end of the function')
cu.add_defn(getsettable.c_defn())
pytype = PyGccWrapperTypeObject(identifier = 'PyGccFunction_TypeObj',
localname = 'Function',
tp_name = 'gcc.Function',
tp_dealloc = 'PyGccWrapper_Dealloc',
struct_name = 'PyGccFunction',
tp_new = 'PyType_GenericNew',
tp_repr = '(reprfunc)PyGccFunction_repr',
tp_str = '(reprfunc)PyGccFunction_repr',
tp_hash = '(hashfunc)PyGccFunction_hash',
tp_richcompare = 'PyGccFunction_richcompare',
tp_getset = getsettable.identifier,
)
cu.add_defn(pytype.c_defn())
modinit_preinit += pytype.c_invoke_type_ready()
modinit_postinit += pytype.c_invoke_add_to_module()
示例5: generate_param
def generate_param():
#
# Generate the gcc.Parameter class:
#
global modinit_preinit
global modinit_postinit
getsettable = PyGetSetDefTable('PyGccParameter_getset_table', [],
identifier_prefix='PyGccParameter',
typename='PyGccParameter')
def add_simple_getter(name, c_expression, doc):
getsettable.add_simple_getter(cu, name, c_expression, doc)
add_simple_getter('option',
'PyGccStringOrNone(PARAM_INFO(self).option)',
"(string) The name used with the `--param <name>=<value>' switch to set this value")
add_simple_getter('default_value',
'PyGccInt_FromLong(PARAM_INFO(self).default_value)',
"(int/long)")
add_simple_getter('min_value',
'PyGccInt_FromLong(PARAM_INFO(self).min_value)',
"(int/long) The minimum acceptable value")
add_simple_getter('max_value',
'PyGccInt_FromLong(PARAM_INFO(self).max_value)',
"(int/long) The maximum acceptable value, if greater than min_value")
add_simple_getter('help',
'PyGccStringOrNone(PARAM_INFO(self).help)',
"(string) A short description of the option.")
# "current_value":
getter = cu.add_simple_getter('PyGccParameter_get_current_value',
'PyGccParameter',
'PyGccInt_FromLong(PARAM_VALUE(self->param_num))')
setter = cu.add_simple_int_setter('PyGccParameter_set_current_value',
'PyGccParameter',
'current_value',
'global_options.x_param_values[self->param_num] = PyGccInt_AsLong(value)') #FIXME
getsettable.add_gsdef('current_value',
getter, setter,
"(int/long)")
cu.add_defn(getsettable.c_defn())
pytype = PyGccWrapperTypeObject(identifier = 'PyGccParameter_TypeObj',
localname = 'Parameter',
tp_name = 'gcc.Parameter',
tp_dealloc = 'PyGccWrapper_Dealloc',
struct_name = 'PyGccParameter',
tp_new = 'PyType_GenericNew',
tp_getset = getsettable.identifier,
#tp_repr = '(reprfunc)PyGccParameter_repr',
#tp_str = '(reprfunc)PyGccParameter_str',
)
cu.add_defn(pytype.c_defn())
modinit_preinit += pytype.c_invoke_type_ready()
modinit_postinit += pytype.c_invoke_add_to_module()
示例6: generate_function
def generate_function():
#
# Generate the gcc.Function class:
#
global modinit_preinit
global modinit_postinit
cu.add_defn("\n"
"static PyObject *\n"
"gcc_Function_get_cfg(struct PyGccFunction *self, void *closure)\n"
"{\n"
" return gcc_python_make_wrapper_cfg(self->fun->cfg);\n"
"}\n"
"\n")
getsettable = PyGetSetDefTable('gcc_Function_getset_table',
[PyGetSetDef('cfg', 'gcc_Function_get_cfg', None,
'Instance of gcc.Cfg for this function (or None for early passes)'),
],
identifier_prefix='gcc_Function',
typename='PyGccFunction')
getsettable.add_simple_getter(cu,
'decl',
'gcc_python_make_wrapper_tree(self->fun->decl)',
'The declaration of this function, as a gcc.FunctionDecl instance')
getsettable.add_simple_getter(cu,
'local_decls',
'VEC_tree_as_PyList(self->fun->local_decls)',
"List of gcc.VarDecl for the function's local variables")
getsettable.add_simple_getter(cu,
'funcdef_no',
'gcc_python_int_from_long(self->fun->funcdef_no)',
'Function sequence number for profiling, debugging, etc.')
getsettable.add_simple_getter(cu,
'start',
'gcc_python_make_wrapper_location(self->fun->function_start_locus)',
'Location of the start of the function')
getsettable.add_simple_getter(cu,
'end',
'gcc_python_make_wrapper_location(self->fun->function_end_locus)',
'Location of the end of the function')
cu.add_defn(getsettable.c_defn())
pytype = PyGccWrapperTypeObject(identifier = 'gcc_FunctionType',
localname = 'Function',
tp_name = 'gcc.Function',
tp_dealloc = 'gcc_python_wrapper_dealloc',
struct_name = 'PyGccFunction',
tp_new = 'PyType_GenericNew',
tp_repr = '(reprfunc)gcc_Function_repr',
tp_str = '(reprfunc)gcc_Function_repr',
tp_getset = getsettable.identifier,
)
cu.add_defn(pytype.c_defn())
modinit_preinit += pytype.c_invoke_type_ready()
modinit_postinit += pytype.c_invoke_add_to_module()
示例7: generate_option
def generate_option():
#
# Generate the gcc.Option class:
#
global modinit_preinit
global modinit_postinit
getsettable = PyGetSetDefTable('PyGccOption_getset_table', [],
identifier_prefix='PyGccOption',
typename='PyGccOption')
def add_simple_getter(name, c_expression, doc):
getsettable.add_simple_getter(cu, name, c_expression, doc)
add_simple_getter('text',
'PyGccStringOrNone(PyGcc_option_to_cl_option(self)->opt_text)',
'(string) The command-line text used to set this option')
add_simple_getter('help',
'PyGccStringOrNone(PyGcc_option_to_cl_option(self)->help)',
'(string) The help text shown for this option')
for flag, helptext in (
('CL_WARNING', '(bool) Does this option control a warning message?'),
('CL_OPTIMIZATION', '(bool) Does this option control an optimization?'),
('CL_DRIVER', '(bool) Is this a driver option?'),
('CL_TARGET', '(bool) Is this a target-specific option?'),
):
add_simple_getter('is_%s' % flag[3:].lower(),
'PyBool_FromLong(PyGcc_option_to_cl_option(self)->flags & %s)' % flag,
helptext)
getsettable.add_gsdef('is_enabled',
'PyGccOption_is_enabled',
None,
'True/False for whether or not this option is enabled, raising a '
'NotImplementedError for options for which the plugin cannot tell')
cu.add_defn(getsettable.c_defn())
pytype = PyGccWrapperTypeObject(identifier = 'PyGccOption_TypeObj',
localname = 'Option',
tp_name = 'gcc.Option',
tp_dealloc = 'PyGccWrapper_Dealloc',
struct_name = 'PyGccOption',
tp_init = 'PyGccOption_init',
tp_getset = getsettable.identifier,
tp_repr = '(reprfunc)PyGccOption_repr',
#tp_str = '(reprfunc)PyGccOption_str',
#tp_richcompare = 'PyGccOption_richcompare'
)
cu.add_defn(pytype.c_defn())
modinit_preinit += pytype.c_invoke_type_ready()
modinit_postinit += pytype.c_invoke_add_to_module()
示例8: generate_edge
def generate_edge():
#
# Generate the gcc.Edge class:
#
global modinit_preinit
global modinit_postinit
getsettable = PyGetSetDefTable('PyGccEdge_getset_table',
[PyGetSetDef('src',
cu.add_simple_getter('PyGccEdge_get_src',
'PyGccEdge',
'PyGccBasicBlock_New(gcc_cfg_edge_get_src(self->e))'),
None,
'The source gcc.BasicBlock of this edge'),
PyGetSetDef('dest',
cu.add_simple_getter('PyGccEdge_get_dest',
'PyGccEdge',
'PyGccBasicBlock_New(gcc_cfg_edge_get_dest(self->e))'),
None,
'The destination gcc.BasicBlock of this edge')],
identifier_prefix = 'PyGccEdge',
typename = 'PyGccEdge')
# We only expose the subset of the flags exposed by gcc-c-api
for attrname, flaggetter in [('true_value', 'is_true_value'),
('false_value', 'is_false_value'),
('loop_exit', 'is_loop_exit'),
('can_fallthru', 'get_can_fallthru'),
('complex', 'is_complex'),
('eh', 'is_eh'),
]:
getsettable.add_simple_getter(cu,
attrname,
'PyBool_FromLong(gcc_cfg_edge_%s(self->e))' % flaggetter,
None)
cu.add_defn(getsettable.c_defn())
pytype = PyGccWrapperTypeObject(identifier = 'PyGccEdge_TypeObj',
localname = 'Edge',
tp_name = 'gcc.Edge',
tp_dealloc = 'PyGccWrapper_Dealloc',
struct_name = 'PyGccEdge',
tp_new = 'PyType_GenericNew',
#tp_repr = '(reprfunc)PyGccEdge_repr',
#tp_str = '(reprfunc)PyGccEdge_repr',
tp_getset = getsettable.identifier,
)
cu.add_defn(pytype.c_defn())
modinit_preinit += pytype.c_invoke_type_ready()
modinit_postinit += pytype.c_invoke_add_to_module()
示例9: generate_basic_block
def generate_basic_block():
#
# Generate the gcc.BasicBlock class:
#
global modinit_preinit
global modinit_postinit
getsettable = PyGetSetDefTable('PyGccBasicBlock_getset_table',
[PyGetSetDef('preds',
'PyGccBasicBlock_get_preds',
None,
'The list of predecessor gcc.Edge instances leading into this block'),
PyGetSetDef('succs',
'PyGccBasicBlock_get_succs',
None,
'The list of successor gcc.Edge instances leading out of this block'),
PyGetSetDef('gimple',
'PyGccBasicBlock_get_gimple',
'PyGccBasicBlock_set_gimple',
'The list of gcc.Gimple instructions, if appropriate for this pass, or None'),
PyGetSetDef('phi_nodes',
'PyGccBasicBlock_get_phi_nodes',
None,
'The list of gcc.GimplePhi phoney functions, if appropriate for this pass, or None'),
PyGetSetDef('rtl',
'PyGccBasicBlock_get_rtl',
None,
'The list of gcc.Rtl instructions, if appropriate for this pass, or None'),
],
identifier_prefix='PyGccBasicBlock',
typename='PyGccBasicBlock')
getsettable.add_simple_getter(cu,
'index',
'PyGccInt_FromLong(gcc_cfg_block_get_index(self->bb))',
None)
cu.add_defn(getsettable.c_defn())
pytype = PyGccWrapperTypeObject(identifier = 'PyGccBasicBlock_TypeObj',
localname = 'BasicBlock',
tp_name = 'gcc.BasicBlock',
tp_dealloc = 'PyGccWrapper_Dealloc',
struct_name = 'PyGccBasicBlock',
tp_new = 'PyType_GenericNew',
tp_repr = '(reprfunc)PyGccBasicBlock_repr',
#tp_str = '(reprfunc)PyGccBasicBlock_repr',
tp_getset = getsettable.identifier,
)
cu.add_defn(pytype.c_defn())
modinit_preinit += pytype.c_invoke_type_ready()
modinit_postinit += pytype.c_invoke_add_to_module()
示例10: generate_edge
def generate_edge():
#
# Generate the gcc.Edge class:
#
global modinit_preinit
global modinit_postinit
getsettable = PyGetSetDefTable('gcc_Edge_getset_table',
[PyGetSetDef('src',
cu.add_simple_getter('gcc_Edge_get_src',
'PyGccEdge',
'gcc_python_make_wrapper_basic_block(self->e->src)'),
None,
'The source gcc.BasicBlock of this edge'),
PyGetSetDef('dest',
cu.add_simple_getter('gcc_Edge_get_dest',
'PyGccEdge',
'gcc_python_make_wrapper_basic_block(self->e->dest)'),
None,
'The destination gcc.BasicBlock of this edge')],
identifier_prefix = 'gcc_Edge',
typename = 'PyGccEdge')
for flag in ('EDGE_FALLTHRU', 'EDGE_ABNORMAL', 'EDGE_ABNORMAL_CALL',
'EDGE_EH', 'EDGE_FAKE', 'EDGE_DFS_BACK', 'EDGE_CAN_FALLTHRU',
'EDGE_IRREDUCIBLE_LOOP', 'EDGE_SIBCALL', 'EDGE_LOOP_EXIT',
'EDGE_TRUE_VALUE', 'EDGE_FALSE_VALUE', 'EDGE_EXECUTABLE',
'EDGE_CROSSING'):
assert flag.startswith('EDGE_')
flagname = flag[5:].lower()
getsettable.add_simple_getter(cu,
flagname,
'PyBool_FromLong(self->e->flags & %s)' % flag,
'Boolean, corresponding to flag %s' % flag)
cu.add_defn(getsettable.c_defn())
pytype = PyGccWrapperTypeObject(identifier = 'gcc_EdgeType',
localname = 'Edge',
tp_name = 'gcc.Edge',
tp_dealloc = 'gcc_python_wrapper_dealloc',
struct_name = 'PyGccEdge',
tp_new = 'PyType_GenericNew',
#tp_repr = '(reprfunc)gcc_Edge_repr',
#tp_str = '(reprfunc)gcc_Edge_repr',
tp_getset = getsettable.identifier,
)
cu.add_defn(pytype.c_defn())
modinit_preinit += pytype.c_invoke_type_ready()
modinit_postinit += pytype.c_invoke_add_to_module()
示例11: generate_cfg
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()
示例12: generate_intermediate_rtx_class_subclasses
def generate_intermediate_rtx_class_subclasses():
global modinit_preinit
global modinit_postinit
for rtx_class in enum_rtx_class:
cc = camel_case(rtx_class)
pytype = PyGccWrapperTypeObject(identifier = 'PyGccRtlClassType%s_TypeObj' % cc,
localname = 'RtlClassType' + cc,
tp_name = 'gcc.%s' % cc,
struct_name = 'PyGccRtl',
tp_new = 'PyType_GenericNew',
tp_base = '&PyGccRtl_TypeObj',
#tp_getset = getsettable.identifier,
#tp_repr = '(reprfunc)PyGccRtl_repr',
#tp_str = '(reprfunc)PyGccRtl_str',
)
cu.add_defn(pytype.c_defn())
modinit_preinit += pytype.c_invoke_type_ready()
modinit_postinit += pytype.c_invoke_add_to_module()
示例13: generate_pass_subclasses
def generate_pass_subclasses():
global modinit_preinit
global modinit_postinit
for opt_pass_type in ('GIMPLE_PASS', 'RTL_PASS',
'SIMPLE_IPA_PASS', 'IPA_PASS'):
cc = camel_case(opt_pass_type)
pytype = PyGccWrapperTypeObject(identifier = 'PyGcc%s_TypeObj' % cc,
localname = cc,
tp_name = 'gcc.%s' % cc,
tp_dealloc = 'PyGccWrapper_Dealloc',
struct_name = 'PyGccPass',
tp_new = 'PyType_GenericNew',
tp_init = 'PyGcc%s_init' % cc,
tp_base = '&PyGccPass_TypeObj',
tp_flags = '(Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE)'
)
cu.add_defn(pytype.c_defn())
modinit_preinit += pytype.c_invoke_type_ready()
modinit_postinit += pytype.c_invoke_add_to_module()
示例14: generate_gimple_struct_subclasses
def generate_gimple_struct_subclasses():
global modinit_preinit
global modinit_postinit
for gt in gimple_struct_types:
#print gimple_types
cc = gt.camel_cased_string()
pytype = PyGccWrapperTypeObject(identifier = 'PyGccGimpleStructType%s_TypeObj' % cc,
localname = 'GimpleStructType' + cc,
tp_name = 'gcc.GimpleStructType%s' % cc,
tp_dealloc = 'PyGccWrapper_Dealloc',
struct_name = 'PyGccGimple',
tp_new = 'PyType_GenericNew',
tp_base = '&PyGccGimple_TypeObj',
#tp_getset = getsettable.identifier,
#tp_repr = '(reprfunc)PyGccGimple_repr',
#tp_str = '(reprfunc)PyGccGimple_str',
)
cu.add_defn(pytype.c_defn())
modinit_preinit += pytype.c_invoke_type_ready()
modinit_postinit += pytype.c_invoke_add_to_module()
示例15: generate_rtl_base_class
def generate_rtl_base_class():
#
# Generate the gcc.Rtl class:
#
global modinit_preinit
global modinit_postinit
'''
cu.add_defn("""
static PyObject *
PyGccRtl_get_block(struct PyGccRtl *self, void *closure)
{
return PyGccTree_New(rtl_block(self->stmt));
}
""")
'''
getsettable = PyGetSetDefTable('PyGccRtl_getset_table', [])
if GCC_VERSION < 5000:
getsettable.add_gsdef('loc',
'PyGccRtl_get_location',
None,
'Source code location of this instruction, as a gcc.Location')
getsettable.add_gsdef('operands',
'PyGccRtl_get_operands',
None,
'Operands of this expression, as a tuple')
cu.add_defn(getsettable.c_defn())
pytype = PyGccWrapperTypeObject(identifier = 'PyGccRtl_TypeObj',
localname = 'Rtl',
tp_name = 'gcc.Rtl',
tp_dealloc = 'PyGccWrapper_Dealloc',
struct_name = 'PyGccRtl',
tp_new = 'PyType_GenericNew',
tp_getset = getsettable.identifier,
tp_repr = '(reprfunc)PyGccRtl_repr',
tp_str = '(reprfunc)PyGccRtl_str',
)
cu.add_defn(pytype.c_defn())
modinit_preinit += pytype.c_invoke_type_ready()
modinit_postinit += pytype.c_invoke_add_to_module()