Naming.py 6.2 KB

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