Пример #1
0
def CreateContext():
    'create the context where a interface file will be executed'
    context = {}
    context['Import'] = Import
    # infos
    context['Function'] = infos.FunctionInfo
    context['Class'] = infos.ClassInfo
    context['Include'] = lambda header: infos.CodeInfo(
        '#include <%s>\n' % header, 'include')
    context['PCHInclude'] = PCHInclude
    context['Template'] = infos.ClassTemplateInfo
    context['Enum'] = infos.EnumInfo
    context['AllFromHeader'] = infos.HeaderInfo
    context['Var'] = infos.VarInfo
    # functions
    context['rename'] = infos.rename
    context['set_policy'] = infos.set_policy
    context['exclude'] = infos.exclude
    context['set_wrapper'] = infos.set_wrapper
    context['use_shared_ptr'] = infos.use_shared_ptr
    context['use_auto_ptr'] = infos.use_auto_ptr
    context['holder'] = infos.holder
    context['add_method'] = infos.add_method
    context['final'] = infos.final
    context['no_init'] = infos.no_init
    context['no_virtual'] = infos.no_virtual
    context['export_values'] = infos.export_values
    # policies
    context['return_internal_reference'] = return_internal_reference
    context['with_custodian_and_ward'] = with_custodian_and_ward
    context['return_value_policy'] = return_value_policy
    context['reference_existing_object'] = reference_existing_object
    context['copy_const_reference'] = copy_const_reference
    context['copy_non_const_reference'] = copy_non_const_reference
    context['return_opaque_pointer'] = return_opaque_pointer
    context['manage_new_object'] = manage_new_object
    context['return_by_value'] = return_by_value
    context['return_self'] = return_self
    # utils
    context['Wrapper'] = exporterutils.FunctionWrapper
    context['declaration_code'] = lambda code: infos.CodeInfo(
        code, 'declaration-outside')
    context['module_code'] = lambda code: infos.CodeInfo(code, 'module')
    context['class_code'] = infos.class_code
    return context
def PCHInclude(*headers):
    code = '\n'.join(['#include <%s>' % x for x in headers])
    infos.CodeInfo(code, 'pchinclude')