1# 2# C naming conventions 3# 4# 5# Prefixes for generating C names. 6# Collected here to facilitate ensuring uniqueness. 7# 8 9pyrex_prefix = "__pyx_" 10 11 12codewriter_temp_prefix = pyrex_prefix + "t_" 13 14temp_prefix = u"__cyt_" 15 16builtin_prefix = pyrex_prefix + "builtin_" 17arg_prefix = pyrex_prefix + "arg_" 18funcdoc_prefix = pyrex_prefix + "doc_" 19enum_prefix = pyrex_prefix + "e_" 20func_prefix = pyrex_prefix + "f_" 21pyfunc_prefix = pyrex_prefix + "pf_" 22pywrap_prefix = pyrex_prefix + "pw_" 23genbody_prefix = pyrex_prefix + "gb_" 24gstab_prefix = pyrex_prefix + "getsets_" 25prop_get_prefix = pyrex_prefix + "getprop_" 26const_prefix = pyrex_prefix + "k_" 27py_const_prefix = pyrex_prefix + "kp_" 28label_prefix = pyrex_prefix + "L" 29pymethdef_prefix = pyrex_prefix + "mdef_" 30methtab_prefix = pyrex_prefix + "methods_" 31memtab_prefix = pyrex_prefix + "members_" 32objstruct_prefix = pyrex_prefix + "obj_" 33typeptr_prefix = pyrex_prefix + "ptype_" 34prop_set_prefix = pyrex_prefix + "setprop_" 35type_prefix = pyrex_prefix + "t_" 36typeobj_prefix = pyrex_prefix + "type_" 37var_prefix = pyrex_prefix + "v_" 38varptr_prefix = pyrex_prefix + "vp_" 39wrapperbase_prefix= pyrex_prefix + "wrapperbase_" 40pybuffernd_prefix = pyrex_prefix + "pybuffernd_" 41pybufferstruct_prefix = pyrex_prefix + "pybuffer_" 42vtable_prefix = pyrex_prefix + "vtable_" 43vtabptr_prefix = pyrex_prefix + "vtabptr_" 44vtabstruct_prefix = pyrex_prefix + "vtabstruct_" 45opt_arg_prefix = pyrex_prefix + "opt_args_" 46convert_func_prefix = pyrex_prefix + "convert_" 47closure_scope_prefix = pyrex_prefix + "scope_" 48closure_class_prefix = pyrex_prefix + "scope_struct_" 49lambda_func_prefix = pyrex_prefix + "lambda_" 50module_is_main = pyrex_prefix + "module_is_main_" 51defaults_struct_prefix = pyrex_prefix + "defaults" 52dynamic_args_cname = pyrex_prefix + "dynamic_args" 53 54interned_prefixes = { 55 'str': pyrex_prefix + "n_", 56 'int': pyrex_prefix + "int_", 57 'float': pyrex_prefix + "float_", 58 'tuple': pyrex_prefix + "tuple_", 59 'codeobj': pyrex_prefix + "codeobj_", 60 'slice': pyrex_prefix + "slice_", 61 'ustring': pyrex_prefix + "ustring_", 62} 63 64args_cname = pyrex_prefix + "args" 65generator_cname = pyrex_prefix + "generator" 66sent_value_cname = pyrex_prefix + "sent_value" 67pykwdlist_cname = pyrex_prefix + "pyargnames" 68obj_base_cname = pyrex_prefix + "base" 69builtins_cname = pyrex_prefix + "b" 70preimport_cname = pyrex_prefix + "i" 71moddict_cname = pyrex_prefix + "d" 72dummy_cname = pyrex_prefix + "dummy" 73filename_cname = pyrex_prefix + "filename" 74modulename_cname = pyrex_prefix + "modulename" 75filetable_cname = pyrex_prefix + "f" 76intern_tab_cname = pyrex_prefix + "intern_tab" 77kwds_cname = pyrex_prefix + "kwds" 78lineno_cname = pyrex_prefix + "lineno" 79clineno_cname = pyrex_prefix + "clineno" 80cfilenm_cname = pyrex_prefix + "cfilenm" 81module_cname = pyrex_prefix + "m" 82moddoc_cname = pyrex_prefix + "mdoc" 83methtable_cname = pyrex_prefix + "methods" 84retval_cname = pyrex_prefix + "r" 85reqd_kwds_cname = pyrex_prefix + "reqd_kwds" 86self_cname = pyrex_prefix + "self" 87stringtab_cname = pyrex_prefix + "string_tab" 88vtabslot_cname = pyrex_prefix + "vtab" 89c_api_tab_cname = pyrex_prefix + "c_api_tab" 90gilstate_cname = pyrex_prefix + "state" 91skip_dispatch_cname = pyrex_prefix + "skip_dispatch" 92empty_tuple = pyrex_prefix + "empty_tuple" 93empty_bytes = pyrex_prefix + "empty_bytes" 94print_function = pyrex_prefix + "print" 95print_function_kwargs = pyrex_prefix + "print_kwargs" 96cleanup_cname = pyrex_prefix + "module_cleanup" 97pymoduledef_cname = pyrex_prefix + "moduledef" 98optional_args_cname = pyrex_prefix + "optional_args" 99import_star = pyrex_prefix + "import_star" 100import_star_set = pyrex_prefix + "import_star_set" 101outer_scope_cname= pyrex_prefix + "outer_scope" 102cur_scope_cname = pyrex_prefix + "cur_scope" 103enc_scope_cname = pyrex_prefix + "enc_scope" 104frame_cname = pyrex_prefix + "frame" 105frame_code_cname = pyrex_prefix + "frame_code" 106binding_cfunc = pyrex_prefix + "binding_PyCFunctionType" 107fused_func_prefix = pyrex_prefix + 'fuse_' 108quick_temp_cname = pyrex_prefix + "temp" # temp variable for quick'n'dirty temping 109 110global_code_object_cache_find = pyrex_prefix + 'find_code_object' 111global_code_object_cache_insert = pyrex_prefix + 'insert_code_object' 112 113genexpr_id_ref = 'genexpr' 114freelist_name = 'freelist' 115freecount_name = 'freecount' 116 117line_c_macro = "__LINE__" 118 119file_c_macro = "__FILE__" 120 121extern_c_macro = pyrex_prefix.upper() + "EXTERN_C" 122 123exc_type_name = pyrex_prefix + "exc_type" 124exc_value_name = pyrex_prefix + "exc_value" 125exc_tb_name = pyrex_prefix + "exc_tb" 126exc_lineno_name = pyrex_prefix + "exc_lineno" 127 128parallel_exc_type = pyrex_prefix + "parallel_exc_type" 129parallel_exc_value = pyrex_prefix + "parallel_exc_value" 130parallel_exc_tb = pyrex_prefix + "parallel_exc_tb" 131parallel_filename = pyrex_prefix + "parallel_filename" 132parallel_lineno = pyrex_prefix + "parallel_lineno" 133parallel_clineno = pyrex_prefix + "parallel_clineno" 134parallel_why = pyrex_prefix + "parallel_why" 135 136exc_vars = (exc_type_name, exc_value_name, exc_tb_name) 137 138api_name = pyrex_prefix + "capi__" 139 140h_guard_prefix = "__PYX_HAVE__" 141api_guard_prefix = "__PYX_HAVE_API__" 142api_func_guard = "__PYX_HAVE_API_FUNC_" 143 144PYX_NAN = "__PYX_NAN()" 145 146def py_version_hex(major, minor=0, micro=0, release_level=0, release_serial=0): 147 return (major << 24) | (minor << 16) | (micro << 8) | (release_level << 4) | (release_serial) 148