|
| 1 | +#ifndef STATIC_DATA |
| 2 | +#define STATIC_DATA |
| 3 | + |
| 4 | +#include "static_data.h" |
| 5 | + |
| 6 | +// Adopted from numpy 2.4.0: numpy/_core/src/multiarry/npy_static_data.c |
| 7 | + |
| 8 | +mypyc_interned_str_struct mypyc_interned_str; |
| 9 | + |
| 10 | +#define INTERN_STRING(struct_member, string) \ |
| 11 | + assert(mypyc_interned_str.struct_member == NULL); \ |
| 12 | + mypyc_interned_str.struct_member = PyUnicode_InternFromString(string); \ |
| 13 | + if (mypyc_interned_str.struct_member == NULL) { \ |
| 14 | + return -1; \ |
| 15 | + } |
| 16 | + |
| 17 | +int |
| 18 | +intern_strings(void) { |
| 19 | + INTERN_STRING(__init_subclass__, "__init_subclass__"); |
| 20 | + INTERN_STRING(__mro_entries__, "__mro_entries__"); |
| 21 | + INTERN_STRING(__name__, "__name__"); |
| 22 | + INTERN_STRING(__radd__, "__radd__"); |
| 23 | + INTERN_STRING(__rsub__, "__rsub__"); |
| 24 | + INTERN_STRING(__rmul__, "__rmul__"); |
| 25 | + INTERN_STRING(__rtruediv__, "__rtruediv__"); |
| 26 | + INTERN_STRING(__rmod__, "__rmod__"); |
| 27 | + INTERN_STRING(__rdivmod__, "__rdivmod__"); |
| 28 | + INTERN_STRING(__rfloordiv__, "__rfloordiv__"); |
| 29 | + INTERN_STRING(__rpow__, "__rpow__"); |
| 30 | + INTERN_STRING(__rmatmul__, "__rmatmul__"); |
| 31 | + INTERN_STRING(__rand__, "__rand__"); |
| 32 | + INTERN_STRING(__ror__, "__ror__"); |
| 33 | + INTERN_STRING(__rxor__, "__rxor__"); |
| 34 | + INTERN_STRING(__rlshift__, "__rlshift__"); |
| 35 | + INTERN_STRING(__rrshift__, "__rrshift__"); |
| 36 | + INTERN_STRING(__eq__, "__eq__"); |
| 37 | + INTERN_STRING(__ne__, "__ne__"); |
| 38 | + INTERN_STRING(__gt__, "__gt__"); |
| 39 | + INTERN_STRING(__le__, "__le__"); |
| 40 | + INTERN_STRING(__lt__, "__lt__"); |
| 41 | + INTERN_STRING(__ge__, "__ge__"); |
| 42 | + INTERN_STRING(clear, "clear"); |
| 43 | + INTERN_STRING(close_, "close"); |
| 44 | + INTERN_STRING(copy, "copy"); |
| 45 | + INTERN_STRING(keys, "keys"); |
| 46 | + INTERN_STRING(items, "items"); |
| 47 | + INTERN_STRING(join, "join"); |
| 48 | + INTERN_STRING(send, "send"); |
| 49 | + INTERN_STRING(setdefault, "setdefault"); |
| 50 | + INTERN_STRING(startswith, "startswith"); |
| 51 | + INTERN_STRING(throw_, "throw"); |
| 52 | + INTERN_STRING(translate, "translate"); |
| 53 | + INTERN_STRING(update, "update"); |
| 54 | + INTERN_STRING(values, "values"); |
| 55 | + return 0; |
| 56 | +} |
| 57 | + |
| 58 | +#endif |
0 commit comments