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