Changeset 119
- Timestamp:
- 07/25/07 20:15:18 (5 years ago)
- Files:
-
- trunk/dcompiler.py (modified) (2 diffs)
- trunk/infrastructure/python/2.4 (deleted)
- trunk/infrastructure/python/2.5 (deleted)
- trunk/infrastructure/python/python.d (copied) (copied from trunk/infrastructure/python/2.5/python.d) (43 diffs)
- trunk/infrastructure/python/python24_digitalmars.lib (copied) (copied from trunk/infrastructure/python/2.4/python24_digitalmars.lib)
- trunk/infrastructure/python/python25_digitalmars.lib (copied) (copied from trunk/infrastructure/python/2.5/python25_digitalmars.lib)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/dcompiler.py
r112 r119 161 161 # To sources, add the appropriate D header file python.d, as well as 162 162 # any platform-specific boilerplate. 163 pythonHeaderPath = os.path.join(_infraDir, 'python', _pyVerXDotY,'python.d')163 pythonHeaderPath = os.path.join(_infraDir, 'python', 'python.d') 164 164 # Add the python header's directory to the include path 165 165 includePathOpts += self._includeOpts 166 includePathOpts[-1] = includePathOpts[-1] % os.path.join(_infraDir, 'python' , _pyVerXDotY)166 includePathOpts[-1] = includePathOpts[-1] % os.path.join(_infraDir, 'python') 167 167 if not os.path.isfile(pythonHeaderPath): 168 168 raise DistutilsPlatformError('Required D translation of Python' … … 450 450 # more convenient to distribute a pre-extracted .lib file to the 451 451 # users and spare them the need for the "Basic Utilities" package. 452 pythonDMDLibPath = _qp(os.path.join(_infraDir, 'python', _pyVerXDotY,452 pythonDMDLibPath = _qp(os.path.join(_infraDir, 'python', 453 453 'python%s_digitalmars.lib' % _pyVerXY 454 454 )) trunk/infrastructure/python/python.d
r107 r119 15 15 version (DigitalMars) { 16 16 version (Windows) { 17 pragma(link, "python25_digitalmars"); 17 version (Python_2_5_Or_Later) { 18 pragma(link, "python25_digitalmars"); 19 } else { 20 pragma(link, "python24_digitalmars"); 21 } 18 22 } 19 23 } else { 20 pragma(link, "python2.5"); 24 version (Python_2_5_Or_Later) { 25 pragma(link, "python2.5"); 26 } else { 27 pragma(link, "python2.4"); 28 } 21 29 } 22 30 } … … 57 65 * bytes on X86. 58 66 */ 59 version (X86_64) { 60 alias long Py_ssize_t; 67 version (Python_2_5_Or_Later) { 68 version (X86_64) { 69 alias long Py_ssize_t; 70 } else { 71 alias int Py_ssize_t; 72 } 61 73 } else { 62 alias intPy_ssize_t;74 alias C_long Py_ssize_t; 63 75 } 64 76 … … 179 191 binaryfunc nb_inplace_true_divide; 180 192 181 /* Added in release 2.5 */ 182 unaryfunc nb_index; 193 version (Python_2_5_Or_Later) { 194 unaryfunc nb_index; 195 } 183 196 } 184 197 … … 293 306 294 307 struct _heaptypeobject { 308 // Some of these names changed between 2.4 and 2.5; not a serious issue. 295 309 PyTypeObject ht_type; 296 310 PyNumberMethods as_number; … … 396 410 const int Py_TPFLAGS_HAVE_STACKLESS_EXTENSION = 0; 397 411 //#endif 398 const int Py_TPFLAGS_HAVE_INDEX = 1L<<17; 412 version (Python_2_5_Or_Later) { 413 const int Py_TPFLAGS_HAVE_INDEX = 1L<<17; 414 } else { 415 const int Py_TPFLAGS_HAVE_INDEX = 0; 416 } 399 417 400 418 const int Py_TPFLAGS_DEFAULT = … … 602 620 PyObject *PyUnicodeUCS2_Split(PyObject *s, PyObject *sep, Py_ssize_t maxsplit); 603 621 PyObject *PyUnicodeUCS2_Splitlines(PyObject *s, int keepends); 604 PyObject *PyUnicodeUCS2_Partition(PyObject* s, PyObject* sep); 605 PyObject *PyUnicodeUCS2_RPartition(PyObject* s, PyObject* sep); 622 version (Python_2_5_Or_Later) { 623 PyObject *PyUnicodeUCS2_Partition(PyObject* s, PyObject* sep); 624 PyObject *PyUnicodeUCS2_RPartition(PyObject* s, PyObject* sep); 625 } 606 626 PyObject *PyUnicodeUCS2_RSplit(PyObject *s, PyObject *sep, Py_ssize_t maxsplit); 607 627 PyObject *PyUnicodeUCS2_Translate(PyObject *str, PyObject *table, char *errors); … … 726 746 PyObject *PyUnicodeUCS4_Split(PyObject *s, PyObject *sep, Py_ssize_t maxsplit); 727 747 PyObject *PyUnicodeUCS4_Splitlines(PyObject *s, int keepends); 728 PyObject *PyUnicodeUCS4_Partition(PyObject* s, PyObject* sep); 729 PyObject *PyUnicodeUCS4_RPartition(PyObject* s, PyObject* sep); 748 version (Python_2_5_Or_Later) { 749 PyObject *PyUnicodeUCS4_Partition(PyObject* s, PyObject* sep); 750 PyObject *PyUnicodeUCS4_RPartition(PyObject* s, PyObject* sep); 751 } 730 752 PyObject *PyUnicodeUCS4_RSplit(PyObject *s, PyObject *sep, Py_ssize_t maxsplit); 731 753 PyObject *PyUnicodeUCS4_Translate(PyObject *str, PyObject *table, char *errors); … … 814 836 alias PyUnicodeUCS2_GetSize PyUnicode_GetSize; 815 837 alias PyUnicodeUCS2_Join PyUnicode_Join; 816 alias PyUnicodeUCS2_Partition PyUnicode_Partition; 838 version (Python_2_5_Or_Later) { 839 alias PyUnicodeUCS2_Partition PyUnicode_Partition; 840 alias PyUnicodeUCS2_RPartition PyUnicode_RPartition; 841 } 817 842 alias PyUnicodeUCS2_Replace PyUnicode_Replace; 818 843 alias PyUnicodeUCS2_Resize PyUnicode_Resize; 819 844 alias PyUnicodeUCS2_SetDefaultEncoding PyUnicode_SetDefaultEncoding; 820 845 alias PyUnicodeUCS2_Split PyUnicode_Split; 821 alias PyUnicodeUCS2_RPartition PyUnicode_RPartition;822 846 alias PyUnicodeUCS2_RSplit PyUnicode_RSplit; 823 847 alias PyUnicodeUCS2_Splitlines PyUnicode_Splitlines; … … 889 913 alias PyUnicodeUCS4_GetSize PyUnicode_GetSize; 890 914 alias PyUnicodeUCS4_Join PyUnicode_Join; 891 alias PyUnicodeUCS4_Partition PyUnicode_Partition;892 915 alias PyUnicodeUCS4_Replace PyUnicode_Replace; 893 916 alias PyUnicodeUCS4_Resize PyUnicode_Resize; 894 alias PyUnicodeUCS4_RPartition PyUnicode_RPartition; 917 version (Python_2_5_Or_Later) { 918 alias PyUnicodeUCS4_Partition PyUnicode_Partition; 919 alias PyUnicodeUCS4_RPartition PyUnicode_RPartition; 920 } 895 921 alias PyUnicodeUCS4_RSplit PyUnicode_RSplit; 896 922 alias PyUnicodeUCS4_SetDefaultEncoding PyUnicode_SetDefaultEncoding; … … 993 1019 PyObject *PyInt_FromUnicode(Py_UNICODE *, Py_ssize_t, int); 994 1020 PyObject *PyInt_FromLong(C_long); 995 PyObject *PyInt_FromSize_t(size_t); 996 PyObject *PyInt_FromSsize_t(Py_ssize_t); 1021 version (Python_2_5_Or_Later) { 1022 PyObject *PyInt_FromSize_t(size_t); 1023 PyObject *PyInt_FromSsize_t(Py_ssize_t); 1024 } 997 1025 998 1026 C_long PyInt_AsLong(PyObject *); … … 1049 1077 1050 1078 PyObject * PyLong_FromDouble(double); 1051 PyObject * PyLong_FromVoidPtr(void *);1052 1079 1053 1080 C_long PyLong_AsLong(PyObject *); … … 1152 1179 1153 1180 // Removed in 2.5 1154 //PyObject * PyRange_New(C_long, C_long, C_long, int); 1181 version (Python_2_5_Or_Later) { 1182 } else { 1183 PyObject * PyRange_New(C_long, C_long, C_long, int); 1184 } 1155 1185 1156 1186 … … 1489 1519 char * PyModule_GetName(PyObject *); 1490 1520 char * PyModule_GetFilename(PyObject *); 1491 void _PyModule_Clear(PyObject *); 1521 version (Python_2_5_Or_Later) { 1522 void _PyModule_Clear(PyObject *); 1523 } 1492 1524 1493 1525 // Python-header-file: Include/modsupport.h: … … 1557 1589 int PyFunction_SetClosure(PyObject *, PyObject *); 1558 1590 1591 // These are not present in the 2.4 API, but do no harm in it, either. 1559 1592 PyObject* PyFunction_GET_CODE(PyObject* func) { 1560 1593 return (cast(PyFunctionObject*)func).func_code; … … 1644 1677 PyObject * _PyInstance_Lookup(PyObject *pinst, PyObject *name); 1645 1678 1679 // These are not present in the 2.4 API, but do no harm in it, either. 1646 1680 PyObject * PyMethod_GET_FUNCTION(PyObject* meth) { 1647 1681 return (cast(PyMethodObject*)meth).im_func; … … 1989 2023 1990 2024 /* Error objects */ 1991 2025 version (Python_2_5_Or_Later) { 1992 2026 struct PyBaseExceptionObject { 1993 2027 mixin PyObject_HEAD; … … 2052 2086 } 2053 2087 } 2088 } /*Python_2_5_Or_Later*/ 2054 2089 2055 2090 void PyErr_SetNone(PyObject *); … … 2093 2128 void PyErr_WriteUnraisable(PyObject *); 2094 2129 2095 //int PyErr_Warn(PyObject *, char *); 2096 int PyErr_WarnEx(PyObject*, char*, Py_ssize_t); 2130 version (Python_2_5_Or_Later) { 2131 int PyErr_WarnEx(PyObject*, char*, Py_ssize_t); 2132 } else { 2133 int PyErr_Warn(PyObject *, char *); 2134 } 2097 2135 int PyErr_WarnExplicit(PyObject *, char *, char *, int, char *, PyObject *); 2098 2136 … … 2169 2207 int co_firstlineno; 2170 2208 PyObject *co_lnotab; 2171 void *co_zombieframe; 2209 version (Python_2_5_Or_Later) { 2210 void *co_zombieframe; 2211 } 2172 2212 } 2173 2213 … … 2181 2221 const int CO_NOFREE = 0x0040; 2182 2222 2183 // Removed in 2.52184 //const int CO_GENERATOR_ALLOWED = 0x1000;2185 2223 const int CO_FUTURE_DIVISION = 0x2000; 2186 const int CO_FUTURE_ABSOLUTE_IMPORT = 0x4000; 2187 const int CO_FUTURE_WITH_STATEMENT = 0x8000; 2224 version (Python_2_5_Or_Later) { 2225 const int CO_FUTURE_ABSOLUTE_IMPORT = 0x4000; 2226 const int CO_FUTURE_WITH_STATEMENT = 0x8000; 2227 } else { 2228 const int CO_GENERATOR_ALLOWED = 0x1000; 2229 } 2188 2230 2189 2231 const int CO_MAXBLOCKS = 20; … … 2198 2240 } 2199 2241 2200 PyCodeObject *PyCode_New( 2201 int, int, int, int, PyObject *, PyObject *, PyObject *, PyObject *, 2202 PyObject *, PyObject *, PyObject *, PyObject *, int, PyObject *); 2203 int PyCode_Addr2Line(PyCodeObject *, int); 2204 2205 struct PyAddrPair { 2206 int ap_lower; 2207 int ap_upper; 2208 } 2209 2210 int PyCode_CheckLineNumber(PyCodeObject* co, int lasti, PyAddrPair *bounds); 2211 2212 // Python-header-file: Include/pyarena.h: 2213 struct PyArena; 2214 2215 PyArena* PyArena_New(); 2216 void PyArena_Free(PyArena*); 2217 2218 void* PyArena_Malloc(PyArena*, size_t); 2219 int PyArena_AddPyObject(PyArena*, PyObject*); 2242 version (Python_2_5_Or_Later) { 2243 struct PyAddrPair { 2244 int ap_lower; 2245 int ap_upper; 2246 } 2247 2248 int PyCode_CheckLineNumber(PyCodeObject* co, int lasti, PyAddrPair *bounds); 2249 2250 // Python-header-file: Include/pyarena.h: 2251 struct PyArena; 2252 2253 PyArena* PyArena_New(); 2254 void PyArena_Free(PyArena*); 2255 2256 void* PyArena_Malloc(PyArena*, size_t); 2257 int PyArena_AddPyObject(PyArena*, PyObject*); 2258 } 2220 2259 2221 2260 /////////////////////////////////////////////////////////////////////////////// … … 2227 2266 char *n_str; 2228 2267 int n_lineno; 2229 int n_col_offset; 2268 version (Python_2_5_Or_Later) { 2269 int n_col_offset; 2270 } 2230 2271 int n_nchildren; 2231 2272 node *n_child; 2232 2273 } 2233 node * PyNode_New(int type); 2234 int PyNode_AddChild(node *n, int type, 2235 char *str, int lineno, int col_offset); 2236 void PyNode_Free(node *n); 2237 void PyNode_ListTree(node *); 2274 version (Python_2_5_Or_Later) { 2275 node * PyNode_New(int type); 2276 int PyNode_AddChild(node *n, int type, 2277 char *str, int lineno, int col_offset); 2278 void PyNode_Free(node *n); 2279 void PyNode_ListTree(node *); 2280 } 2238 2281 2239 2282 // Python-header-file: Include/compile.h: 2240 2283 PyCodeObject *PyNode_Compile(node *, char *); 2284 PyCodeObject *PyCode_New( 2285 int, int, int, int, PyObject *, PyObject *, PyObject *, PyObject *, 2286 PyObject *, PyObject *, PyObject *, PyObject *, int, PyObject *); 2287 int PyCode_Addr2Line(PyCodeObject *, int); 2288 2241 2289 2242 2290 struct PyFutureFeatures { 2291 version (Python_2_5_Or_Later) {} else { 2292 int ff_found_docstring; 2293 int ff_last_lineno; 2294 } 2243 2295 int ff_features; 2244 int ff_lineno; 2245 } 2246 2247 // PyFutureFeatures *PyNode_Future(node *, char *); 2248 // PyCodeObject *PyNode_CompileFlags(node *, char *, PyCompilerFlags *); 2296 version (Python_2_5_Or_Later) { 2297 int ff_lineno; 2298 } 2299 } 2300 2301 version (Python_2_5_Or_Later) {} else { 2302 PyFutureFeatures *PyNode_Future(node *, char *); 2303 PyCodeObject *PyNode_CompileFlags(node *, char *, PyCompilerFlags *); 2304 } 2249 2305 2250 2306 const char[] FUTURE_NESTED_SCOPES = "nested_scopes"; 2251 2307 const char[] FUTURE_GENERATORS = "generators"; 2252 2308 const char[] FUTURE_DIVISION = "division"; 2253 const char[] FUTURE_ABSOLUTE_IMPORT = "absolute_import"; 2254 const char[] FUTURE_WITH_STATEMENT = "with_statement"; 2255 2256 struct _mod; /* Declare the existence of this type */ 2257 PyCodeObject * PyAST_Compile(_mod *, char *, PyCompilerFlags *, PyArena *); 2258 PyFutureFeatures * PyFuture_FromAST(_mod *, char *); 2259 2260 // Python-header-file: Include/ast.h 2261 _mod* PyAST_FromNode(node*, PyCompilerFlags*, char*, PyArena*); 2309 version (Python_2_5_Or_Later) { 2310 const char[] FUTURE_ABSOLUTE_IMPORT = "absolute_import"; 2311 const char[] FUTURE_WITH_STATEMENT = "with_statement"; 2312 2313 struct _mod; /* Declare the existence of this type */ 2314 PyCodeObject * PyAST_Compile(_mod *, char *, PyCompilerFlags *, PyArena *); 2315 PyFutureFeatures * PyFuture_FromAST(_mod *, char *); 2316 2317 // Python-header-file: Include/ast.h 2318 _mod* PyAST_FromNode(node*, PyCompilerFlags*, char*, PyArena*); 2319 } 2262 2320 2263 2321 /////////////////////////////////////////////////////////////////////////////// … … 2283 2341 void Py_EndInterpreter(PyThreadState *); 2284 2342 2343 // These are slightly different in 2.4, but the 2.5 form should still work. 2285 2344 int PyRun_AnyFileExFlags(FILE *, char *, int, PyCompilerFlags *); 2286 2345 … … 2317 2376 } 2318 2377 2319 _mod* PyParser_ASTFromString(char *, char *, 2378 version (Python_2_5_Or_Later) { 2379 _mod* PyParser_ASTFromString(char *, char *, 2320 2380 int, PyCompilerFlags *, PyArena *); 2321 _mod* PyParser_ASTFromFile(FILE *, char *, int,2381 _mod* PyParser_ASTFromFile(FILE *, char *, int, 2322 2382 char *, char *, PyCompilerFlags *, int *, PyArena *); 2383 } 2323 2384 2324 2385 node *PyParser_SimpleParseStringFlags(char *, int, int); … … 2380 2441 char *Py_GetCompiler(); 2381 2442 char *Py_GetBuildInfo(); 2382 char * _Py_svnversion(); 2383 char * Py_SubversionRevision(); 2384 char * Py_SubversionShortBranch(); 2443 version (Python_2_5_Or_Later) { 2444 char * _Py_svnversion(); 2445 char * Py_SubversionRevision(); 2446 char * Py_SubversionShortBranch(); 2447 } 2385 2448 2386 2449 ///////////////////////////////////////////////////////////////////////////// … … 2470 2533 PyObject *PyEval_GetCallStats(PyObject *); 2471 2534 PyObject *PyEval_EvalFrame(PyFrameObject *); 2472 PyObject *PyEval_EvalFrameEx(PyFrameObject *, int); 2473 2535 version (Python_2_5_Or_Later) { 2536 PyObject *PyEval_EvalFrameEx(PyFrameObject *, int); 2537 } 2474 2538 2475 2539 /////////////////////////////////////////////////////////////////////////////// … … 2529 2593 int f_lasti; 2530 2594 int f_lineno; 2595 version (Python_2_5_Or_Later) {} else { 2596 int f_restricted; 2597 } 2531 2598 int f_iblock; 2532 2599 PyTryBlock f_blockstack[CO_MAXBLOCKS]; 2600 version (Python_2_5_Or_Later) {} else { 2601 int f_nlocals; 2602 int f_ncells; 2603 int f_nfreevars; 2604 int f_stacksize; 2605 } 2533 2606 PyObject *_f_localsplus[1]; 2534 2607 PyObject** f_localsplus() { … … 2542 2615 return op.ob_type == PyFrame_Type_p; 2543 2616 } 2544 int PyFrame_IsRestricted(PyFrameObject* f) { 2545 return f.f_builtins != f.f_tstate.interp.builtins; 2617 version (Python_2_5_Or_Later) { 2618 int PyFrame_IsRestricted(PyFrameObject* f) { 2619 return f.f_builtins != f.f_tstate.interp.builtins; 2620 } 2546 2621 } 2547 2622 … … 2680 2755 PyObject *PyImport_AddModule(char *name); 2681 2756 PyObject *PyImport_ImportModule(char *name); 2682 PyObject *PyImport_ImportModuleLevel(char *name, 2683 PyObject *globals, PyObject *locals, PyObject *fromlist, int level); 2684 PyObject *PyImport_ImportModuleEx(char *n, PyObject *g, PyObject *l, PyObject *f) { 2685 return PyImport_ImportModuleLevel(n, g, l, f, -1); 2757 version (Python_2_5_Or_Later) { 2758 PyObject *PyImport_ImportModuleLevel(char *name, 2759 PyObject *globals, PyObject *locals, PyObject *fromlist, int level); 2760 PyObject *PyImport_ImportModuleEx(char *n, PyObject *g, PyObject *l, PyObject *f) { 2761 return PyImport_ImportModuleLevel(n, g, l, f, -1); 2762 } 2763 } else { 2764 PyObject *PyImport_ImportModuleEx(char *n, PyObject *g, PyObject *l, PyObject *f); 2686 2765 } 2687 2766 PyObject *PyImport_Import(PyObject *name); … … 2738 2817 PyObject *PyObject_Call(PyObject *callable_object, PyObject *args, PyObject *kw); 2739 2818 PyObject *PyObject_CallObject(PyObject *callable_object, PyObject *args); 2740 // PyObject *PyObject_CallFunction(PyObject *callable_object, char *format, ...); 2741 // PyObject *PyObject_CallMethod(PyObject *o, char *m, char *format, ...); 2742 PyObject *_PyObject_CallFunction_SizeT(PyObject *callable, char *format, ...); 2743 PyObject *_PyObject_CallMethod_SizeT(PyObject *o, char *name, char *format, ...); 2744 alias _PyObject_CallFunction_SizeT PyObject_CallFunction; 2745 alias _PyObject_CallMethod_SizeT PyObject_CallMethod; 2819 version (Python_2_5_Or_Later) { 2820 PyObject *_PyObject_CallFunction_SizeT(PyObject *callable, char *format, ...); 2821 PyObject *_PyObject_CallMethod_SizeT(PyObject *o, char *name, char *format, ...); 2822 alias _PyObject_CallFunction_SizeT PyObject_CallFunction; 2823 alias _PyObject_CallMethod_SizeT PyObject_CallMethod; 2824 } else { 2825 PyObject *PyObject_CallFunction(PyObject *callable_object, char *format, ...); 2826 PyObject *PyObject_CallMethod(PyObject *o, char *m, char *format, ...); 2827 } 2746 2828 PyObject *PyObject_CallFunctionObjArgs(PyObject *callable, ...); 2747 2829 PyObject *PyObject_CallMethodObjArgs(PyObject *o,PyObject *m, ...); … … 2757 2839 2758 2840 Py_ssize_t PyObject_Size(PyObject *o); 2759 //int PyObject_Length(PyObject *o); 2760 alias PyObject_Size PyObject_Length; 2841 version (Python_2_5_Or_Later) { 2842 alias PyObject_Size PyObject_Length; 2843 } else { 2844 int PyObject_Length(PyObject *o); 2845 } 2761 2846 2762 2847 PyObject *PyObject_GetItem(PyObject *o, PyObject *key); … … 2808 2893 PyObject *PyNumber_Or(PyObject *o1, PyObject *o2); 2809 2894 2810 int PyIndex_Check(PyObject* obj) { 2811 return obj.ob_type.tp_as_number !is null && 2812 PyType_HasFeature(obj.ob_type, Py_TPFLAGS_HAVE_INDEX) && 2813 obj.ob_type.tp_as_number.nb_index !is null; 2814 } 2815 PyObject *PyNumber_Index(PyObject *o); 2816 Py_ssize_t PyNumber_AsSsize_t(PyObject* o, PyObject* exc); 2895 version (Python_2_5_Or_Later) { 2896 int PyIndex_Check(PyObject* obj) { 2897 return obj.ob_type.tp_as_number !is null && 2898 PyType_HasFeature(obj.ob_type, Py_TPFLAGS_HAVE_INDEX) && 2899 obj.ob_type.tp_as_number.nb_index !is null; 2900 } 2901 PyObject *PyNumber_Index(PyObject *o); 2902 Py_ssize_t PyNumber_AsSsize_t(PyObject* o, PyObject* exc); 2903 } 2817 2904 PyObject *PyNumber_Int(PyObject *o); 2818 2905 PyObject *PyNumber_Long(PyObject *o); … … 2839 2926 int PySequence_Check(PyObject *o); 2840 2927 Py_ssize_t PySequence_Size(PyObject *o); 2841 //int PySequence_Length(PyObject *o); 2842 alias PySequence_Size PySequence_Length; 2928 version (Python_2_5_Or_Later) { 2929 alias PySequence_Size PySequence_Length; 2930 } else { 2931 int PySequence_Length(PyObject *o); 2932 } 2843 2933 2844 2934 PyObject *PySequence_Concat(PyObject *o1, PyObject *o2); … … 2882 2972 2883 2973 Py_ssize_t _PySequence_IterSearch(PyObject *seq, PyObject *obj, int operation); 2884 //int PySequence_In(PyObject *o, PyObject *value); 2885 alias PySequence_Contains PySequence_In; 2974 version (Python_2_5_Or_Later) { 2975 alias PySequence_Contains PySequence_In; 2976 } else { 2977 int PySequence_In(PyObject *o, PyObject *value); 2978 } 2886 2979 Py_ssize_t PySequence_Index(PyObject *o, PyObject *value); 2887 2980 … … 2894 2987 int PyMapping_Check(PyObject *o); 2895 2988 Py_ssize_t PyMapping_Size(PyObject *o); 2896 //int PyMapping_Length(PyObject *o); 2897 alias PyMapping_Size PyMapping_Length; 2989 version (Python_2_5_Or_Later) { 2990 alias PyMapping_Size PyMapping_Length; 2991 } else { 2992 int PyMapping_Length(PyObject *o); 2993 } 2898 2994 2899 2995 // D translations of C macros: … … 3281 3377 3282 3378 PyObject *PyGen_New(PyFrameObject *); 3283 int PyGen_NeedsFinalizing(PyGenObject *); 3379 version (Python_2_5_Or_Later) { 3380 int PyGen_NeedsFinalizing(PyGenObject *); 3381 } 3284 3382 3285 3383 … … 3289 3387 // Python-header-file: Include/marshal.h: 3290 3388 3291 const int Py_MARSHAL_VERSION = 2; 3389 version (Python_2_5_Or_Later) { 3390 const int Py_MARSHAL_VERSION = 2; 3391 } else { 3392 const int Py_MARSHAL_VERSION = 1; 3393 } 3292 3394 3293 3395 void PyMarshal_WriteLongToFile(C_long, FILE *, int); … … 3333 3435 void PyThread_release_lock(PyThread_type_lock); 3334 3436 3335 size_t PyThread_get_stacksize(); 3336 int PyThread_set_stacksize(size_t); 3437 version (Python_2_5_Or_Later) { 3438 size_t PyThread_get_stacksize(); 3439 int PyThread_set_stacksize(size_t); 3440 } 3337 3441 3338 3442 void PyThread_exit_prog(int); … … 3351 3455 // Python-header-file: Include/setobject.h: 3352 3456 3353 const int PySet_MINSIZE = 8; 3354 3355 struct setentry { 3356 C_long hash; 3357 PyObject *key; 3457 version (Python_2_5_Or_Later) { 3458 const int PySet_MINSIZE = 8; 3459 3460 struct setentry { 3461 C_long hash; 3462 PyObject *key; 3463 } 3358 3464 } 3359 3465 … … 3361 3467 mixin PyObject_HEAD; 3362 3468 3363 Py_ssize_t fill; 3364 Py_ssize_t used; 3365 3366 Py_ssize_t mask; 3367 3368 setentry *table; 3369 setentry *(*lookup)(PySetObject *so, PyObject *key, C_long hash); 3370 setentry smalltable[PySet_MINSIZE]; 3469 version (Python_2_5_Or_Later) { 3470 Py_ssize_t fill; 3471 Py_ssize_t used; 3472 3473 Py_ssize_t mask; 3474 3475 setentry *table; 3476 setentry *(*lookup)(PySetObject *so, PyObject *key, C_long hash); 3477 setentry smalltable[PySet_MINSIZE]; 3478 } else { 3479 PyObject* data; 3480 } 3371 3481 3372 3482 C_long hash; … … 3381 3491 return ob.ob_type == PyFrozenSet_Type_p; 3382 3492 } 3493 // Not technically part of the 2.4 API, included anyway. 3383 3494 int PyAnySet_CheckExact(PyObject* ob) { 3384 3495 return ob.ob_type == PySet_Type_p || ob.ob_type == PyFrozenSet_Type_p; … … 3393 3504 } 3394 3505 3395 PyObject *PySet_New(PyObject *); 3396 PyObject *PyFrozenSet_New(PyObject *); 3397 Py_ssize_t PySet_Size(PyObject *anyset); 3398 Py_ssize_t PySet_GET_SIZE(PyObject* so) { 3399 return (cast(PySetObject*)so).used; 3400 } 3401 int PySet_Clear(PyObject *set); 3402 int PySet_Contains(PyObject *anyset, PyObject *key); 3403 int PySet_Discard(PyObject *set, PyObject *key); 3404 int PySet_Add(PyObject *set, PyObject *key); 3405 int _PySet_Next(PyObject *set, Py_ssize_t *pos, PyObject **entry); 3406 PyObject *PySet_Pop(PyObject *set); 3407 int _PySet_Update(PyObject *set, PyObject *iterable); 3506 version (Python_2_5_Or_Later) { 3507 PyObject *PySet_New(PyObject *); 3508 PyObject *PyFrozenSet_New(PyObject *); 3509 Py_ssize_t PySet_Size(PyObject *anyset); 3510 Py_ssize_t PySet_GET_SIZE(PyObject* so) { 3511 return (cast(PySetObject*)so).used; 3512 } 3513 int PySet_Clear(PyObject *set); 3514 int PySet_Contains(PyObject *anyset, PyObject *key); 3515 int PySet_Discard(PyObject *set, PyObject *key); 3516 int PySet_Add(PyObject *set, PyObject *key); 3517 int _PySet_Next(PyObject *set, Py_ssize_t *pos, PyObject **entry); 3518 PyObject *PySet_Pop(PyObject *set); 3519 int _PySet_Update(PyObject *set, PyObject *iterable); 3520 } 3408 3521 3409 3522 /////////////////////////////////////////////////////////////////////////////// … … 3435 3548 const int T_STRING_INPLACE = 13; 3436 3549 const int T_OBJECT_EX = 16; 3437 const int T_LONGLONG = 17; 3438 const int T_ULONGLONG = 18; 3550 version (Python_2_5_Or_Later) { 3551 const int T_LONGLONG = 17; 3552 const int T_ULONGLONG = 18; 3553 } 3439 3554 3440 3555 const int READONLY = 1;
