├── examples ├── script_example2.py ├── example_module.py ├── script_example1.py └── examples.nim ├── python.nimble ├── README.md ├── LICENSE └── src └── python.nim /examples/script_example2.py: -------------------------------------------------------------------------------- 1 | 2 | import emb 3 | 4 | print("Number of arguments", emb.numargs()) -------------------------------------------------------------------------------- /examples/example_module.py: -------------------------------------------------------------------------------- 1 | 2 | def multiply(a,b): 3 | print("Will compute", a, "times", b) 4 | c = 0 5 | for i in range(0, a): 6 | c = c + b 7 | return c -------------------------------------------------------------------------------- /examples/script_example1.py: -------------------------------------------------------------------------------- 1 | 2 | # Python test script for use with a Python 3 interpreter embedded 3 | # in a Nim application. This is an example of very high level embedding. 4 | 5 | import time 6 | 7 | print('Today is ', time.ctime(time.time())) -------------------------------------------------------------------------------- /python.nimble: -------------------------------------------------------------------------------- 1 | # Package 2 | version = "1.2" 3 | author = "Andreas Rumpf, Matic Kukovec" 4 | description = "Wrapper to interface with Python 1/2 interpreter" 5 | license = "MIT" 6 | 7 | srcDir = "src" 8 | 9 | # Deps 10 | requires "nim >= 0.13.0" 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python 2 wrapper for Nim [![nimble](https://raw.githubusercontent.com/yglukhov/nimble-tag/master/nimble.png)](https://github.com/yglukhov/nimble-tag) 2 | 3 | ## Description: 4 | Nim wrapper for the Python 2 programming language. 5 | 6 | ## Notes: 7 | Compatible with Python 1.5 to 2.7 (Examples tested with Python 2.7). 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/examples.nim: -------------------------------------------------------------------------------- 1 | 2 | ## Various Python 2 examples 3 | 4 | import python 5 | import os, strutils 6 | 7 | 8 | ## Very high level python binding examples 9 | proc example1() = 10 | ## Run an interactive Python interpreter in a Nim console application 11 | let 12 | applicationName = os.getAppFilename() 13 | arguments = os.commandLineParams() 14 | var 15 | cArgumentList: seq[cstring] = newSeq[cstring](0) 16 | returnValue: int 17 | # Convert the arguments into C strings 18 | cArgumentList.add(cstring(applicationName)) 19 | for arg in arguments: 20 | cArgumentList.add(cstring(arg)) 21 | # Run the interpreter by passing it the application arguments 22 | returnValue = main(cArgumentList.len, addr(cArgumentList[0])) 23 | if returnValue == 1: 24 | echo("Exception occured!") 25 | elif returnValue == 2: 26 | echo("Invalid parameter list passed to the Python interpreter!") 27 | 28 | proc example2() = 29 | ## Executing a python script from a file 30 | var 31 | fileName: string = "script_example1.py" 32 | # Set program name in python (recommended) 33 | setProgramName("Example 2 ŽĆČŠĐ ŁĄŻĘĆŃŚŹ ЯБГДЖЙ ÄäÜüß") 34 | # Initialize the Python interpreter 35 | initialize() 36 | # Execute the script 37 | if runAnyFile(fileName) == -1: 38 | echo("Exception occured in Python script!") 39 | # Display program name 40 | echo getProgramName() 41 | # Close and delete the Python interpreter 42 | finalize() 43 | 44 | proc example3() = 45 | ## Executing a python script from a string 46 | # Setup the string variable with some python code 47 | var pythonString = "import time\nprint('Today is ', time.ctime(time.time()))" 48 | # Initialize the Python interpreter 49 | initialize() 50 | # Execute the string script 51 | if runSimpleString(pythonString) == -1: 52 | echo("Exception occured in Python script!") 53 | # Close and delete the Python interpreter 54 | finalize() 55 | 56 | proc example4() = 57 | ## Simple example of an Exception in a python script 58 | # Initialize the Python interpreter 59 | initialize() 60 | # Variable Initialization 61 | var 62 | pythonString: cstring = "import time\nd=\nprint('Today is ', time.ctime(time.time()))" 63 | globals: PyObjectPtr = moduleGetDict(importAddModule("__main__")) 64 | locals: PyObjectPtr = globals 65 | # Check globals, locals dictionaries and run the python string 66 | if globals == nil or locals == nil: 67 | echo("Error creating globals and locals dictionaries") 68 | elif runString(pythonString, fileInput, globals, locals) == nil: 69 | echo("Exception occured in Python script!") 70 | # Close and delete the Python interpreter 71 | finalize() 72 | 73 | ## Pure Embedding (C example translation) 74 | ## https://docs.python.org/2/extending/embedding.html#pure-embedding 75 | proc example5() = 76 | ## Import a python module from a file and execute a function from it. 77 | ## How to run the example: 78 | ## - compile this file 79 | ## - run in console: $ python_example example_module multiply 2 3 80 | ## - make sure that the example_module.py file is in the same directory as the executable 81 | # Application parameters 82 | let 83 | applicationName = os.getAppFilename() 84 | arguments = os.commandLineParams() 85 | argumentCount = os.paramCount() 86 | # Variables 87 | var 88 | pName, pModule, pFunc, pArgs, pValue: PyObjectPtr 89 | # Check command line arguments 90 | if len(arguments) < 2: 91 | quit "Usage: call pythonfile funcname [args]" 92 | # Initialize the Python interpreter 93 | initialize() 94 | # Get the app name into a python object 95 | pName = stringFromString(arguments[0]) # Error checking of pName left out 96 | #echo PyBytes_AsString(PyUnicode_AsASCIIString(pName)) 97 | pModule = importImport(pName) 98 | decref(pName) 99 | # Check if module was loaded 100 | if pModule != nil: 101 | pFunc = objectGetAttrString(pModule, arguments[1]) # pFunc is a new reference 102 | if pFunc != nil and callableCheck(pFunc) != 0: 103 | var countStart = argumentCount - 2 104 | pArgs = tupleNew(countStart) 105 | for i in 0..(countStart-1): 106 | pValue = longFromLong(parseInt(arguments[i + 2]).clong) 107 | if pValue == nil: 108 | decref(pArgs) 109 | decref(pModule) 110 | quit "Cannot convert argument number: $1" % $i 111 | # pValue reference stolen here: 112 | if tupleSetItem(pArgs, i, pValue) != 0: 113 | quit "Cannot insert tuple item: $1" % $i 114 | pValue = objectCallObject(pFunc, pArgs) 115 | decref(pArgs) 116 | if pValue != nil: 117 | echo "Result of call: $1" % $longAsLong(pValue) 118 | decref(pValue) 119 | else: 120 | decref(pFunc) 121 | decref(pModule) 122 | errPrint() 123 | quit "Call failed!" 124 | else: 125 | if errOccurred() != nil: 126 | errPrint() 127 | quit "Cannot find function '$1'\n" % arguments[1] 128 | else: 129 | errPrint(); 130 | quit "Failed to load '$1'" % arguments[0] 131 | # Close and delete the Python interpreter 132 | finalize() 133 | 134 | 135 | ## Run one of the examples 136 | example1() 137 | #example2() 138 | #example3() 139 | #example4() 140 | #example5() 141 | -------------------------------------------------------------------------------- /src/python.nim: -------------------------------------------------------------------------------- 1 | # 2 | # Light-weight binding for the Python interpreter 3 | # (c) 2010 Andreas Rumpf 4 | # Based on 'PythonEngine' module by Dr. Dietmar Budelsky 5 | # 6 | # 7 | #************************************************************************ 8 | # 9 | # Module: Unit 'PythonEngine' Copyright (c) 1997 10 | # 11 | # Version: 3.0 Dr. Dietmar Budelsky 12 | # Sub-Version: 0.25 dbudelsky@web.de 13 | # Germany 14 | # 15 | # Morgan Martinet 16 | # 4721 rue Brebeuf 17 | # H2J 3L2 MONTREAL (QC) 18 | # CANADA 19 | # e-mail: mmm@free.fr 20 | # 21 | # look our page at: http://www.multimania.com/marat 22 | #************************************************************************ 23 | # Functionality: Delphi Components that provide an interface to the 24 | # Python language (see python.txt for more infos on 25 | # Python itself). 26 | # 27 | #************************************************************************ 28 | # Contributors: 29 | # Grzegorz Makarewicz (mak@mikroplan.com.pl) 30 | # Andrew Robinson (andy@hps1.demon.co.uk) 31 | # Mark Watts(mark_watts@hotmail.com) 32 | # Olivier Deckmyn (olivier.deckmyn@mail.dotcom.fr) 33 | # Sigve Tjora (public@tjora.no) 34 | # Mark Derricutt (mark@talios.com) 35 | # Igor E. Poteryaev (jah@mail.ru) 36 | # Yuri Filimonov (fil65@mail.ru) 37 | # Stefan Hoffmeister (Stefan.Hoffmeister@Econos.de) 38 | #************************************************************************ 39 | # This source code is distributed with no WARRANTY, for no reason or use. 40 | # Everyone is allowed to use and change this code free for his own tasks 41 | # and projects, as long as this header and its copyright text is intact. 42 | # For changed versions of this code, which are public distributed the 43 | # following additional conditions have to be fullfilled: 44 | # 1) The header has to contain a comment on the change and the author of 45 | # it. 46 | # 2) A copy of the changed source has to be sent to the above E-Mail 47 | # address or my then valid address, if this is possible to the 48 | # author. 49 | # The second condition has the target to maintain an up to date central 50 | # version of the component. If this condition is not acceptable for 51 | # confidential or legal reasons, everyone is free to derive a component 52 | # or to generate a diff file to my or other original sources. 53 | # Dr. Dietmar Budelsky, 1997-11-17 54 | #************************************************************************ 55 | 56 | {.deadCodeElim: on.} 57 | 58 | import 59 | dynlib, 60 | strutils 61 | 62 | 63 | when defined(windows): 64 | const dllname = "python(27|26|25|24|23|22|21|20|16|15).dll" 65 | elif defined(macosx): 66 | const dllname = "libpython(2.7|2.6|2.5|2.4|2.3|2.2|2.1|2.0|1.6|1.5).dylib" 67 | else: 68 | const dllver = ".1" 69 | const dllname = "libpython(2.7|2.6|2.5|2.4|2.3|2.2|2.1|2.0|1.6|1.5).so" & 70 | dllver 71 | 72 | 73 | const 74 | tMethodBufferIncrease* = 10 75 | tMemberBufferIncrease* = 10 76 | tGetsetBufferIncrease* = 10 77 | # Flag passed to newmethodobject 78 | methOldargs* = 0x0000 79 | methVarargs* = 0x0001 80 | methKeywords* = 0x0002 81 | methNoargs* = 0x0004 82 | methO* = 0x0008 83 | methClass* = 0x0010 84 | methStatic* = 0x0020 85 | methCoexist* = 0x0040 86 | # Masks for the co_flags field of PyCodeObject 87 | coOptimized* = 0x0001 88 | coNewlocals* = 0x0002 89 | coVarargs* = 0x0004 90 | coVarkeywords* = 0x0008 91 | coNested* = 0x0010 92 | coGenerator* = 0x0020 93 | coFutureDivision* = 0x2000 94 | coFutureAbsoluteImport* = 0x4000 95 | coFutureWithStatement* = 0x8000 96 | coFuturePrintFunction* = 0x10000 97 | coFutureUnicodeLiterals* = 0x20000 98 | {.deprecated: [PYT_METHOD_BUFFER_INCREASE: tMethodBufferIncrease].} 99 | {.deprecated: [PYT_MEMBER_BUFFER_INCREASE: tMemberBufferIncrease].} 100 | {.deprecated: [PYT_GETSET_BUFFER_INCREASE: tGetsetBufferIncrease].} 101 | {.deprecated: [METH_OLDARGS: methOldargs].} 102 | {.deprecated: [METH_VARARGS: methVarargs].} 103 | {.deprecated: [METH_KEYWORDS: methKeywords].} 104 | {.deprecated: [METH_NOARGS: methNoargs].} 105 | {.deprecated: [METH_O: methO].} 106 | {.deprecated: [METH_CLASS: methClass].} 107 | {.deprecated: [METH_STATIC: methStatic].} 108 | {.deprecated: [METH_COEXIST: methCoexist].} 109 | {.deprecated: [CO_OPTIMIZED: coOptimized].} 110 | {.deprecated: [CO_NEWLOCALS: coNewlocals].} 111 | {.deprecated: [CO_VARARGS: coVarargs].} 112 | {.deprecated: [CO_VARKEYWORDS: coVarkeywords].} 113 | {.deprecated: [CO_NESTED: coNested].} 114 | {.deprecated: [CO_GENERATOR: coGenerator].} 115 | {.deprecated: [CO_FUTURE_DIVISION: coFutureDivision].} 116 | {.deprecated: [CO_FUTURE_ABSOLUTE_IMPORT: coFutureAbsoluteImport].} 117 | {.deprecated: [CO_FUTURE_WITH_STATEMENT: coFutureWithStatement].} 118 | {.deprecated: [CO_FUTURE_PRINT_FUNCTION: coFuturePrintFunction].} 119 | {.deprecated: [CO_FUTURE_UNICODE_LITERALS: coFutureUnicodeLiterals].} 120 | 121 | type 122 | # Rich comparison opcodes introduced in version 2.1 123 | RichComparisonOpcode* = enum 124 | rcoLT, rcoLE, rcoEQ, rcoNE, rcoGT, rcoGE 125 | 126 | const 127 | # PySequenceMethods contains sq_contains 128 | tpflagsHaveGetCharBuffer* = (1 shl 0) 129 | # Objects which participate in garbage collection (see objimp.h) 130 | tpflagsHaveSequenceIn* = (1 shl 1) 131 | # PySequenceMethods and PyNumberMethods contain in-place operators 132 | tpflagsGc* = (1 shl 2) 133 | # PyNumberMethods do their own Coercion 134 | tpflagsHaveInplaceops* = (1 shl 3) 135 | tpflagsCheckTypes* = (1 shl 4) 136 | # Objects which are weakly referencable if their tp_weaklistoffset is > 0 137 | # XXX Should this have the same value as Py_TPFLAGS_HAVE_RICHCOMPARE? 138 | # These both indicate a feature that appeared in the same alpha release. 139 | tpflagsHaveRichCompare* = (1 shl 5) 140 | # tp_iter is defined 141 | tpflagsHaveWeakRefs* = (1 shl 6) 142 | # New members introduced by Python 2.2 exist 143 | tpflagsHaveIter* = (1 shl 7) 144 | # Set if the type object is dynamically allocated 145 | tpflagsHaveClass* = (1 shl 8) 146 | # Set if the type allows subclassing 147 | tpflagsHeapType* = (1 shl 9) 148 | # Set if the type is 'ready' -- fully initialized 149 | tpflagsBaseType* = (1 shl 10) 150 | # Set while the type is being 'readied', to prevent recursive ready calls 151 | tpflagsReady* = (1 shl 12) 152 | # Objects support garbage collection (see objimp.h) 153 | tpflagsReadying* = (1 shl 13) 154 | tpflagsHaveGc* = (1 shl 14) 155 | tpflagsDefault* = tpflagsHaveGetCharBuffer or 156 | tpflagsHaveSequenceIn or 157 | tpflagsHaveInplaceops or 158 | tpflagsHaveRichCompare or 159 | tpflagsHaveWeakRefs or 160 | tpflagsHaveIter or 161 | tpflagsHaveClass 162 | {.deprecated: [Py_TPFLAGS_HAVE_GETCHARBUFFER: tpflagsHaveGetCharBuffer].} 163 | {.deprecated: [Py_TPFLAGS_HAVE_SEQUENCE_IN: tpflagsHaveSequenceIn].} 164 | {.deprecated: [Py_TPFLAGS_GC: tpflagsGc].} 165 | {.deprecated: [Py_TPFLAGS_HAVE_INPLACEOPS: tpflagsHaveInplaceops].} 166 | {.deprecated: [Py_TPFLAGS_CHECKTYPES: tpflagsCheckTypes].} 167 | {.deprecated: [Py_TPFLAGS_HAVE_RICHCOMPARE: tpflagsHaveRichCompare].} 168 | {.deprecated: [Py_TPFLAGS_HAVE_WEAKREFS: tpflagsHaveWeakRefs].} 169 | {.deprecated: [Py_TPFLAGS_HAVE_ITER: tpflagsHaveIter].} 170 | {.deprecated: [Py_TPFLAGS_HAVE_CLASS: tpflagsHaveClass].} 171 | {.deprecated: [Py_TPFLAGS_HEAPTYPE: tpflagsHeapType].} 172 | {.deprecated: [Py_TPFLAGS_BASETYPE: tpflagsBaseType].} 173 | {.deprecated: [Py_TPFLAGS_READY: tpflagsReady].} 174 | {.deprecated: [Py_TPFLAGS_READYING: tpflagsReadying].} 175 | {.deprecated: [Py_TPFLAGS_HAVE_GC: tpflagsHaveGc].} 176 | {.deprecated: [Py_TPFLAGS_DEFAULT: tpflagsDefault].} 177 | 178 | type 179 | PFlag* = enum 180 | tpfHaveGetCharBuffer, tpfHaveSequenceIn, tpfGC, tpfHaveInplaceOps, 181 | tpfCheckTypes, tpfHaveRichCompare, tpfHaveWeakRefs, tpfHaveIter, 182 | tpfHaveClass, tpfHeapType, tpfBaseType, tpfReady, tpfReadying, tpfHaveGC 183 | PFlags* = set[PFlag] 184 | 185 | const 186 | tpflagsDefaultSet* = {tpfHaveGetCharBuffer, tpfHaveSequenceIn, 187 | tpfHaveInplaceOps, tpfHaveRichCompare, tpfHaveWeakRefs, tpfHaveIter, 188 | tpfHaveClass} 189 | {.deprecated: [TPFLAGS_DEFAULT: tpflagsDefault].} 190 | 191 | const # Python opcodes 192 | singleInput* = 256 193 | fileInput* = 257 194 | evalInput* = 258 195 | funcdef* = 259 196 | parameters* = 260 197 | varargslist* = 261 198 | fpdef* = 262 199 | fplist* = 263 200 | statement* = 264 201 | simpleStmt* = 265 202 | smallStmt* = 266 203 | exprStmt* = 267 204 | augassign* = 268 205 | printStmt* = 269 206 | delStmt* = 270 207 | passStmt* = 271 208 | flowStmt* = 272 209 | breakStmt* = 273 210 | continueStmt* = 274 211 | returnStmt* = 275 212 | raiseStmt* = 276 213 | importStmt* = 277 214 | importAsName* = 278 215 | dottedAsName* = 279 216 | dottedName* = 280 217 | globalStmt* = 281 218 | execStmt* = 282 219 | assertStmt* = 283 220 | compoundStmt* = 284 221 | ifStmt* = 285 222 | whileStmt* = 286 223 | forStmt* = 287 224 | tryStmt* = 288 225 | exceptClause* = 289 226 | suite* = 290 227 | test* = 291 228 | andTest* = 291 229 | notTest* = 293 230 | comparison* = 294 231 | compOp* = 295 232 | expression* = 296 233 | xorExpr* = 297 234 | andExpr* = 298 235 | shiftExpr* = 299 236 | arithExpr* = 300 237 | term* = 301 238 | factor* = 302 239 | power* = 303 240 | atom* = 304 241 | listmaker* = 305 242 | lambdef* = 306 243 | trailer* = 307 244 | subscriptlist* = 308 245 | subscript* = 309 246 | sliceop* = 310 247 | exprlist* = 311 248 | testlist* = 312 249 | dictmaker* = 313 250 | classdef* = 314 251 | arglist* = 315 252 | argument* = 316 253 | listIter* = 317 254 | listFor* = 318 255 | listIf* = 319 256 | 257 | const 258 | tShort* = 0 259 | tInt* = 1 260 | tLong* = 2 261 | tFloat* = 3 262 | tDouble* = 4 263 | tString* = 5 264 | tObject* = 6 265 | tChar* = 7 # 1-character string 266 | tByte* = 8 # 8-bit signed int 267 | tUbyte* = 9 268 | tUshort* = 10 269 | tUint* = 11 270 | tUlong* = 12 271 | tStringInplace* = 13 272 | tObjectEx* = 16 273 | readonly* = 1 274 | ro* = readonly # Shorthand 275 | readRestricted* = 2 276 | writeRestricted* = 4 277 | restricted* = (readRestricted or writeRestricted) 278 | {.deprecated: [T_SHORT: tShort].} 279 | {.deprecated: [T_INT: tInt].} 280 | {.deprecated: [T_LONG: tLong].} 281 | {.deprecated: [T_FLOAT: tFloat].} 282 | {.deprecated: [T_DOUBLE: tDouble].} 283 | {.deprecated: [T_STRING: tString].} 284 | {.deprecated: [T_OBJECT: tObject].} 285 | {.deprecated: [T_CHAR: tChar].} 286 | {.deprecated: [T_BYTE: tByte].} 287 | {.deprecated: [T_UBYTE: tUbyte].} 288 | {.deprecated: [T_USHORT: tUshort].} 289 | {.deprecated: [T_UINT: tUint].} 290 | {.deprecated: [T_ULONG: tUlong].} 291 | {.deprecated: [T_STRING_INPLACE: tStringInplace].} 292 | {.deprecated: [T_OBJECT_EX: tObjectEx].} 293 | {.deprecated: [READ_RESTRICTED: readRestricted].} 294 | {.deprecated: [WRITE_RESTRICTED: writeRestricted].} 295 | 296 | type 297 | PyMemberType* = enum 298 | mtShort, mtInt, mtLong, mtFloat, mtDouble, mtString, mtObject, mtChar, 299 | mtByte, mtUByte, mtUShort, mtUInt, mtULong, mtStringInplace, mtObjectEx 300 | 301 | PyMemberFlag* = enum 302 | mfDefault, mfReadOnly, mfReadRestricted, mfWriteRestricted, mfRestricted 303 | 304 | IntPtr* = ptr int 305 | 306 | type 307 | CstringPtr* = ptr cstring 308 | FrozenPtrPtr* = ptr Frozen 309 | FrozenPtr* = ptr Frozen 310 | PyObjectPtr* = ptr PyObject 311 | PyObjectPtrPtr* = ptr PyObjectPtr 312 | PyObjectPtrPtrPtr* = ptr PyObjectPtrPtr 313 | PyIntObjectPtr* = ptr PyIntObject 314 | PyTypeObjectPtr* = ptr PyTypeObject 315 | PySliceObjectPtr* = ptr PySliceObject 316 | PyCFunction* = proc (self, args: PyObjectPtr): PyObjectPtr{.cdecl.} 317 | UnaryFunc* = proc (ob1: PyObjectPtr): PyObjectPtr{.cdecl.} 318 | BinaryFunc* = proc (ob1, ob2: PyObjectPtr): PyObjectPtr{.cdecl.} 319 | TernaryFunc* = proc (ob1, ob2, ob3: PyObjectPtr): PyObjectPtr{.cdecl.} 320 | Inquiry* = proc (ob1: PyObjectPtr): int{.cdecl.} 321 | Coercion* = proc (ob1, ob2: PyObjectPtrPtr): int{.cdecl.} 322 | IntArgFunc* = proc (ob1: PyObjectPtr, i: int): PyObjectPtr{.cdecl.} 323 | IntIntArgFunc* = proc (ob1: PyObjectPtr, i1, i2: int): PyObjectPtr{.cdecl.} 324 | IntObjArgProc* = proc (ob1: PyObjectPtr, i: int, 325 | ob2: PyObjectPtr): int{.cdecl.} 326 | IntIntObjArgProc* = proc (ob1: PyObjectPtr, i1, i2: int, 327 | ob2: PyObjectPtr): int{.cdecl.} 328 | ObjObjargProc* = proc (ob1, ob2, ob3: PyObjectPtr): int{.cdecl.} 329 | PyDestructor* = proc (ob: PyObjectPtr){.cdecl.} 330 | PrintFunc* = proc (ob: PyObjectPtr, f: File, i: int): int{.cdecl.} 331 | GetAttrFunc* = proc (ob1: PyObjectPtr, name: cstring): PyObjectPtr{.cdecl.} 332 | SetAttrFunc* = proc (ob1: PyObjectPtr, name: cstring, 333 | ob2: PyObjectPtr): int{.cdecl.} 334 | CmpFunc* = proc (ob1, ob2: PyObjectPtr): int{.cdecl.} 335 | ReprFunc* = proc (ob: PyObjectPtr): PyObjectPtr{.cdecl.} 336 | HashFunc* = proc (ob: PyObjectPtr): int32{.cdecl.} 337 | GetAttroFunc* = proc (ob1, ob2: PyObjectPtr): PyObjectPtr{.cdecl.} 338 | SetAttroFunc* = proc (ob1, ob2, ob3: PyObjectPtr): int{.cdecl.} 339 | GetReadBufferProc* = proc (ob1: PyObjectPtr, i: int, p: pointer): int{.cdecl.} 340 | GetWriteBufferProc* = proc (ob1: PyObjectPtr, i: int, 341 | p: pointer): int{.cdecl.} 342 | GetSegCountProc* = proc (ob1: PyObjectPtr, i: int): int{.cdecl.} 343 | GetCharBufferProc* = proc (ob1: PyObjectPtr, 344 | i: int, pstr: cstring): int{.cdecl.} 345 | ObjObjProc* = proc (ob1, ob2: PyObjectPtr): int{.cdecl.} 346 | VisitProc* = proc (ob1: PyObjectPtr, p: pointer): int{.cdecl.} 347 | TraverseProc* = proc (ob1: PyObjectPtr, prc: VisitProc, 348 | p: pointer): int{.cdecl.} 349 | RichCmpFunc* = proc (ob1, ob2: PyObjectPtr, i: int): PyObjectPtr{.cdecl.} 350 | GetIterFunc* = proc (ob1: PyObjectPtr): PyObjectPtr{.cdecl.} 351 | IterNextFunc* = proc (ob1: PyObjectPtr): PyObjectPtr{.cdecl.} 352 | DescrGetFunc* = proc (ob1, ob2, ob3: PyObjectPtr): PyObjectPtr{.cdecl.} 353 | DescrSetFunc* = proc (ob1, ob2, ob3: PyObjectPtr): int{.cdecl.} 354 | InitProc* = proc (self, args, kwds: PyObjectPtr): int{.cdecl.} 355 | NewFunc* = proc (subtype: PyTypeObjectPtr, 356 | args, kwds: PyObjectPtr): PyObjectPtr{.cdecl.} 357 | AllocFunc* = proc (self: PyTypeObjectPtr, nitems: int): PyObjectPtr{.cdecl.} 358 | PyNumberMethods*{.final.} = object 359 | nbAdd*: BinaryFunc 360 | nbSubstract*: BinaryFunc 361 | nbMultiply*: BinaryFunc 362 | nbDivide*: BinaryFunc 363 | nbRemainder*: BinaryFunc 364 | nbDivmod*: BinaryFunc 365 | nbPower*: TernaryFunc 366 | nbNegative*: UnaryFunc 367 | nbPositive*: UnaryFunc 368 | nbAbsolute*: UnaryFunc 369 | nbNonzero*: Inquiry 370 | nbInvert*: UnaryFunc 371 | nbLshift*: BinaryFunc 372 | nbRshift*: BinaryFunc 373 | nbAnd*: BinaryFunc 374 | nbXor*: BinaryFunc 375 | nbOr*: BinaryFunc 376 | nbCoerce*: Coercion 377 | nbInt*: UnaryFunc 378 | nbLong*: UnaryFunc 379 | nbFloat*: UnaryFunc 380 | nbOct*: UnaryFunc 381 | nbHex*: UnaryFunc 382 | # jah 29-sep-2000: updated for python 2.0 added from .h 383 | nbInplaceAdd*: BinaryFunc 384 | nbInplaceSubtract*: BinaryFunc 385 | nbInplaceMultiply*: BinaryFunc 386 | nbInplaceDivide*: BinaryFunc 387 | nbInplaceRemainder*: BinaryFunc 388 | nbInplacePower*: TernaryFunc 389 | nbInplaceLshift*: BinaryFunc 390 | nbInplaceRshift*: BinaryFunc 391 | nbInplaceAnd*: BinaryFunc 392 | nbInplaceXor*: BinaryFunc 393 | nbInplaceOr*: BinaryFunc 394 | # Added in release 2.2 395 | # The following require the tpflagsHaveClass flag 396 | nbFloorDivide*: BinaryFunc 397 | nbTrueDivide*: BinaryFunc 398 | nbInplaceFloorDivide*: BinaryFunc 399 | nbInplaceTrueDivide*: BinaryFunc 400 | 401 | PyNumberMethodsPtr* = ptr PyNumberMethods 402 | PySequenceMethods*{.final.} = object 403 | sqLength*: Inquiry 404 | sqConcat*: BinaryFunc 405 | sqRepeat*: IntArgFunc 406 | sqItem*: IntArgFunc 407 | sqSlice*: IntIntArgFunc 408 | sqAssItem*: IntObjArgProc 409 | sqAssSlice*: IntIntObjArgProc 410 | sqContains*: ObjObjProc 411 | sqInplaceConcat*: BinaryFunc 412 | sqInplaceRepeat*: IntArgFunc 413 | 414 | PySequenceMethodsPtr* = ptr PySequenceMethods 415 | PyMappingMethods*{.final.} = object 416 | mpLength*: Inquiry 417 | mpSubscript*: BinaryFunc 418 | mpAssSubscript*: ObjObjargProc 419 | 420 | PyMappingMethodsPtr* = ptr PyMappingMethods 421 | PyBufferProcs*{.final.} = object 422 | bfGetreadbuffer*: GetReadBufferProc 423 | bfGetwritebuffer*: GetWriteBufferProc 424 | bfGetsegcount*: GetSegCountProc 425 | bfGetcharbuffer*: GetCharBufferProc 426 | 427 | PyBufferProcsPtr* = ptr PyBufferProcs 428 | PyComplex*{.final.} = object 429 | float*: float64 430 | imag*: float64 431 | 432 | PyObject*{.pure, inheritable.} = object 433 | obRefcnt*: int 434 | obType*: PyTypeObjectPtr 435 | 436 | PyIntObject* = object of RootObj 437 | obIval*: int32 438 | 439 | BytePtr* = ptr int8 440 | Frozen*{.final.} = object 441 | name*: cstring 442 | code*: BytePtr 443 | size*: int 444 | 445 | PySliceObject* = object of PyObject 446 | start*, stop*, step*: PyObjectPtr 447 | 448 | PyMethodDefPtr* = ptr PyMethodDef 449 | PyMethodDef*{.final.} = object # structmember.h 450 | mlName*: cstring 451 | mlMeth*: PyCFunction 452 | mlFlags*: int 453 | mlDoc*: cstring 454 | 455 | PyMemberDefPtr* = ptr PyMemberDef 456 | PyMemberDef*{.final.} = object # descrobject.h Descriptors 457 | name*: cstring 458 | theType*: int 459 | offset*: int 460 | flags*: int 461 | doc*: cstring 462 | 463 | Getter* = proc (obj: PyObjectPtr, context: pointer): PyObjectPtr{.cdecl.} 464 | Setter* = proc (obj, value: PyObjectPtr, context: pointer): int{.cdecl.} 465 | PyGetSetDefPtr* = ptr PyGetSetDef 466 | PyGetSetDef*{.final.} = object 467 | name*: cstring 468 | get*: Getter 469 | Setter*: Setter 470 | doc*: cstring 471 | closure*: pointer 472 | 473 | wrapperfunc* = proc (self, args: PyObjectPtr, 474 | wrapped: pointer): PyObjectPtr{.cdecl.} 475 | wrapperbasePtr* = ptr wrapperbase 476 | 477 | # Various kinds of descriptor objects 478 | # #define PyDescr_COMMON \ 479 | # PyObject_HEAD \ 480 | # PyTypeObject *d_type; \ 481 | # PyObject *d_name 482 | wrapperbase*{.final.} = object 483 | name*: cstring 484 | wrapper*: wrapperfunc 485 | doc*: cstring 486 | 487 | PyDescrObjectPtr* = ptr PyDescrObject 488 | PyDescrObject* = object of PyObject 489 | dType*: PyTypeObjectPtr 490 | dName*: PyObjectPtr 491 | 492 | PyMethodDescrObjectPtr* = ptr PyMethodDescrObject 493 | PyMethodDescrObject* = object of PyDescrObject 494 | dMethod*: PyMethodDefPtr 495 | 496 | PyMemberDescrObjectPtr* = ptr PyMemberDescrObject 497 | PyMemberDescrObject* = object of PyDescrObject 498 | dMember*: PyMemberDefPtr 499 | 500 | PyGetSetDescrObjectPtr* = ptr PyGetSetDescrObject 501 | PyGetSetDescrObject* = object of PyDescrObject 502 | dGetset*: PyGetSetDefPtr 503 | 504 | PyWrapperDescrObjectPtr* = ptr PyWrapperDescrObject 505 | PyWrapperDescrObject* = object of PyDescrObject # object.h 506 | dBase*: wrapperbasePtr 507 | dWrapped*: pointer # This can be any function pointer 508 | 509 | PyTypeObject* = object of PyObject 510 | obSize*: int # Number of items in variable part 511 | tpName*: cstring # For printing 512 | tpBasicsize*, tpItemsize*: int # For allocation 513 | # Methods to implement standard operations 514 | tpDealloc*: PyDestructor 515 | tpPrint*: PrintFunc 516 | tpGetattr*: GetAttrFunc 517 | tpSetattr*: SetAttrFunc 518 | tpCompare*: CmpFunc 519 | tpRepr*: ReprFunc 520 | # Method suites for standard classes 521 | tpAsNumber*: PyNumberMethodsPtr 522 | tpAsSequence*: PySequenceMethodsPtr 523 | # More standard operations (here for binary compatibility) 524 | tpAsMapping*: PyMappingMethodsPtr 525 | tpHash*: HashFunc 526 | tpCall*: TernaryFunc 527 | tpStr*: ReprFunc 528 | tpGetattro*: GetAttroFunc 529 | tpSetattro*: SetAttroFunc 530 | # Functions to access object as input/output buffer 531 | tpAsBuffer*: PyBufferProcsPtr 532 | # Flags to define presence of optional/expanded features 533 | tpFlags*: int32 534 | # Documentation string 535 | tpDoc*: cstring 536 | # call function for all accessible objects 537 | tpTraverse*: TraverseProc 538 | # delete references to contained objects 539 | tpClear*: Inquiry 540 | # rich comparisons 541 | tpRichcompare*: RichCmpFunc 542 | # weak reference enabler 543 | tpWeaklistoffset*: int32 544 | # Iterators 545 | tpIter*: GetIterFunc 546 | tpIternext*: IterNextFunc 547 | # Attribute descriptor and subclassing stuff 548 | tpMethods*: PyMethodDefPtr 549 | tpMembers*: PyMemberDefPtr 550 | tpGetset*: PyGetSetDefPtr 551 | tpBase*: PyTypeObjectPtr 552 | tpDict*: PyObjectPtr 553 | tpDescrGet*: DescrGetFunc 554 | tpDescrSet*: DescrSetFunc 555 | tpDictoffset*: int32 556 | tpInit*: InitProc 557 | tpAlloc*: AllocFunc 558 | tpNew*: NewFunc 559 | tpFree*: PyDestructor # Low-level free-memory routine 560 | tpIsGc*: Inquiry # For PyObject_IS_GC 561 | tpBases*: PyObjectPtr 562 | tpMro*: PyObjectPtr # method resolution order 563 | tpCache*: PyObjectPtr 564 | tpSubclasses*: PyObjectPtr 565 | tpWeaklist*: PyObjectPtr 566 | #More spares 567 | tpXxx7*: pointer 568 | tpXxx8*: pointer 569 | 570 | PyMethodChainPtr* = ptr PyMethodChain 571 | PyMethodChain*{.final.} = object 572 | methods*: PyMethodDefPtr 573 | link*: PyMethodChainPtr 574 | 575 | PyClassObjectPtr* = ptr PyClassObject 576 | PyClassObject* = object of PyObject 577 | clBases*: PyObjectPtr # A tuple of class objects 578 | clDict*: PyObjectPtr # A dictionary 579 | clName*: PyObjectPtr # A string 580 | # The following three are functions or NULL 581 | clGetattr*: PyObjectPtr 582 | clSetattr*: PyObjectPtr 583 | clDelattr*: PyObjectPtr 584 | 585 | PyInstanceObjectPtr* = ptr PyInstanceObject 586 | PyInstanceObject* = object of PyObject 587 | inClass*: PyClassObjectPtr # The class object 588 | inDict*: PyObjectPtr # A dictionary 589 | 590 | PyMethodObjectPtr* = ptr PyMethodObject 591 | PyMethodObject* = object of PyObject # Bytecode object, compile.h 592 | imFunc*: PyObjectPtr # The function implementing the method 593 | imSelf*: PyObjectPtr # The instance it is bound to, or NULL 594 | imClass*: PyObjectPtr # The class that defined the method 595 | 596 | PyCodeObjectPtr* = ptr PyCodeObject 597 | PyCodeObject* = object of PyObject # from pystate.h 598 | coArgcount*: int # #arguments, except *args 599 | coNlocals*: int # #local variables 600 | coStacksize*: int # #entries needed for evaluation stack 601 | coFlags*: int # CO_..., see below 602 | coCode*: PyObjectPtr # instruction opcodes (it hides a PyStringObject) 603 | coConsts*: PyObjectPtr # list (constants used) 604 | coNames*: PyObjectPtr # list of strings (names used) 605 | coVarnames*: PyObjectPtr # tuple of strings (local variable names) 606 | coFreevars*: PyObjectPtr # tuple of strings (free variable names) 607 | coCellvars*: PyObjectPtr # tuple of strings (cell variable names) 608 | # The rest doesn't count for hash/cmp 609 | coFilename*: PyObjectPtr # string (where it was loaded from) 610 | coName*: PyObjectPtr # string (name, for reference) 611 | coFirstlineno*: int # first source line number 612 | coLnotab*: PyObjectPtr # string (encoding addr<->lineno mapping) 613 | 614 | PyInterpreterStatePtr* = ptr PyInterpreterState 615 | PyThreadStatePtr* = ptr PyThreadState 616 | PyFrameObjectPtr* = ptr PyFrameObject # Interpreter environments 617 | PyInterpreterState*{.final.} = object # Thread specific information 618 | next*: PyInterpreterStatePtr 619 | tstate_head*: PyThreadStatePtr 620 | modules*: PyObjectPtr 621 | sysdict*: PyObjectPtr 622 | builtins*: PyObjectPtr 623 | checkinterval*: int 624 | 625 | PyThreadState*{.final.} = object # from frameobject.h 626 | next*: PyThreadStatePtr 627 | interp*: PyInterpreterStatePtr 628 | frame*: PyFrameObjectPtr 629 | recursionDepth*: int 630 | ticker*: int 631 | tracing*: int 632 | sysProfilefunc*: PyObjectPtr 633 | sysTracefunc*: PyObjectPtr 634 | curexcType*: PyObjectPtr 635 | curexcValue*: PyObjectPtr 636 | curexcTraceback*: PyObjectPtr 637 | excType*: PyObjectPtr 638 | excValue*: PyObjectPtr 639 | excTraceback*: PyObjectPtr 640 | dict*: PyObjectPtr 641 | 642 | PyTryBlockPtr* = ptr PyTryBlock 643 | PyTryBlock*{.final.} = object 644 | bType*: int # what kind of block this is 645 | bHandler*: int # where to jump to find handler 646 | bLevel*: int # value stack level to pop to 647 | 648 | coMaxblocks* = range[0..19] 649 | PyFrameObject* = object of PyObject # start of the VAR_HEAD of an object 650 | # From traceback.c 651 | obSize*: int # Number of items in variable part 652 | # End of the Head of an object 653 | fBack*: PyFrameObjectPtr # previous frame, or NULL 654 | fCode*: PyCodeObjectPtr # code segment 655 | fBuiltins*: PyObjectPtr # builtin symbol table (PyDictObject) 656 | fGlobals*: PyObjectPtr # global symbol table (PyDictObject) 657 | fLocals*: PyObjectPtr # local symbol table (PyDictObject) 658 | fValuestack*: PyObjectPtrPtr # points after the last local 659 | # Next free slot in fValuestack. 660 | # Frame creation sets to fValuestack. 661 | # Frame evaluation usually NULLs it, 662 | # but a frame that yields sets it 663 | # to the current stack top. 664 | fStacktop*: PyObjectPtrPtr 665 | fTrace*: PyObjectPtr # Trace function 666 | fExcType*, fExcValue*, fExcTraceback*: PyObjectPtr 667 | fTstate*: PyThreadStatePtr 668 | fLasti*: int # Last instruction if called 669 | fLineno*: int # Current line number 670 | fRestricted*: int # Flag set if restricted operations 671 | # in this scope 672 | fIblock*: int # index in f_blockstack 673 | fBlockstack*: array[coMaxblocks, PyTryBlock] # for try and loop blocks 674 | fNlocals*: int # number of locals 675 | fNcells*: int 676 | fNfreevars*: int 677 | fStacksize*: int # size of value stack 678 | fLocalsplus*: array[0..0, PyObjectPtr] # locals+stack, dynamically sized 679 | 680 | PyTraceBackObjectPtr* = ptr PyTraceBackObject 681 | PyTraceBackObject* = object of PyObject # Parse tree node interface 682 | tbNext*: PyTraceBackObjectPtr 683 | tbFrame*: PyFrameObjectPtr 684 | tbLasti*: int 685 | tbLineno*: int 686 | 687 | NodePtr* = ptr Node 688 | Node*{.final.} = object # From weakrefobject.h 689 | nType*: int16 690 | nStr*: cstring 691 | nLineno*: int16 692 | nNchildren*: int16 693 | nChild*: NodePtr 694 | 695 | PyWeakReferencePtr* = ptr PyWeakReference 696 | PyWeakReference* = object of PyObject 697 | wr_object*: PyObjectPtr 698 | wr_callback*: PyObjectPtr 699 | hash*: int32 700 | wr_prev*: PyWeakReferencePtr 701 | wr_next*: PyWeakReferencePtr 702 | {.deprecated: [CO_MAXBLOCKS: coMaxblocks].} 703 | 704 | const 705 | pydatetimeDateDatasize* = 4 # of bytes for year, month, and day 706 | pydatetimeTimeDatasize* = 6 # of bytes for hour, minute, second, and usecond 707 | pydatetimeDatetimeDatasize* = 10 # of bytes for year, month, 708 | # day, hour, minute, second, and usecond. 709 | {.deprecated: [PyDateTime_DATE_DATASIZE: pydatetimeDateDatasize].} 710 | {.deprecated: [PyDateTime_TIME_DATASIZE: pydatetimeTimeDatasize].} 711 | {.deprecated: [PyDateTime_DATETIME_DATASIZE: pydatetimeDatetimeDatasize].} 712 | 713 | type 714 | PyDateTimeDelta* = object of PyObject 715 | hashcode*: int # -1 when unknown 716 | days*: int # -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS 717 | seconds*: int # 0 <= seconds < 24*3600 is invariant 718 | microseconds*: int # 0 <= microseconds < 1000000 is invariant 719 | 720 | PyDateTimeDeltaPtr* = ptr PyDateTimeDelta 721 | PyDateTimeTZInfo* = object of PyObject # a pure abstract base clase 722 | PyDateTimeTZInfoPtr* = ptr PyDateTimeTZInfo 723 | PyDateTimeBaseTZInfo* = object of PyObject 724 | hashcode*: int 725 | # boolean flag 726 | hastzinfo*: bool 727 | 728 | PyDateTimeBaseTZInfoPtr* = ptr PyDateTimeBaseTZInfo 729 | PyDateTimeBaseTime* = object of PyDateTimeBaseTZInfo 730 | data*: array[0..pred(pydatetimeTimeDatasize), int8] 731 | 732 | PyDateTimeBaseTimePtr* = ptr PyDateTimeBaseTime 733 | PyDateTimeTime* = object of PyDateTimeBaseTime # hastzinfo true 734 | tzinfo*: PyObjectPtr 735 | 736 | PyDateTimeTimePtr* = ptr PyDateTimeTime 737 | PyDateTimeDate* = object of PyDateTimeBaseTZInfo 738 | data*: array[0..pred(pydatetimeDateDatasize), int8] 739 | 740 | PyDateTimeDatePtr* = ptr PyDateTimeDate 741 | PyDateTimeBaseDateTime* = object of PyDateTimeBaseTZInfo 742 | data*: array[0..pred(pydatetimeDatetimeDatasize), int8] 743 | 744 | PyDateTimeBaseDateTimePtr* = ptr PyDateTimeBaseDateTime 745 | PyDateTimeDateTime* = object of PyDateTimeBaseTZInfo 746 | data*: array[0..pred(pydatetimeDatetimeDatasize), int8] 747 | tzinfo*: PyObjectPtr 748 | 749 | PyDateTimeDateTimePtr* = ptr PyDateTimeDateTime 750 | 751 | ## Deprecated type definitions 752 | {.deprecated: [TAllocFunc: AllocFunc].} 753 | {.deprecated: [TBinaryFunc: BinaryFunc].} 754 | {.deprecated: [PByte: BytePtr].} 755 | {.deprecated: [TCmpFunc: CmpFunc].} 756 | {.deprecated: [TCO_MAXBLOCKS: coMaxblocks].} 757 | {.deprecated: [TCoercion: Coercion].} 758 | {.deprecated: [TDescrGetFunc: DescrGetFunc].} 759 | {.deprecated: [TDescrSetFunc: DescrSetFunc].} 760 | {.deprecated: [Tfrozen: Frozen].} 761 | {.deprecated: [P_frozen: FrozenPtr].} 762 | {.deprecated: [PP_frozen: FrozenPtrPtr].} 763 | {.deprecated: [TGetAttrFunc: GetAttrFunc].} 764 | {.deprecated: [TGetAttroFunc: GetAttroFunc].} 765 | {.deprecated: [TGetCharBufferProc: GetCharBufferProc].} 766 | {.deprecated: [TGetIterFunc: GetIterFunc].} 767 | {.deprecated: [TGetReadBufferProc: GetReadBufferProc].} 768 | {.deprecated: [TGetSegCountProc: GetSegCountProc].} 769 | {.deprecated: [TGetter: Getter].} 770 | {.deprecated: [TGetWriteBufferProc: GetWriteBufferProc].} 771 | {.deprecated: [THashFunc: HashFunc].} 772 | {.deprecated: [TInitProc: InitProc].} 773 | {.deprecated: [TInquiry: Inquiry].} 774 | {.deprecated: [TIntArgFunc: IntArgFunc].} 775 | {.deprecated: [TIntIntArgFunc: IntIntArgFunc].} 776 | {.deprecated: [TIntIntObjArgProc: IntIntObjArgProc].} 777 | {.deprecated: [TIntObjArgProc: IntObjArgProc].} 778 | {.deprecated: [PInt: IntPtr].} 779 | {.deprecated: [TIterNextFunc: IterNextFunc].} 780 | {.deprecated: [TNewFunc: NewFunc].} 781 | {.deprecated: [Tnode: Node].} 782 | {.deprecated: [PNode: NodePtr].} 783 | {.deprecated: [TObjObjargProc: ObjObjargProc].} 784 | {.deprecated: [TObjObjProc: ObjObjProc].} 785 | {.deprecated: [TPFlag: PFlag].} 786 | {.deprecated: [TPFlags: PFlags].} 787 | {.deprecated: [TPrintFunc: PrintFunc].} 788 | {.deprecated: [pwrapperbase: wrapperbasePtr].} 789 | {.deprecated: [TPyComplex: PyComplex].} 790 | {.deprecated: [TPyBufferProcs: PyBufferProcs].} 791 | {.deprecated: [PPyBufferProcs: PyBufferProcsPtr].} 792 | {.deprecated: [TPyCFunction: PyCFunction].} 793 | {.deprecated: [TPyClassObject: PyClassObject].} 794 | {.deprecated: [PPyClassObject: PyClassObjectPtr].} 795 | {.deprecated: [TPyCodeObject: PyCodeObject].} 796 | {.deprecated: [PPyCodeObject: PyCodeObjectPtr].} 797 | {.deprecated: [TPyDateTime_BaseDateTime: PyDateTime_BaseDateTime].} 798 | {.deprecated: [PPyDateTime_BaseDateTime: PyDateTime_BaseDateTimePtr].} 799 | {.deprecated: [TPyDateTime_BaseTime: PyDateTime_BaseTime].} 800 | {.deprecated: [PPyDateTime_BaseTime: PyDateTime_BaseTimePtr].} 801 | {.deprecated: [TPyDateTime_BaseTZInfo: PyDateTime_BaseTZInfo].} 802 | {.deprecated: [PPyDateTime_BaseTZInfo: PyDateTime_BaseTZInfoPtr].} 803 | {.deprecated: [TPyDateTime_Date: PyDateTime_Date].} 804 | {.deprecated: [PPyDateTime_Date: PyDateTime_DatePtr].} 805 | {.deprecated: [TPyDateTime_DateTime: PyDateTime_DateTime].} 806 | {.deprecated: [PPyDateTime_DateTime: PyDateTime_DateTimePtr].} 807 | {.deprecated: [TPyDateTime_Delta: PyDateTime_Delta].} 808 | {.deprecated: [PPyDateTime_Delta: PyDateTime_DeltaPtr].} 809 | {.deprecated: [TPyDateTime_Time: PyDateTime_Time].} 810 | {.deprecated: [PPyDateTime_Time: PyDateTime_TimePtr].} 811 | {.deprecated: [TPyDateTime_TZInfo: PyDateTime_TZInfo].} 812 | {.deprecated: [PPyDateTime_TZInfo: PyDateTime_TZInfoPtr].} 813 | {.deprecated: [TPyDescrObject: PyDescrObject].} 814 | {.deprecated: [PPyDescrObject: PyDescrObjectPtr].} 815 | {.deprecated: [TPyDestructor: PyDestructor].} 816 | {.deprecated: [TPyFrameObject: PyFrameObject].} 817 | {.deprecated: [PPyFrameObject: PyFrameObjectPtr].} 818 | {.deprecated: [TPyGetSetDef: PyGetSetDef].} 819 | {.deprecated: [PPyGetSetDef: PyGetSetDefPtr].} 820 | {.deprecated: [TPyGetSetDescrObject: PyGetSetDescrObject].} 821 | {.deprecated: [PPyGetSetDescrObject: PyGetSetDescrObjectPtr].} 822 | {.deprecated: [TPyInstanceObject: PyInstanceObject].} 823 | {.deprecated: [PPyInstanceObject: PyInstanceObjectPtr].} 824 | {.deprecated: [TPyInterpreterState: PyInterpreterState].} 825 | {.deprecated: [PPyInterpreterState: PyInterpreterStatePtr].} 826 | {.deprecated: [TPyIntObject: PyIntObject].} 827 | {.deprecated: [PPyIntObject: PyIntObjectPtr].} 828 | {.deprecated: [TPyMappingMethods: PyMappingMethods].} 829 | {.deprecated: [PPyMappingMethods: PyMappingMethodsPtr].} 830 | {.deprecated: [TPyMemberDef: PyMemberDef].} 831 | {.deprecated: [PPyMemberDef: PyMemberDefPtr].} 832 | {.deprecated: [TPyMemberDescrObject: PyMemberDescrObject].} 833 | {.deprecated: [PPyMemberDescrObject: PyMemberDescrObjectPtr].} 834 | {.deprecated: [TPyMemberFlag: PyMemberFlag].} 835 | {.deprecated: [TPyMemberType: PyMemberType].} 836 | {.deprecated: [TPyMethodChain: PyMethodChain].} 837 | {.deprecated: [PPyMethodChain: PyMethodChainPtr].} 838 | {.deprecated: [TPyMethodDef: PyMethodDef].} 839 | {.deprecated: [PPyMethodDef: PyMethodDefPtr].} 840 | {.deprecated: [TPyMethodDescrObject: PyMethodDescrObject].} 841 | {.deprecated: [PPyMethodDescrObject: PyMethodDescrObjectPtr].} 842 | {.deprecated: [TPyMethodObject: PyMethodObject].} 843 | {.deprecated: [PPyMethodObject: PyMethodObjectPtr].} 844 | {.deprecated: [TPyNumberMethods: PyNumberMethods].} 845 | {.deprecated: [PPyNumberMethods: PyNumberMethodsPtr].} 846 | {.deprecated: [TPyObject: PyObject].} 847 | {.deprecated: [PPyObject: PyObjectPtr].} 848 | {.deprecated: [PPPyObject: PyObjectPtrPtr].} 849 | {.deprecated: [PPPPyObject: PyObjectPtrPtrPtr].} 850 | {.deprecated: [TPySequenceMethods: PySequenceMethods].} 851 | {.deprecated: [PPySequenceMethods: PySequenceMethodsPtr].} 852 | {.deprecated: [TPySliceObject: PySliceObject].} 853 | {.deprecated: [PPySliceObject: PySliceObjectPtr].} 854 | {.deprecated: [TPyThreadState: PyThreadState].} 855 | {.deprecated: [PPyThreadState: PyThreadStatePtr].} 856 | {.deprecated: [TPyTraceBackObject: PyTraceBackObject].} 857 | {.deprecated: [PPyTraceBackObject: PyTraceBackObjectPtr].} 858 | {.deprecated: [TPyTryBlock: PyTryBlock].} 859 | {.deprecated: [PPyTryBlock: PyTryBlockPtr].} 860 | {.deprecated: [TPyTypeObject: PyTypeObject].} 861 | {.deprecated: [PPyTypeObject: PyTypeObjectPtr].} 862 | {.deprecated: [TPyWeakReference: PyWeakReference].} 863 | {.deprecated: [PPyWeakReference: PyWeakReferencePtr].} 864 | {.deprecated: [TPyWrapperDescrObject: PyWrapperDescrObject].} 865 | {.deprecated: [PPyWrapperDescrObject: PyWrapperDescrObjectPtr].} 866 | {.deprecated: [TReprFunc: ReprFunc].} 867 | {.deprecated: [TRichCmpFunc: RichCmpFunc].} 868 | {.deprecated: [TRichComparisonOpcode: RichComparisonOpcode].} 869 | {.deprecated: [TSetAttrFunc: SetAttrFunc].} 870 | {.deprecated: [TSetAttroFunc: SetAttroFunc].} 871 | {.deprecated: [TSetter: Setter].} 872 | {.deprecated: [TTernaryFunc: TernaryFunc].} 873 | {.deprecated: [TTraverseProc: TraverseProc].} 874 | {.deprecated: [TUnaryFunc: UnaryFunc].} 875 | {.deprecated: [TVisitProc: VisitProc].} 876 | {.deprecated: [Twrapperbase: wrapperbase].} 877 | {.deprecated: [Twrapperfunc: wrapperfunc].} 878 | 879 | 880 | #----------------------------------------------------# 881 | # # 882 | # New exception classes # 883 | # # 884 | #----------------------------------------------------# 885 | 886 | # 887 | # // Python's exceptions 888 | # EPythonError = object(Exception) 889 | # EName: String; 890 | # EValue: String; 891 | # end; 892 | # EPyExecError = object(EPythonError) 893 | # end; 894 | # 895 | # // Standard exception classes of Python 896 | # 897 | #/// jah 29-sep-2000: updated for python 2.0 898 | #/// base classes updated according python documentation 899 | # 900 | #Hierarchy of Python exceptions, Python 2.3, 901 | #copied from \Python\exceptions.c 902 | # 903 | #Exception\n\ 904 | # |\n\ 905 | # +-- SystemExit\n\ 906 | # +-- StopIteration\n\ 907 | # +-- StandardError\n\ 908 | # | |\n\ 909 | # | +-- KeyboardInterrupt\n\ 910 | # | +-- ImportError\n\ 911 | # | +-- EnvironmentError\n\ 912 | # | | |\n\ 913 | # | | +-- IOError\n\ 914 | # | | +-- OSError\n\ 915 | # | | |\n\ 916 | # | | +-- WindowsError\n\ 917 | # | | +-- VMSError\n\ 918 | # | |\n\ 919 | # | +-- EOFError\n\ 920 | # | +-- RuntimeError\n\ 921 | # | | |\n\ 922 | # | | +-- NotImplementedError\n\ 923 | # | |\n\ 924 | # | +-- NameError\n\ 925 | # | | |\n\ 926 | # | | +-- UnboundLocalError\n\ 927 | # | |\n\ 928 | # | +-- AttributeError\n\ 929 | # | +-- SyntaxError\n\ 930 | # | | |\n\ 931 | # | | +-- IndentationError\n\ 932 | # | | |\n\ 933 | # | | +-- TabError\n\ 934 | # | |\n\ 935 | # | +-- TypeError\n\ 936 | # | +-- AssertionError\n\ 937 | # | +-- LookupError\n\ 938 | # | | |\n\ 939 | # | | +-- IndexError\n\ 940 | # | | +-- KeyError\n\ 941 | # | |\n\ 942 | # | +-- ArithmeticError\n\ 943 | # | | |\n\ 944 | # | | +-- OverflowError\n\ 945 | # | | +-- ZeroDivisionError\n\ 946 | # | | +-- FloatingPointError\n\ 947 | # | |\n\ 948 | # | +-- ValueError\n\ 949 | # | | |\n\ 950 | # | | +-- UnicodeError\n\ 951 | # | | |\n\ 952 | # | | +-- UnicodeEncodeError\n\ 953 | # | | +-- UnicodeDecodeError\n\ 954 | # | | +-- UnicodeTranslateError\n\ 955 | # | |\n\ 956 | # | +-- ReferenceError\n\ 957 | # | +-- SystemError\n\ 958 | # | +-- MemoryError\n\ 959 | # |\n\ 960 | # +---Warning\n\ 961 | # |\n\ 962 | # +-- UserWarning\n\ 963 | # +-- DeprecationWarning\n\ 964 | # +-- PendingDeprecationWarning\n\ 965 | # +-- SyntaxWarning\n\ 966 | # +-- OverflowWarning\n\ 967 | # +-- RuntimeWarning\n\ 968 | # +-- FutureWarning" 969 | #} 970 | # EPyException = class (EPythonError); 971 | # EPyStandardError = class (EPyException); 972 | # EPyArithmeticError = class (EPyStandardError); 973 | # EPyLookupError = class (EPyStandardError); 974 | # EPyAssertionError = class (EPyStandardError); 975 | # EPyAttributeError = class (EPyStandardError); 976 | # EPyEOFError = class (EPyStandardError); 977 | # EPyFloatingPointError = class (EPyArithmeticError); 978 | # EPyEnvironmentError = class (EPyStandardError); 979 | # EPyIOError = class (EPyEnvironmentError); 980 | # EPyOSError = class (EPyEnvironmentError); 981 | # EPyImportError = class (EPyStandardError); 982 | # EPyIndexError = class (EPyLookupError); 983 | # EPyKeyError = class (EPyLookupError); 984 | # EPyKeyboardInterrupt = class (EPyStandardError); 985 | # EPyMemoryError = class (EPyStandardError); 986 | # EPyNameError = class (EPyStandardError); 987 | # EPyOverflowError = class (EPyArithmeticError); 988 | # EPyRuntimeError = class (EPyStandardError); 989 | # EPyNotImplementedError = class (EPyRuntimeError); 990 | # EPySyntaxError = class (EPyStandardError) 991 | # public 992 | # EFileName: string; 993 | # ELineStr: string; 994 | # ELineNumber: Integer; 995 | # EOffset: Integer; 996 | # end; 997 | # EPyIndentationError = class (EPySyntaxError); 998 | # EPyTabError = class (EPyIndentationError); 999 | # EPySystemError = class (EPyStandardError); 1000 | # EPySystemExit = class (EPyException); 1001 | # EPyTypeError = class (EPyStandardError); 1002 | # EPyUnboundLocalError = class (EPyNameError); 1003 | # EPyValueError = class (EPyStandardError); 1004 | # EPyUnicodeError = class (EPyValueError); 1005 | # UnicodeEncodeError = class (EPyUnicodeError); 1006 | # UnicodeDecodeError = class (EPyUnicodeError); 1007 | # UnicodeTranslateError = class (EPyUnicodeError); 1008 | # EPyZeroDivisionError = class (EPyArithmeticError); 1009 | # EPyStopIteration = class(EPyException); 1010 | # EPyWarning = class (EPyException); 1011 | # EPyUserWarning = class (EPyWarning); 1012 | # EPyDeprecationWarning = class (EPyWarning); 1013 | # PendingDeprecationWarning = class (EPyWarning); 1014 | # FutureWarning = class (EPyWarning); 1015 | # EPySyntaxWarning = class (EPyWarning); 1016 | # EPyOverflowWarning = class (EPyWarning); 1017 | # EPyRuntimeWarning = class (EPyWarning); 1018 | # EPyReferenceError = class (EPyStandardError); 1019 | 1020 | 1021 | var 1022 | PyArg_Parse*: proc (args: PyObjectPtr, format: cstring): int{.cdecl, varargs.} 1023 | PyArg_ParseTuple*: proc (args: PyObjectPtr, format: cstring, 1024 | x1: pointer = nil, x2: pointer = nil, 1025 | x3: pointer = nil): int{.cdecl, varargs.} 1026 | Py_BuildValue*: proc (format: cstring): PyObjectPtr{.cdecl, varargs.} 1027 | PyCode_Addr2Line*: proc (co: PyCodeObjectPtr, addrq: int): int{.cdecl.} 1028 | DLL_Py_GetBuildInfo*: proc (): cstring{.cdecl.} 1029 | 1030 | var 1031 | debugFlag*: IntPtr 1032 | verboseFlag*: IntPtr 1033 | interactiveFlag*: IntPtr 1034 | optimizeFlag*: IntPtr 1035 | noSiteFlag*: IntPtr 1036 | useClassExceptionsFlag*: IntPtr 1037 | frozenFlag*: IntPtr 1038 | tabcheckFlag*: IntPtr 1039 | unicodeFlag*: IntPtr 1040 | ignoreEnvironmentFlag*: IntPtr 1041 | divisionWarningFlag*: IntPtr 1042 | #_PySys_TraceFunc: PyObjectPtrPtr; 1043 | #_PySys_ProfileFunc: PyObjectPtrPtrPtr; 1044 | importFrozenModules*: FrozenPtrPtr 1045 | noneVar*: PyObjectPtr 1046 | ellipsis*: PyObjectPtr 1047 | falseVar*: PyIntObjectPtr 1048 | trueVar*: PyIntObjectPtr 1049 | notImplemented*: PyObjectPtr 1050 | excAttributeError*: PyObjectPtrPtr 1051 | excEOFError*: PyObjectPtrPtr 1052 | excIOError*: PyObjectPtrPtr 1053 | excImportError*: PyObjectPtrPtr 1054 | excIndexError*: PyObjectPtrPtr 1055 | excKeyError*: PyObjectPtrPtr 1056 | excKeyboardInterrupt*: PyObjectPtrPtr 1057 | excMemoryError*: PyObjectPtrPtr 1058 | excNameError*: PyObjectPtrPtr 1059 | excOverflowError*: PyObjectPtrPtr 1060 | excRuntimeError*: PyObjectPtrPtr 1061 | excSyntaxError*: PyObjectPtrPtr 1062 | excSystemError*: PyObjectPtrPtr 1063 | excSystemExit*: PyObjectPtrPtr 1064 | excTypeError*: PyObjectPtrPtr 1065 | excValueError*: PyObjectPtrPtr 1066 | excZeroDivisionError*: PyObjectPtrPtr 1067 | excArithmeticError*: PyObjectPtrPtr 1068 | excException*: PyObjectPtrPtr 1069 | excFloatingPointError*: PyObjectPtrPtr 1070 | excLookupError*: PyObjectPtrPtr 1071 | excStandardError*: PyObjectPtrPtr 1072 | excAssertionError*: PyObjectPtrPtr 1073 | excEnvironmentError*: PyObjectPtrPtr 1074 | excIndentationError*: PyObjectPtrPtr 1075 | excMemoryErrorInst*: PyObjectPtrPtr 1076 | excNotImplementedError*: PyObjectPtrPtr 1077 | excOSError*: PyObjectPtrPtr 1078 | excTabError*: PyObjectPtrPtr 1079 | excUnboundLocalError*: PyObjectPtrPtr 1080 | excUnicodeError*: PyObjectPtrPtr 1081 | excWarning*: PyObjectPtrPtr 1082 | excDeprecationWarning*: PyObjectPtrPtr 1083 | excRuntimeWarning*: PyObjectPtrPtr 1084 | excSyntaxWarning*: PyObjectPtrPtr 1085 | excUserWarning*: PyObjectPtrPtr 1086 | excOverflowWarning*: PyObjectPtrPtr 1087 | excReferenceError*: PyObjectPtrPtr 1088 | excStopIteration*: PyObjectPtrPtr 1089 | excFutureWarning*: PyObjectPtrPtr 1090 | excPendingDeprecationWarning*: PyObjectPtrPtr 1091 | excUnicodeDecodeError*: PyObjectPtrPtr 1092 | excUnicodeEncodeError*: PyObjectPtrPtr 1093 | excUnicodeTranslateError*: PyObjectPtrPtr 1094 | typeType*: PyTypeObjectPtr 1095 | cfunctionType*: PyTypeObjectPtr 1096 | cobjectType*: PyTypeObjectPtr 1097 | classType*: PyTypeObjectPtr 1098 | codeType*: PyTypeObjectPtr 1099 | complexType*: PyTypeObjectPtr 1100 | dictType*: PyTypeObjectPtr 1101 | fileType*: PyTypeObjectPtr 1102 | floatType*: PyTypeObjectPtr 1103 | frameType*: PyTypeObjectPtr 1104 | functionType*: PyTypeObjectPtr 1105 | instanceType*: PyTypeObjectPtr 1106 | intType*: PyTypeObjectPtr 1107 | listType*: PyTypeObjectPtr 1108 | longType*: PyTypeObjectPtr 1109 | methodType*: PyTypeObjectPtr 1110 | moduleType*: PyTypeObjectPtr 1111 | objectType*: PyTypeObjectPtr 1112 | rangeType*: PyTypeObjectPtr 1113 | sliceType*: PyTypeObjectPtr 1114 | stringType*: PyTypeObjectPtr 1115 | tupleType*: PyTypeObjectPtr 1116 | baseobjectType*: PyTypeObjectPtr 1117 | bufferType*: PyTypeObjectPtr 1118 | calliterType*: PyTypeObjectPtr 1119 | cellType*: PyTypeObjectPtr 1120 | classmethodType*: PyTypeObjectPtr 1121 | propertyType*: PyTypeObjectPtr 1122 | seqiterType*: PyTypeObjectPtr 1123 | staticmethodType*: PyTypeObjectPtr 1124 | superType*: PyTypeObjectPtr 1125 | symtableentryType*: PyTypeObjectPtr 1126 | tracebackType*: PyTypeObjectPtr 1127 | unicodeType*: PyTypeObjectPtr 1128 | wrapperdescrType*: PyTypeObjectPtr 1129 | basestringType*: PyTypeObjectPtr 1130 | boolType*: PyTypeObjectPtr 1131 | enumType*: PyTypeObjectPtr 1132 | {.deprecated: [Py_DebugFlag: debugFlag].} 1133 | {.deprecated: [Py_VerboseFlag: verboseFlag].} 1134 | {.deprecated: [Py_InteractiveFlag: interactiveFlag].} 1135 | {.deprecated: [Py_OptimizeFlag: optimizeFlag].} 1136 | {.deprecated: [Py_NoSiteFlag: noSiteFlag].} 1137 | {.deprecated: [Py_UseClassExceptionsFlag: useClassExceptionsFlag].} 1138 | {.deprecated: [Py_FrozenFlag: frozenFlag].} 1139 | {.deprecated: [Py_TabcheckFlag: tabcheckFlag].} 1140 | {.deprecated: [Py_UnicodeFlag: unicodeFlag].} 1141 | {.deprecated: [Py_IgnoreEnvironmentFlag: ignoreEnvironmentFlag].} 1142 | {.deprecated: [Py_DivisionWarningFlag: divisionWarningFlag].} 1143 | {.deprecated: [PyImport_FrozenModules: importFrozenModules].} 1144 | {.deprecated: [Py_None: noneVar].} 1145 | {.deprecated: [Py_Ellipsis: ellipsis].} 1146 | {.deprecated: [Py_False: falseVar].} 1147 | {.deprecated: [Py_True: trueVar].} 1148 | {.deprecated: [Py_NotImplemented: notImplemented].} 1149 | {.deprecated: [PyExc_AttributeError: excAttributeError].} 1150 | {.deprecated: [PyExc_EOFError: excEOFError].} 1151 | {.deprecated: [PyExc_IOError: excIOError].} 1152 | {.deprecated: [PyExc_ImportError: excImportError].} 1153 | {.deprecated: [PyExc_IndexError: excIndexError].} 1154 | {.deprecated: [PyExc_KeyError: excKeyError].} 1155 | {.deprecated: [PyExc_KeyboardInterrupt: excKeyboardInterrupt].} 1156 | {.deprecated: [PyExc_MemoryError: excMemoryError].} 1157 | {.deprecated: [PyExc_NameError: excNameError].} 1158 | {.deprecated: [PyExc_OverflowError: excOverflowError].} 1159 | {.deprecated: [PyExc_RuntimeError: excRuntimeError].} 1160 | {.deprecated: [PyExc_SyntaxError: excSyntaxError].} 1161 | {.deprecated: [PyExc_SystemError: excSystemError].} 1162 | {.deprecated: [PyExc_SystemExit: excSystemExit].} 1163 | {.deprecated: [PyExc_TypeError: excTypeError].} 1164 | {.deprecated: [PyExc_ValueError: excValueError].} 1165 | {.deprecated: [PyExc_ZeroDivisionError: excZeroDivisionError].} 1166 | {.deprecated: [PyExc_ArithmeticError: excArithmeticError].} 1167 | {.deprecated: [PyExc_Exception: excException].} 1168 | {.deprecated: [PyExc_FloatingPointError: excFloatingPointError].} 1169 | {.deprecated: [PyExc_LookupError: excLookupError].} 1170 | {.deprecated: [PyExc_StandardError: excStandardError].} 1171 | {.deprecated: [PyExc_AssertionError: excAssertionError].} 1172 | {.deprecated: [PyExc_EnvironmentError: excEnvironmentError].} 1173 | {.deprecated: [PyExc_IndentationError: excIndentationError].} 1174 | {.deprecated: [PyExc_MemoryErrorInst: excMemoryErrorInst].} 1175 | {.deprecated: [PyExc_NotImplementedError: excNotImplementedError].} 1176 | {.deprecated: [PyExc_OSError: excOSError].} 1177 | {.deprecated: [PyExc_TabError: excTabError].} 1178 | {.deprecated: [PyExc_UnboundLocalError: excUnboundLocalError].} 1179 | {.deprecated: [PyExc_UnicodeError: excUnicodeError].} 1180 | {.deprecated: [PyExc_Warning: excWarning].} 1181 | {.deprecated: [PyExc_DeprecationWarning: excDeprecationWarning].} 1182 | {.deprecated: [PyExc_RuntimeWarning: excRuntimeWarning].} 1183 | {.deprecated: [PyExc_SyntaxWarning: excSyntaxWarning].} 1184 | {.deprecated: [PyExc_UserWarning: excUserWarning].} 1185 | {.deprecated: [PyExc_OverflowWarning: excOverflowWarning].} 1186 | {.deprecated: [PyExc_ReferenceError: excReferenceError].} 1187 | {.deprecated: [PyExc_StopIteration: excStopIteration].} 1188 | {.deprecated: [PyExc_FutureWarning: excFutureWarning].} 1189 | {.deprecated: [PyExc_PendingDeprecationWarning: excPendingDeprecationWarning].} 1190 | {.deprecated: [PyExc_UnicodeDecodeError: excUnicodeDecodeError].} 1191 | {.deprecated: [PyExc_UnicodeEncodeError: excUnicodeEncodeError].} 1192 | {.deprecated: [PyExc_UnicodeTranslateError: excUnicodeTranslateError].} 1193 | {.deprecated: [PyType_Type: typeType].} 1194 | {.deprecated: [PyCFunction_Type: cfunctionType].} 1195 | {.deprecated: [PyCObject_Type: cobjectType].} 1196 | {.deprecated: [PyClass_Type: classType].} 1197 | {.deprecated: [PyCode_Type: codeType].} 1198 | {.deprecated: [PyComplex_Type: complexType].} 1199 | {.deprecated: [PyDict_Type: dictType].} 1200 | {.deprecated: [PyFile_Type: fileType].} 1201 | {.deprecated: [PyFloat_Type: floatType].} 1202 | {.deprecated: [PyFrame_Type: frameType].} 1203 | {.deprecated: [PyFunction_Type: functionType].} 1204 | {.deprecated: [PyInstance_Type: instanceType].} 1205 | {.deprecated: [PyInt_Type: intType].} 1206 | {.deprecated: [PyList_Type: listType].} 1207 | {.deprecated: [PyLong_Type: longType].} 1208 | {.deprecated: [PyMethod_Type: methodType].} 1209 | {.deprecated: [PyModule_Type: moduleType].} 1210 | {.deprecated: [PyObject_Type: objectType].} 1211 | {.deprecated: [PyRange_Type: rangeType].} 1212 | {.deprecated: [PySlice_Type: sliceType].} 1213 | {.deprecated: [PyString_Type: stringType].} 1214 | {.deprecated: [PyTuple_Type: tupleType].} 1215 | {.deprecated: [PyBaseObject_Type: baseobjectType].} 1216 | {.deprecated: [PyBuffer_Type: bufferType].} 1217 | {.deprecated: [PyCallIter_Type: calliterType].} 1218 | {.deprecated: [PyCell_Type: cellType].} 1219 | {.deprecated: [PyClassMethod_Type: classmethodType].} 1220 | {.deprecated: [PyProperty_Type: propertyType].} 1221 | {.deprecated: [PySeqIter_Type: seqiterType].} 1222 | {.deprecated: [PyStaticMethod_Type: staticmethodType].} 1223 | {.deprecated: [PySuper_Type: superType].} 1224 | {.deprecated: [PySymtableEntry_Type: symtableentryType].} 1225 | {.deprecated: [PyTraceBack_Type: tracebackType].} 1226 | {.deprecated: [PyUnicode_Type: unicodeType].} 1227 | {.deprecated: [PyWrapperDescr_Type: wrapperdescrType].} 1228 | {.deprecated: [PyBaseString_Type: basestringType].} 1229 | {.deprecated: [PyBool_Type: boolType].} 1230 | {.deprecated: [PyEnum_Type: enumType].} 1231 | 1232 | proc vaBuildValue*(format: cstring; va_list: varargs): PyObjectPtr{.cdecl, 1233 | importc: "Py_VaBuildValue", dynlib: dllname.} 1234 | proc builtinInit*(){.cdecl, importc: "_PyBuiltin_Init", dynlib: dllname.} 1235 | proc complexFromCComplex*(c: PyComplex): PyObjectPtr{.cdecl, 1236 | importc: "PyComplex_FromCComplex", dynlib: dllname.} 1237 | proc complexFromDoubles*(realv, imag: float64): PyObjectPtr{.cdecl, 1238 | importc: "PyComplex_FromDoubles", dynlib: dllname.} 1239 | proc complexRealAsDouble*(op: PyObjectPtr): float64{.cdecl, 1240 | importc: "PyComplex_RealAsDouble", dynlib: dllname.} 1241 | proc complexImagAsDouble*(op: PyObjectPtr): float64{.cdecl, 1242 | importc: "PyComplex_ImagAsDouble", dynlib: dllname.} 1243 | proc complexAsCComplex*(op: PyObjectPtr): PyComplex{.cdecl, 1244 | importc: "PyComplex_AsCComplex", dynlib: dllname.} 1245 | proc cfunctionGetFunction*(ob: PyObjectPtr): pointer{.cdecl, 1246 | importc: "PyCFunction_GetFunction", dynlib: dllname.} 1247 | proc cfunctionGetSelf*(ob: PyObjectPtr): PyObjectPtr{.cdecl, 1248 | importc: "PyCFunction_GetSelf", dynlib: dllname.} 1249 | proc callableCheck*(ob: PyObjectPtr): int{.cdecl, importc: "PyCallable_Check", 1250 | dynlib: dllname.} 1251 | proc cobjectFromVoidPtr*(cobj, destruct: pointer): PyObjectPtr{.cdecl, 1252 | importc: "PyCObject_FromVoidPtr", dynlib: dllname.} 1253 | proc cobjectAsVoidPtr*(ob: PyObjectPtr): pointer{.cdecl, 1254 | importc: "PyCObject_AsVoidPtr", dynlib: dllname.} 1255 | proc classNew*(ob1, ob2, ob3: PyObjectPtr): PyObjectPtr{.cdecl, 1256 | importc: "PyClass_New", dynlib: dllname.} 1257 | proc classIsSubclass*(ob1, ob2: PyObjectPtr): int{.cdecl, 1258 | importc: "PyClass_IsSubclass", dynlib: dllname.} 1259 | proc initModule4*(name: cstring, methods: PyMethodDefPtr, doc: cstring, 1260 | passthrough: PyObjectPtr, Api_Version: int): PyObjectPtr{. 1261 | cdecl, importc: "Py_InitModule4", dynlib: dllname.} 1262 | proc errBadArgument*(): int{.cdecl, importc: "PyErr_BadArgument", 1263 | dynlib: dllname.} 1264 | proc errBadInternalCall*(){.cdecl, importc: "PyErr_BadInternalCall", 1265 | dynlib: dllname.} 1266 | proc errCheckSignals*(): int{.cdecl, importc: "PyErr_CheckSignals", 1267 | dynlib: dllname.} 1268 | proc errClear*(){.cdecl, importc: "PyErr_Clear", dynlib: dllname.} 1269 | proc errFetch*(errtype, errvalue, errtraceback: PyObjectPtrPtr){.cdecl, 1270 | importc: "PyErr_Fetch", dynlib: dllname.} 1271 | proc errNoMemory*(): PyObjectPtr{.cdecl, importc: "PyErr_NoMemory", 1272 | dynlib: dllname.} 1273 | proc errOccurred*(): PyObjectPtr{.cdecl, importc: "PyErr_Occurred", 1274 | dynlib: dllname.} 1275 | proc errPrint*(){.cdecl, importc: "PyErr_Print", dynlib: dllname.} 1276 | proc errRestore*(errtype, errvalue, errtraceback: PyObjectPtr){.cdecl, 1277 | importc: "PyErr_Restore", dynlib: dllname.} 1278 | proc errSetFromErrno*(ob: PyObjectPtr): PyObjectPtr{.cdecl, 1279 | importc: "PyErr_SetFromErrno", dynlib: dllname.} 1280 | proc errSetNone*(value: PyObjectPtr){.cdecl, importc: "PyErr_SetNone", 1281 | dynlib: dllname.} 1282 | proc errSetObject*(ob1, ob2: PyObjectPtr){.cdecl, importc: "PyErr_SetObject", 1283 | dynlib: dllname.} 1284 | proc errSetString*(ErrorObject: PyObjectPtr, text: cstring){.cdecl, 1285 | importc: "PyErr_SetString", dynlib: dllname.} 1286 | proc importGetModuleDict*(): PyObjectPtr{.cdecl, 1287 | importc: "PyImport_GetModuleDict", dynlib: dllname.} 1288 | proc intFromLong*(x: int32): PyObjectPtr{.cdecl, importc: "PyInt_FromLong", 1289 | dynlib: dllname.} 1290 | proc initialize*(){.cdecl, importc: "Py_Initialize", 1291 | dynlib: dllname.} 1292 | proc exit*(RetVal: int){.cdecl, importc: "Py_Exit", 1293 | dynlib: dllname.} 1294 | proc evalGetBuiltins*(): PyObjectPtr{.cdecl, importc: "PyEval_GetBuiltins", 1295 | dynlib: dllname.} 1296 | proc dictGetItem*(mp, key: PyObjectPtr): PyObjectPtr{.cdecl, 1297 | importc: "PyDict_GetItem", dynlib: dllname.} 1298 | proc dictSetItem*(mp, key, item: PyObjectPtr): int{.cdecl, 1299 | importc: "PyDict_SetItem", dynlib: dllname.} 1300 | proc dictDelItem*(mp, key: PyObjectPtr): int{.cdecl, 1301 | importc: "PyDict_DelItem", dynlib: dllname.} 1302 | proc dictClear*(mp: PyObjectPtr){.cdecl, importc: "PyDict_Clear", 1303 | dynlib: dllname.} 1304 | proc dictNext*(mp: PyObjectPtr, pos: IntPtr, key, 1305 | value: PyObjectPtrPtr): int{.cdecl, importc: "PyDict_Next", 1306 | dynlib: dllname.} 1307 | proc dictKeys*(mp: PyObjectPtr): PyObjectPtr{.cdecl, importc: "PyDict_Keys", 1308 | dynlib: dllname.} 1309 | proc dictValues*(mp: PyObjectPtr): PyObjectPtr{.cdecl, 1310 | importc: "PyDict_Values", dynlib: dllname.} 1311 | proc dictItems*(mp: PyObjectPtr): PyObjectPtr{.cdecl, 1312 | importc: "PyDict_Items", dynlib: dllname.} 1313 | proc dictSize*(mp: PyObjectPtr): int{.cdecl, importc: "PyDict_Size", 1314 | dynlib: dllname.} 1315 | proc dictDelItemString*(dp: PyObjectPtr, key: cstring): int{.cdecl, 1316 | importc: "PyDict_DelItemString", dynlib: dllname.} 1317 | proc dictNew*(): PyObjectPtr{.cdecl, importc: "PyDict_New", 1318 | dynlib: dllname.} 1319 | proc dictGetItemString*(dp: PyObjectPtr, key: cstring): PyObjectPtr{.cdecl, 1320 | importc: "PyDict_GetItemString", dynlib: dllname.} 1321 | proc dictSetItemString*(dp: PyObjectPtr, key: cstring, 1322 | item: PyObjectPtr): int{.cdecl, 1323 | importc: "PyDict_SetItemString", dynlib: dllname.} 1324 | proc dictproxyNew*(obj: PyObjectPtr): PyObjectPtr{.cdecl, 1325 | importc: "PyDictProxy_New", dynlib: dllname.} 1326 | proc moduleGetDict*(module: PyObjectPtr): PyObjectPtr{.cdecl, 1327 | importc: "PyModule_GetDict", dynlib: dllname.} 1328 | proc objectStr*(v: PyObjectPtr): PyObjectPtr{.cdecl, importc: "PyObject_Str", 1329 | dynlib: dllname.} 1330 | proc runString*(str: cstring, start: int, globals: PyObjectPtr, 1331 | locals: PyObjectPtr): PyObjectPtr{.cdecl, 1332 | importc: "PyRun_String", dynlib: dllname.} 1333 | proc runSimpleString*(str: cstring): int{.cdecl, 1334 | importc: "PyRun_SimpleString", dynlib: dllname.} 1335 | proc stringAsString*(ob: PyObjectPtr): cstring{.cdecl, 1336 | importc: "PyString_AsString", dynlib: dllname.} 1337 | proc stringFromString*(str: cstring): PyObjectPtr{.cdecl, 1338 | importc: "PyString_FromString", dynlib: dllname.} 1339 | proc sysSetArgv*(argc: int, argv: cstringArray){.cdecl, 1340 | importc: "PySys_SetArgv", dynlib: dllname.} 1341 | #+ means, Grzegorz or me has tested his non object version of this function 1342 | #+ 1343 | proc cfunctionNew*(md: PyMethodDefPtr, ob: PyObjectPtr): PyObjectPtr{.cdecl, 1344 | importc: "PyCFunction_New", dynlib: dllname.} #+ 1345 | proc evalCallObject*(ob1, ob2: PyObjectPtr): PyObjectPtr{.cdecl, 1346 | importc: "PyEval_CallObject", dynlib: dllname.} #- 1347 | proc evalCallObjectWithKeywords*(ob1, ob2, ob3: PyObjectPtr): PyObjectPtr{.cdecl, 1348 | importc: "PyEval_CallObjectWithKeywords", dynlib: dllname.} #- 1349 | proc evalGetFrame*(): PyObjectPtr{.cdecl, importc: "PyEval_GetFrame", 1350 | dynlib: dllname.} #- 1351 | proc evalGetGlobals*(): PyObjectPtr{.cdecl, importc: "PyEval_GetGlobals", 1352 | dynlib: dllname.} #- 1353 | proc evalGetLocals*(): PyObjectPtr{.cdecl, importc: "PyEval_GetLocals", 1354 | dynlib: dllname.} #- 1355 | proc evalGetOwner*(): PyObjectPtr {.cdecl, importc: "PyEval_GetOwner", 1356 | dynlib: dllname.} 1357 | proc evalGetRestricted*(): int{.cdecl, importc: "PyEval_GetRestricted", 1358 | dynlib: dllname.} #- 1359 | proc evalInitThreads*(){.cdecl, importc: "PyEval_InitThreads", 1360 | dynlib: dllname.} #- 1361 | proc evalRestoreThread*(tstate: PyThreadStatePtr){.cdecl, 1362 | importc: "PyEval_RestoreThread", dynlib: dllname.} #- 1363 | proc evalSaveThread*(): PyThreadStatePtr{.cdecl, 1364 | importc: "PyEval_SaveThread", dynlib: dllname.} #- 1365 | proc fileFromString*(pc1, pc2: cstring): PyObjectPtr{.cdecl, 1366 | importc: "PyFile_FromString", dynlib: dllname.} #- 1367 | proc fileGetLine*(ob: PyObjectPtr, i: int): PyObjectPtr{.cdecl, 1368 | importc: "PyFile_GetLine", dynlib: dllname.} #- 1369 | proc fileName*(ob: PyObjectPtr): PyObjectPtr{.cdecl, importc: "PyFile_Name", 1370 | dynlib: dllname.} #- 1371 | proc fileSetBufSize*(ob: PyObjectPtr, i: int){.cdecl, 1372 | importc: "PyFile_SetBufSize", dynlib: dllname.} #- 1373 | proc fileSoftSpace*(ob: PyObjectPtr, i: int): int{.cdecl, 1374 | importc: "PyFile_SoftSpace", dynlib: dllname.} #- 1375 | proc fileWriteObject*(ob1, ob2: PyObjectPtr, i: int): int{.cdecl, 1376 | importc: "PyFile_WriteObject", dynlib: dllname.} #- 1377 | proc fileWriteString*(s: cstring, ob: PyObjectPtr){.cdecl, 1378 | importc: "PyFile_WriteString", dynlib: dllname.} #+ 1379 | proc floatAsDouble*(ob: PyObjectPtr): float64{.cdecl, 1380 | importc: "PyFloat_AsDouble", dynlib: dllname.} #+ 1381 | proc floatFromDouble*(db: float64): PyObjectPtr{.cdecl, 1382 | importc: "PyFloat_FromDouble", dynlib: dllname.} #- 1383 | proc functionGetCode*(ob: PyObjectPtr): PyObjectPtr{.cdecl, 1384 | importc: "PyFunction_GetCode", dynlib: dllname.} #- 1385 | proc functionGetGlobals*(ob: PyObjectPtr): PyObjectPtr{.cdecl, 1386 | importc: "PyFunction_GetGlobals", dynlib: dllname.} #- 1387 | proc functionNew*(ob1, ob2: PyObjectPtr): PyObjectPtr{.cdecl, 1388 | importc: "PyFunction_New", dynlib: dllname.} #- 1389 | proc importAddModule*(name: cstring): PyObjectPtr{.cdecl, 1390 | importc: "PyImport_AddModule", dynlib: dllname.} #- 1391 | proc importCleanup*(){.cdecl, importc: "PyImport_Cleanup", 1392 | dynlib: dllname.} #- 1393 | proc importGetMagicNumber*(): int32{.cdecl, 1394 | importc: "PyImport_GetMagicNumber", dynlib: dllname.} #+ 1395 | proc importImportFrozenModule*(key: cstring): int{.cdecl, 1396 | importc: "PyImport_ImportFrozenModule", dynlib: dllname.} #+ 1397 | proc importImportModule*(name: cstring): PyObjectPtr{.cdecl, 1398 | importc: "PyImport_ImportModule", dynlib: dllname.} #+ 1399 | proc importImport*(name: PyObjectPtr): PyObjectPtr{.cdecl, 1400 | importc: "PyImport_Import", dynlib: dllname.} #- 1401 | proc importInit*() {.cdecl, importc: "PyImport_Init", 1402 | dynlib: dllname.} 1403 | proc importReloadModule*(ob: PyObjectPtr): PyObjectPtr{.cdecl, 1404 | importc: "PyImport_ReloadModule", dynlib: dllname.} #- 1405 | proc instanceNew*(obClass, obArg, obKW: PyObjectPtr): PyObjectPtr{.cdecl, 1406 | importc: "PyInstance_New", dynlib: dllname.} #+ 1407 | proc intAsLong*(ob: PyObjectPtr): int32{.cdecl, importc: "PyInt_AsLong", 1408 | dynlib: dllname.} #- 1409 | proc listAppend*(ob1, ob2: PyObjectPtr): int{.cdecl, 1410 | importc: "PyList_Append", dynlib: dllname.} #- 1411 | proc listAsTuple*(ob: PyObjectPtr): PyObjectPtr{.cdecl, 1412 | importc: "PyList_AsTuple", dynlib: dllname.} #+ 1413 | proc listGetItem*(ob: PyObjectPtr, i: int): PyObjectPtr{.cdecl, 1414 | importc: "PyList_GetItem", dynlib: dllname.} #- 1415 | proc listGetSlice*(ob: PyObjectPtr, i1, i2: int): PyObjectPtr{.cdecl, 1416 | importc: "PyList_GetSlice", dynlib: dllname.} #- 1417 | proc listInsert*(dp: PyObjectPtr, idx: int, item: PyObjectPtr): int{.cdecl, 1418 | importc: "PyList_Insert", dynlib: dllname.} #- 1419 | proc listNew*(size: int): PyObjectPtr{.cdecl, importc: "PyList_New", 1420 | dynlib: dllname.} #- 1421 | proc listReverse*(ob: PyObjectPtr): int{.cdecl, importc: "PyList_Reverse", 1422 | dynlib: dllname.} #- 1423 | proc listSetItem*(dp: PyObjectPtr, idx: int, item: PyObjectPtr): int{.cdecl, 1424 | importc: "PyList_SetItem", dynlib: dllname.} #- 1425 | proc listSetSlice*(ob: PyObjectPtr, i1, i2: int, ob2: PyObjectPtr): int{.cdecl, 1426 | importc: "PyList_SetSlice", dynlib: dllname.} #+ 1427 | proc listSize*(ob: PyObjectPtr): int{.cdecl, importc: "PyList_Size", 1428 | dynlib: dllname.} #- 1429 | proc listSort*(ob: PyObjectPtr): int{.cdecl, importc: "PyList_Sort", 1430 | dynlib: dllname.} #- 1431 | proc longAsDouble*(ob: PyObjectPtr): float64{.cdecl, 1432 | importc: "PyLong_AsDouble", dynlib: dllname.} #+ 1433 | proc longAsLong*(ob: PyObjectPtr): int32{.cdecl, importc: "PyLong_AsLong", 1434 | dynlib: dllname.} #+ 1435 | proc longFromDouble*(db: float64): PyObjectPtr{.cdecl, 1436 | importc: "PyLong_FromDouble", dynlib: dllname.} #+ 1437 | proc longFromLong*(L: int32): PyObjectPtr{.cdecl, importc: "PyLong_FromLong", 1438 | dynlib: dllname.} #- 1439 | proc longFromString*(pc: cstring, ppc: var cstring, i: int): PyObjectPtr{.cdecl, 1440 | importc: "PyLong_FromString", dynlib: dllname.} #- 1441 | proc longFromUnsignedLong*(val: int): PyObjectPtr{.cdecl, 1442 | importc: "PyLong_FromUnsignedLong", dynlib: dllname.} #- 1443 | proc longAsUnsignedLong*(ob: PyObjectPtr): int{.cdecl, 1444 | importc: "PyLong_AsUnsignedLong", dynlib: dllname.} #- 1445 | proc longFromUnicode*(ob: PyObjectPtr, a, b: int): PyObjectPtr{.cdecl, 1446 | importc: "PyLong_FromUnicode", dynlib: dllname.} #- 1447 | proc longFromLongLong*(val: int64): PyObjectPtr{.cdecl, 1448 | importc: "PyLong_FromLongLong", dynlib: dllname.} #- 1449 | proc longAsLongLong*(ob: PyObjectPtr): int64{.cdecl, 1450 | importc: "PyLong_AsLongLong", dynlib: dllname.} #- 1451 | proc mappingCheck*(ob: PyObjectPtr): int{.cdecl, importc: "PyMapping_Check", 1452 | dynlib: dllname.} #- 1453 | proc mappingGetItemString*(ob: PyObjectPtr, key: cstring): PyObjectPtr{.cdecl, 1454 | importc: "PyMapping_GetItemString", dynlib: dllname.} #- 1455 | proc mappingHasKey*(ob, key: PyObjectPtr): int{.cdecl, 1456 | importc: "PyMapping_HasKey", dynlib: dllname.} #- 1457 | proc mappingHasKeyString*(ob: PyObjectPtr, key: cstring): int{.cdecl, 1458 | importc: "PyMapping_HasKeyString", dynlib: dllname.} #- 1459 | proc mappingLength*(ob: PyObjectPtr): int{.cdecl, 1460 | importc: "PyMapping_Length", dynlib: dllname.} #- 1461 | proc mappingSetItemString*(ob: PyObjectPtr, key: cstring, 1462 | value: PyObjectPtr): int{.cdecl, 1463 | importc: "PyMapping_SetItemString", 1464 | dynlib: dllname.} #- 1465 | proc methodClass*(ob: PyObjectPtr): PyObjectPtr{.cdecl, 1466 | importc: "PyMethod_Class", dynlib: dllname.} #- 1467 | proc methodFunction*(ob: PyObjectPtr): PyObjectPtr{.cdecl, 1468 | importc: "PyMethod_Function", dynlib: dllname.} #- 1469 | proc methodNew*(ob1, ob2, ob3: PyObjectPtr): PyObjectPtr{.cdecl, 1470 | importc: "PyMethod_New", dynlib: dllname.} #- 1471 | proc methodSelf*(ob: PyObjectPtr): PyObjectPtr{.cdecl, 1472 | importc: "PyMethod_Self", dynlib: dllname.} #- 1473 | proc moduleGetName*(ob: PyObjectPtr): cstring{.cdecl, 1474 | importc: "PyModule_GetName", dynlib: dllname.} #- 1475 | proc moduleNew*(key: cstring): PyObjectPtr{.cdecl, importc: "PyModule_New", 1476 | dynlib: dllname.} #- 1477 | proc numberAbsolute*(ob: PyObjectPtr): PyObjectPtr{.cdecl, 1478 | importc: "PyNumber_Absolute", dynlib: dllname.} #- 1479 | proc numberAdd*(ob1, ob2: PyObjectPtr): PyObjectPtr{.cdecl, 1480 | importc: "PyNumber_Add", dynlib: dllname.} #- 1481 | proc numberAnd*(ob1, ob2: PyObjectPtr): PyObjectPtr{.cdecl, 1482 | importc: "PyNumber_And", dynlib: dllname.} #- 1483 | proc numberCheck*(ob: PyObjectPtr): int{.cdecl, importc: "PyNumber_Check", 1484 | dynlib: dllname.} #- 1485 | proc numberCoerce*(ob1, ob2: var PyObjectPtr): int{.cdecl, 1486 | importc: "PyNumber_Coerce", dynlib: dllname.} #- 1487 | proc numberDivide*(ob1, ob2: PyObjectPtr): PyObjectPtr{.cdecl, 1488 | importc: "PyNumber_Divide", dynlib: dllname.} #- 1489 | proc numberFloorDivide*(ob1, ob2: PyObjectPtr): PyObjectPtr{.cdecl, 1490 | importc: "PyNumber_FloorDivide", dynlib: dllname.} #- 1491 | proc numberTrueDivide*(ob1, ob2: PyObjectPtr): PyObjectPtr{.cdecl, 1492 | importc: "PyNumber_TrueDivide", dynlib: dllname.} #- 1493 | proc numberDivmod*(ob1, ob2: PyObjectPtr): PyObjectPtr{.cdecl, 1494 | importc: "PyNumber_Divmod", dynlib: dllname.} #- 1495 | proc numberFloat*(ob: PyObjectPtr): PyObjectPtr{.cdecl, 1496 | importc: "PyNumber_Float", dynlib: dllname.} #- 1497 | proc numberInt*(ob: PyObjectPtr): PyObjectPtr{.cdecl, 1498 | importc: "PyNumber_Int", dynlib: dllname.} #- 1499 | proc numberInvert*(ob: PyObjectPtr): PyObjectPtr{.cdecl, 1500 | importc: "PyNumber_Invert", dynlib: dllname.} #- 1501 | proc numberLong*(ob: PyObjectPtr): PyObjectPtr{.cdecl, 1502 | importc: "PyNumber_Long", dynlib: dllname.} #- 1503 | proc numberLshift*(ob1, ob2: PyObjectPtr): PyObjectPtr{.cdecl, 1504 | importc: "PyNumber_Lshift", dynlib: dllname.} #- 1505 | proc numberMultiply*(ob1, ob2: PyObjectPtr): PyObjectPtr{.cdecl, 1506 | importc: "PyNumber_Multiply", dynlib: dllname.} #- 1507 | proc numberNegative*(ob: PyObjectPtr): PyObjectPtr{.cdecl, 1508 | importc: "PyNumber_Negative", dynlib: dllname.} #- 1509 | proc numberOr*(ob1, ob2: PyObjectPtr): PyObjectPtr{.cdecl, 1510 | importc: "PyNumber_Or", dynlib: dllname.} #- 1511 | proc numberPositive*(ob: PyObjectPtr): PyObjectPtr{.cdecl, 1512 | importc: "PyNumber_Positive", dynlib: dllname.} #- 1513 | proc numberPower*(ob1, ob2, ob3: PyObjectPtr): PyObjectPtr{.cdecl, 1514 | importc: "PyNumber_Power", dynlib: dllname.} #- 1515 | proc numberRemainder*(ob1, ob2: PyObjectPtr): PyObjectPtr{.cdecl, 1516 | importc: "PyNumber_Remainder", dynlib: dllname.} #- 1517 | proc numberRshift*(ob1, ob2: PyObjectPtr): PyObjectPtr{.cdecl, 1518 | importc: "PyNumber_Rshift", dynlib: dllname.} #- 1519 | proc numberSubtract*(ob1, ob2: PyObjectPtr): PyObjectPtr{.cdecl, 1520 | importc: "PyNumber_Subtract", dynlib: dllname.} #- 1521 | proc numberXor*(ob1, ob2: PyObjectPtr): PyObjectPtr{.cdecl, 1522 | importc: "PyNumber_Xor", dynlib: dllname.} #- 1523 | proc osInitInterrupts*(){.cdecl, importc: "PyOS_InitInterrupts", 1524 | dynlib: dllname.} #- 1525 | proc osInterruptOccurred*(): int{.cdecl, importc: "PyOS_InterruptOccurred", 1526 | dynlib: dllname.} #- 1527 | proc objectCallObject*(ob, args: PyObjectPtr): PyObjectPtr{.cdecl, 1528 | importc: "PyObject_CallObject", dynlib: dllname.} #- 1529 | proc objectCompare*(ob1, ob2: PyObjectPtr): int{.cdecl, 1530 | importc: "PyObject_Compare", dynlib: dllname.} #- 1531 | proc objectGetAttr*(ob1, ob2: PyObjectPtr): PyObjectPtr{.cdecl, 1532 | importc: "PyObject_GetAttr", dynlib: dllname.} #+ 1533 | proc objectGetAttrString*(ob: PyObjectPtr, c: cstring): PyObjectPtr{.cdecl, 1534 | importc: "PyObject_GetAttrString", dynlib: dllname.} #- 1535 | proc objectGetItem*(ob, key: PyObjectPtr): PyObjectPtr{.cdecl, 1536 | importc: "PyObject_GetItem", dynlib: dllname.} #- 1537 | proc objectDelItem*(ob, key: PyObjectPtr): PyObjectPtr{.cdecl, 1538 | importc: "PyObject_DelItem", dynlib: dllname.} #- 1539 | proc objectHasAttrString*(ob: PyObjectPtr, key: cstring): int{.cdecl, 1540 | importc: "PyObject_HasAttrString", dynlib: dllname.} #- 1541 | proc objectHash*(ob: PyObjectPtr): int32{.cdecl, importc: "PyObject_Hash", 1542 | dynlib: dllname.} #- 1543 | proc objectIsTrue*(ob: PyObjectPtr): int{.cdecl, importc: "PyObject_IsTrue", 1544 | dynlib: dllname.} #- 1545 | proc objectLength*(ob: PyObjectPtr): int{.cdecl, importc: "PyObject_Length", 1546 | dynlib: dllname.} #- 1547 | proc objectRepr*(ob: PyObjectPtr): PyObjectPtr{.cdecl, 1548 | importc: "PyObject_Repr", dynlib: dllname.} #- 1549 | proc objectSetAttr*(ob1, ob2, ob3: PyObjectPtr): int{.cdecl, 1550 | importc: "PyObject_SetAttr", dynlib: dllname.} #- 1551 | proc objectSetAttrString*(ob: PyObjectPtr, key: cstring, 1552 | value: PyObjectPtr): int{.cdecl, 1553 | importc: "PyObject_SetAttrString", dynlib: dllname.} #- 1554 | proc objectSetItem*(ob1, ob2, ob3: PyObjectPtr): int{.cdecl, 1555 | importc: "PyObject_SetItem", dynlib: dllname.} #- 1556 | proc objectInit*(ob: PyObjectPtr, t: PyTypeObjectPtr): PyObjectPtr{.cdecl, 1557 | importc: "PyObject_Init", dynlib: dllname.} #- 1558 | proc objectInitVar*(ob: PyObjectPtr, t: PyTypeObjectPtr, 1559 | size: int): PyObjectPtr{.cdecl, importc: "PyObject_InitVar", 1560 | dynlib: dllname.} #- 1561 | proc objectNew*(t: PyTypeObjectPtr): PyObjectPtr{.cdecl, 1562 | importc: "PyObject_New", dynlib: dllname.} #- 1563 | proc objectNewVar*(t: PyTypeObjectPtr, size: int): PyObjectPtr{.cdecl, 1564 | importc: "PyObject_NewVar", dynlib: dllname.} 1565 | proc objectFree*(ob: PyObjectPtr){.cdecl, importc: "PyObject_Free", 1566 | dynlib: dllname.} #- 1567 | proc objectIsInstance*(inst, cls: PyObjectPtr): int{.cdecl, 1568 | importc: "PyObject_IsInstance", dynlib: dllname.} #- 1569 | proc objectIsSubclass*(derived, cls: PyObjectPtr): int{.cdecl, 1570 | importc: "PyObject_IsSubclass", dynlib: dllname.} 1571 | proc objectGenericGetAttr*(obj, name: PyObjectPtr): PyObjectPtr{.cdecl, 1572 | importc: "PyObject_GenericGetAttr", dynlib: dllname.} 1573 | proc objectGenericSetAttr*(obj, name, value: PyObjectPtr): int{.cdecl, 1574 | importc: "PyObject_GenericSetAttr", dynlib: dllname.} #- 1575 | proc objectGCMalloc*(size: int): PyObjectPtr{.cdecl, 1576 | importc: "PyObject_GC_Malloc", dynlib: dllname.} #- 1577 | proc objectGCNew*(t: PyTypeObjectPtr): PyObjectPtr{.cdecl, 1578 | importc: "PyObject_GC_New", dynlib: dllname.} #- 1579 | proc objectGCNewVar*(t: PyTypeObjectPtr, size: int): PyObjectPtr{.cdecl, 1580 | importc: "PyObject_GC_NewVar", dynlib: dllname.} #- 1581 | proc objectGCResize*(t: PyObjectPtr, newsize: int): PyObjectPtr{.cdecl, 1582 | importc: "PyObject_GC_Resize", dynlib: dllname.} #- 1583 | proc objectGCDel*(ob: PyObjectPtr){.cdecl, importc: "PyObject_GC_Del", 1584 | dynlib: dllname.} #- 1585 | proc objectGCTrack*(ob: PyObjectPtr){.cdecl, importc: "PyObject_GC_Track", 1586 | dynlib: dllname.} #- 1587 | proc objectGCUnTrack*(ob: PyObjectPtr){.cdecl, 1588 | importc: "PyObject_GC_UnTrack", dynlib: dllname.} #- 1589 | proc rangeNew*(l1, l2, l3: int32, i: int): PyObjectPtr{.cdecl, 1590 | importc: "PyRange_New", dynlib: dllname.} #- 1591 | proc sequenceCheck*(ob: PyObjectPtr): int{.cdecl, 1592 | importc: "PySequence_Check", dynlib: dllname.} #- 1593 | proc sequenceConcat*(ob1, ob2: PyObjectPtr): PyObjectPtr{.cdecl, 1594 | importc: "PySequence_Concat", dynlib: dllname.} #- 1595 | proc sequenceCount*(ob1, ob2: PyObjectPtr): int{.cdecl, 1596 | importc: "PySequence_Count", dynlib: dllname.} #- 1597 | proc sequenceGetItem*(ob: PyObjectPtr, i: int): PyObjectPtr{.cdecl, 1598 | importc: "PySequence_GetItem", dynlib: dllname.} #- 1599 | proc sequenceGetSlice*(ob: PyObjectPtr, i1, i2: int): PyObjectPtr{.cdecl, 1600 | importc: "PySequence_GetSlice", dynlib: dllname.} #- 1601 | proc sequenceIn*(ob1, ob2: PyObjectPtr): int{.cdecl, 1602 | importc: "PySequence_In", dynlib: dllname.} #- 1603 | proc sequenceIndex*(ob1, ob2: PyObjectPtr): int{.cdecl, 1604 | importc: "PySequence_Index", dynlib: dllname.} #- 1605 | proc sequenceLength*(ob: PyObjectPtr): int{.cdecl, 1606 | importc: "PySequence_Length", dynlib: dllname.} #- 1607 | proc sequenceRepeat*(ob: PyObjectPtr, count: int): PyObjectPtr{.cdecl, 1608 | importc: "PySequence_Repeat", dynlib: dllname.} #- 1609 | proc sequenceSetItem*(ob: PyObjectPtr, i: int, value: PyObjectPtr): int{.cdecl, 1610 | importc: "PySequence_SetItem", dynlib: dllname.} #- 1611 | proc sequenceSetSlice*(ob: PyObjectPtr, i1, i2: int, 1612 | value: PyObjectPtr): int{.cdecl, 1613 | importc: "PySequence_SetSlice", dynlib: dllname.} #- 1614 | proc sequenceDelSlice*(ob: PyObjectPtr, i1, i2: int): int{.cdecl, 1615 | importc: "PySequence_DelSlice", dynlib: dllname.} #- 1616 | proc sequenceTuple*(ob: PyObjectPtr): PyObjectPtr{.cdecl, 1617 | importc: "PySequence_Tuple", dynlib: dllname.} #- 1618 | proc sequenceContains*(ob, value: PyObjectPtr): int{.cdecl, 1619 | importc: "PySequence_Contains", dynlib: dllname.} #- 1620 | proc sliceGetIndices*(ob: PySliceObjectPtr, len: int, 1621 | start, stop, step: var int): int{.cdecl, 1622 | importc: "PySlice_GetIndices", dynlib: dllname.} #- 1623 | proc sliceGetIndicesEx*(ob: PySliceObjectPtr, len: int, 1624 | start, stop, step, slicelength: var int): int{.cdecl, 1625 | importc: "PySlice_GetIndicesEx", dynlib: dllname.} #- 1626 | proc sliceNew*(start, stop, step: PyObjectPtr): PyObjectPtr{.cdecl, 1627 | importc: "PySlice_New", dynlib: dllname.} #- 1628 | proc stringConcat*(ob1: var PyObjectPtr, ob2: PyObjectPtr){.cdecl, 1629 | importc: "PyString_Concat", dynlib: dllname.} #- 1630 | proc stringConcatAndDel*(ob1: var PyObjectPtr, ob2: PyObjectPtr){.cdecl, 1631 | importc: "PyString_ConcatAndDel", dynlib: dllname.} #- 1632 | proc stringFormat*(ob1, ob2: PyObjectPtr): PyObjectPtr{.cdecl, 1633 | importc: "PyString_Format", dynlib: dllname.} #- 1634 | proc stringFromStringAndSize*(s: cstring, i: int): PyObjectPtr{.cdecl, 1635 | importc: "PyString_FromStringAndSize", dynlib: dllname.} #- 1636 | proc stringSize*(ob: PyObjectPtr): int{.cdecl, importc: "PyString_Size", 1637 | dynlib: dllname.} #- 1638 | proc stringDecodeEscape*(s: cstring, length: int, errors: cstring, unicode: int, 1639 | recode_encoding: cstring): PyObjectPtr{.cdecl, 1640 | importc: "PyString_DecodeEscape", dynlib: dllname.} #- 1641 | proc stringRepr*(ob: PyObjectPtr, smartquotes: int): PyObjectPtr{.cdecl, 1642 | importc: "PyString_Repr", dynlib: dllname.} #+ 1643 | proc sysGetObject*(s: cstring): PyObjectPtr{.cdecl, 1644 | importc: "PySys_GetObject", dynlib: dllname.} #- 1645 | #- 1646 | #PySys_Init:procedure; cdecl, importc, dynlib: dllname; 1647 | #- 1648 | proc sysSetObject*(s: cstring, ob: PyObjectPtr): int{.cdecl, 1649 | importc: "PySys_SetObject", dynlib: dllname.} #- 1650 | proc sysSetPath*(path: cstring){.cdecl, importc: "PySys_SetPath", 1651 | dynlib: dllname.} #- 1652 | #PyTraceBack_Fetch:function:PyObjectPtr; cdecl, importc, dynlib: dllname; 1653 | #- 1654 | proc tracebackHere*(p: pointer): int{.cdecl, importc: "PyTraceBack_Here", 1655 | dynlib: dllname.} #- 1656 | proc tracebackPrint*(ob1, ob2: PyObjectPtr): int{.cdecl, 1657 | importc: "PyTraceBack_Print", dynlib: dllname.} #- 1658 | #PyTraceBack_Store:function (ob:PyObjectPtr):integer; cdecl, importc, dynlib: dllname; 1659 | #+ 1660 | proc tupleGetItem*(ob: PyObjectPtr, i: int): PyObjectPtr{.cdecl, 1661 | importc: "PyTuple_GetItem", dynlib: dllname.} #- 1662 | proc tupleGetSlice*(ob: PyObjectPtr, i1, i2: int): PyObjectPtr{.cdecl, 1663 | importc: "PyTuple_GetSlice", dynlib: dllname.} #+ 1664 | proc tupleNew*(size: int): PyObjectPtr{.cdecl, importc: "PyTuple_New", 1665 | dynlib: dllname.} #+ 1666 | proc tupleSetItem*(ob: PyObjectPtr, key: int, value: PyObjectPtr): int{.cdecl, 1667 | importc: "PyTuple_SetItem", dynlib: dllname.} #+ 1668 | proc tupleSize*(ob: PyObjectPtr): int{.cdecl, importc: "PyTuple_Size", 1669 | dynlib: dllname.} #+ 1670 | proc typeIsSubtype*(a, b: PyTypeObjectPtr): int{.cdecl, 1671 | importc: "PyType_IsSubtype", dynlib: dllname.} 1672 | proc typeGenericAlloc*(atype: PyTypeObjectPtr, nitems: int): PyObjectPtr{.cdecl, 1673 | importc: "PyType_GenericAlloc", dynlib: dllname.} 1674 | proc typeGenericNew*(atype: PyTypeObjectPtr, 1675 | args, kwds: PyObjectPtr): PyObjectPtr{.cdecl, 1676 | importc: "PyType_GenericNew", dynlib: dllname.} 1677 | proc typeReady*(atype: PyTypeObjectPtr): int{.cdecl, importc: "PyType_Ready", 1678 | dynlib: dllname.} #+ 1679 | proc unicodeFromWideChar*(w: pointer, size: int): PyObjectPtr{.cdecl, 1680 | importc: "PyUnicode_FromWideChar", dynlib: dllname.} #+ 1681 | proc unicodeAsWideChar*(unicode: PyObjectPtr, w: pointer, size: int): int{.cdecl, 1682 | importc: "PyUnicode_AsWideChar", dynlib: dllname.} #- 1683 | proc unicodeFromOrdinal*(ordinal: int): PyObjectPtr{.cdecl, 1684 | importc: "PyUnicode_FromOrdinal", dynlib: dllname.} 1685 | proc weakrefGetObject*(theRef: PyObjectPtr): PyObjectPtr{.cdecl, 1686 | importc: "PyWeakref_GetObject", dynlib: dllname.} 1687 | proc weakrefNewProxy*(ob, callback: PyObjectPtr): PyObjectPtr{.cdecl, 1688 | importc: "PyWeakref_NewProxy", dynlib: dllname.} 1689 | proc weakrefNewRef*(ob, callback: PyObjectPtr): PyObjectPtr{.cdecl, 1690 | importc: "PyWeakref_NewRef", dynlib: dllname.} 1691 | proc wrapperNew*(ob1, ob2: PyObjectPtr): PyObjectPtr{.cdecl, 1692 | importc: "PyWrapper_New", dynlib: dllname.} 1693 | proc boolFromLong*(ok: int): PyObjectPtr{.cdecl, importc: "PyBool_FromLong", 1694 | dynlib: dllname.} #- 1695 | proc atExit*(prc: proc () {.cdecl.}): int{.cdecl, importc: "Py_AtExit", 1696 | dynlib: dllname.} #- 1697 | #Py_Cleanup:procedure; cdecl, importc, dynlib: dllname; 1698 | #- 1699 | proc compileString*(s1, s2: cstring, i: int): PyObjectPtr{.cdecl, 1700 | importc: "Py_CompileString", dynlib: dllname.} #- 1701 | proc fatalError*(s: cstring){.cdecl, importc: "Py_FatalError", 1702 | dynlib: dllname.} #- 1703 | proc findMethod*(md: PyMethodDefPtr, ob: PyObjectPtr, 1704 | key: cstring): PyObjectPtr{.cdecl, importc: "Py_FindMethod", 1705 | dynlib: dllname.} #- 1706 | proc findMethodInChain*(mc: PyMethodChainPtr, ob: PyObjectPtr, 1707 | key: cstring): PyObjectPtr{.cdecl, 1708 | importc: "Py_FindMethodInChain", dynlib: dllname.} #- 1709 | proc flushLine*(){.cdecl, importc: "Py_FlushLine", 1710 | dynlib: dllname.} #+ 1711 | proc finalize*(){.cdecl, importc: "Py_Finalize", 1712 | dynlib: dllname.} #- 1713 | proc errExceptionMatches*(exc: PyObjectPtr): int{.cdecl, 1714 | importc: "PyErr_ExceptionMatches", dynlib: dllname.} #- 1715 | proc errGivenExceptionMatches*(raised_exc, exc: PyObjectPtr): int{.cdecl, 1716 | importc: "PyErr_GivenExceptionMatches", dynlib: dllname.} #- 1717 | proc evalEvalCode*(co: PyCodeObjectPtr, 1718 | globals, locals: PyObjectPtr): PyObjectPtr{.cdecl, 1719 | importc: "PyEval_EvalCode", dynlib: dllname.} #+ 1720 | proc getVersion*(): cstring{.cdecl, importc: "Py_GetVersion", 1721 | dynlib: dllname.} #+ 1722 | proc getCopyright*(): cstring{.cdecl, importc: "Py_GetCopyright", 1723 | dynlib: dllname.} #+ 1724 | proc getExecPrefix*(): cstring{.cdecl, importc: "Py_GetExecPrefix", 1725 | dynlib: dllname.} #+ 1726 | proc getPath*(): cstring{.cdecl, importc: "Py_GetPath", 1727 | dynlib: dllname.} #+ 1728 | proc getPrefix*(): cstring{.cdecl, importc: "Py_GetPrefix", 1729 | dynlib: dllname.} #+ 1730 | proc getProgramName*(): cstring{.cdecl, importc: "Py_GetProgramName", 1731 | dynlib: dllname.} #- 1732 | proc parserSimpleParseString*(str: cstring, start: int): NodePtr{.cdecl, 1733 | importc: "PyParser_SimpleParseString", dynlib: dllname.} #- 1734 | proc nodeFree*(n: NodePtr){.cdecl, importc: "PyNode_Free", 1735 | dynlib: dllname.} #- 1736 | proc errNewException*(name: cstring, base, dict: PyObjectPtr): PyObjectPtr{.cdecl, 1737 | importc: "PyErr_NewException", dynlib: dllname.} #- 1738 | proc malloc*(size: int): pointer {.cdecl, importc: "Py_Malloc", 1739 | dynlib: dllname.} 1740 | proc memMalloc*(size: int): pointer {.cdecl, importc: "PyMem_Malloc", 1741 | dynlib: dllname.} 1742 | proc objectCallMethod*(obj: PyObjectPtr, theMethod, 1743 | format: cstring): PyObjectPtr{.cdecl, 1744 | importc: "PyObject_CallMethod", dynlib: dllname.} 1745 | proc setProgramName*(name: cstring){.cdecl, importc: "Py_SetProgramName", 1746 | dynlib: dllname.} 1747 | proc isInitialized*(): int{.cdecl, importc: "Py_IsInitialized", 1748 | dynlib: dllname.} 1749 | proc getProgramFullPath*(): cstring{.cdecl, importc: "Py_GetProgramFullPath", 1750 | dynlib: dllname.} 1751 | proc newInterpreter*(): PyThreadStatePtr{.cdecl, 1752 | importc: "Py_NewInterpreter", dynlib: dllname.} 1753 | proc endInterpreter*(tstate: PyThreadStatePtr){.cdecl, 1754 | importc: "Py_EndInterpreter", dynlib: dllname.} 1755 | proc evalAcquireLock*(){.cdecl, importc: "PyEval_AcquireLock", 1756 | dynlib: dllname.} 1757 | proc evalReleaseLock*(){.cdecl, importc: "PyEval_ReleaseLock", 1758 | dynlib: dllname.} 1759 | proc evalAcquireThread*(tstate: PyThreadStatePtr){.cdecl, 1760 | importc: "PyEval_AcquireThread", dynlib: dllname.} 1761 | proc evalReleaseThread*(tstate: PyThreadStatePtr){.cdecl, 1762 | importc: "PyEval_ReleaseThread", dynlib: dllname.} 1763 | proc interpreterstateNew*(): PyInterpreterStatePtr{.cdecl, 1764 | importc: "PyInterpreterState_New", dynlib: dllname.} 1765 | proc interpreterstateClear*(interp: PyInterpreterStatePtr){.cdecl, 1766 | importc: "PyInterpreterState_Clear", dynlib: dllname.} 1767 | proc interpreterstateDelete*(interp: PyInterpreterStatePtr){.cdecl, 1768 | importc: "PyInterpreterState_Delete", dynlib: dllname.} 1769 | proc threadStateNew*(interp: PyInterpreterStatePtr): PyThreadStatePtr{.cdecl, 1770 | importc: "PyThreadState_New", dynlib: dllname.} 1771 | proc threadStateClear*(tstate: PyThreadStatePtr){.cdecl, 1772 | importc: "PyThreadState_Clear", dynlib: dllname.} 1773 | proc threadStateDelete*(tstate: PyThreadStatePtr){.cdecl, 1774 | importc: "PyThreadState_Delete", dynlib: dllname.} 1775 | proc threadStateGet*(): PyThreadStatePtr{.cdecl, 1776 | importc: "PyThreadState_Get", dynlib: dllname.} 1777 | proc threadStateSwap*(tstate: PyThreadStatePtr): PyThreadStatePtr{.cdecl, 1778 | importc: "PyThreadState_Swap", dynlib: dllname.} 1779 | {.deprecated: [PyComplex_FromCComplex: complexFromCComplex].} 1780 | {.deprecated: [PyComplex_FromDoubles: complexFromDoubles].} 1781 | {.deprecated: [PyComplex_RealAsDouble: complexRealAsDouble].} 1782 | {.deprecated: [PyComplex_ImagAsDouble: complexImagAsDouble].} 1783 | {.deprecated: [PyComplex_AsCComplex: complexAsCComplex].} 1784 | {.deprecated: [PyCFunction_GetFunction: cfunctionGetFunction].} 1785 | {.deprecated: [PyCFunction_GetSelf: cfunctionGetSelf].} 1786 | {.deprecated: [PyCallable_Check: callableCheck].} 1787 | {.deprecated: [PyCObject_FromVoidPtr: cobjectFromVoidPtr].} 1788 | {.deprecated: [PyCObject_AsVoidPtr: cobjectAsVoidPtr].} 1789 | {.deprecated: [PyClass_New: classNew].} 1790 | {.deprecated: [PyClass_IsSubclass: classIsSubclass].} 1791 | {.deprecated: [Py_InitModule4: initModule4].} 1792 | {.deprecated: [PyErr_BadArgument: errBadArgument].} 1793 | {.deprecated: [PyErr_BadInternalCall: errBadInternalCall].} 1794 | {.deprecated: [PyErr_CheckSignals: errCheckSignals].} 1795 | {.deprecated: [PyErr_Clear: errClear].} 1796 | {.deprecated: [PyErr_Fetch: errFetch].} 1797 | {.deprecated: [PyErr_NoMemory: errNoMemory].} 1798 | {.deprecated: [PyErr_Occurred: errOccurred].} 1799 | {.deprecated: [PyErr_Print: errPrint].} 1800 | {.deprecated: [PyErr_Restore: errRestore].} 1801 | {.deprecated: [PyErr_SetFromErrno: errSetFromErrno].} 1802 | {.deprecated: [PyErr_SetNone: errSetNone].} 1803 | {.deprecated: [PyErr_SetObject: errSetObject].} 1804 | {.deprecated: [PyErr_SetString: errSetString].} 1805 | {.deprecated: [PyImport_GetModuleDict: importGetModuleDict].} 1806 | {.deprecated: [PyInt_FromLong: intFromLong].} 1807 | {.deprecated: [Py_Initialize: initialize].} 1808 | {.deprecated: [Py_Exit: exit].} 1809 | {.deprecated: [PyEval_GetBuiltins: evalGetBuiltins].} 1810 | {.deprecated: [PyDict_GetItem: dictGetItem].} 1811 | {.deprecated: [PyDict_SetItem: dictSetItem].} 1812 | {.deprecated: [PyDict_DelItem: dictDelItem].} 1813 | {.deprecated: [PyDict_Clear: dictClear].} 1814 | {.deprecated: [PyDict_Next: dictNext].} 1815 | {.deprecated: [PyDict_Keys: dictKeys].} 1816 | {.deprecated: [PyDict_Values: dictValues].} 1817 | {.deprecated: [PyDict_Items: dictItems].} 1818 | {.deprecated: [PyDict_Size: dictSize].} 1819 | {.deprecated: [PyDict_DelItemString: dictDelItemString].} 1820 | {.deprecated: [PyDict_New: dictNew].} 1821 | {.deprecated: [PyDict_GetItemString: dictGetItemString].} 1822 | {.deprecated: [PyDict_SetItemString: dictSetItemString].} 1823 | {.deprecated: [PyDictProxy_New: dictproxyNew].} 1824 | {.deprecated: [PyModule_GetDict: moduleGetDict].} 1825 | {.deprecated: [PyObject_Str: objectStr].} 1826 | {.deprecated: [PyRun_String: runString].} 1827 | {.deprecated: [PyRun_SimpleString: runSimpleString].} 1828 | {.deprecated: [PyString_AsString: stringAsString].} 1829 | {.deprecated: [PyString_FromString: stringFromString].} 1830 | {.deprecated: [PySys_SetArgv: sysSetArgv].} 1831 | {.deprecated: [PyCFunction_New: cfunctionNew].} 1832 | {.deprecated: [PyEval_CallObject: evalCallObject].} 1833 | {.deprecated: [PyEval_CallObjectWithKeywords: evalCallObjectWithKeywords].} 1834 | {.deprecated: [PyEval_GetFrame: evalGetFrame].} 1835 | {.deprecated: [PyEval_GetGlobals: evalGetGlobals].} 1836 | {.deprecated: [PyEval_GetLocals: evalGetLocals].} 1837 | {.deprecated: [PyEval_GetOwner: evalGetOwner].} 1838 | {.deprecated: [PyEval_GetRestricted: evalGetRestricted].} 1839 | {.deprecated: [PyEval_InitThreads: evalInitThreads].} 1840 | {.deprecated: [PyEval_RestoreThread: evalRestoreThread].} 1841 | {.deprecated: [PyEval_SaveThread: evalSaveThread].} 1842 | {.deprecated: [PyFile_FromString: fileFromString].} 1843 | {.deprecated: [PyFile_GetLine: fileGetLine].} 1844 | {.deprecated: [PyFile_Name: fileName].} 1845 | {.deprecated: [PyFile_SetBufSize: fileSetBufSize].} 1846 | {.deprecated: [PyFile_SoftSpace: fileSoftSpace].} 1847 | {.deprecated: [PyFile_WriteObject: fileWriteObject].} 1848 | {.deprecated: [PyFile_WriteString: fileWriteString].} 1849 | {.deprecated: [PyFloat_AsDouble: floatAsDouble].} 1850 | {.deprecated: [PyFloat_FromDouble: floatFromDouble].} 1851 | {.deprecated: [PyFunction_GetCode: functionGetCode].} 1852 | {.deprecated: [PyFunction_GetGlobals: functionGetGlobals].} 1853 | {.deprecated: [PyFunction_New: functionNew].} 1854 | {.deprecated: [PyImport_AddModule: importAddModule].} 1855 | {.deprecated: [PyImport_Cleanup: importCleanup].} 1856 | {.deprecated: [PyImport_GetMagicNumber: importGetMagicNumber].} 1857 | {.deprecated: [PyImport_ImportFrozenModule: importImportFrozenModule].} 1858 | {.deprecated: [PyImport_ImportModule: importImportModule].} 1859 | {.deprecated: [PyImport_Import: importImport].} 1860 | {.deprecated: [PyImport_Init: importInit].} 1861 | {.deprecated: [PyImport_ReloadModule: importReloadModule].} 1862 | {.deprecated: [PyInstance_New: instanceNew].} 1863 | {.deprecated: [PyInt_AsLong: intAsLong].} 1864 | {.deprecated: [PyList_Append: listAppend].} 1865 | {.deprecated: [PyList_AsTuple: listAsTuple].} 1866 | {.deprecated: [PyList_GetItem: listGetItem].} 1867 | {.deprecated: [PyList_GetSlice: listGetSlice].} 1868 | {.deprecated: [PyList_Insert: listInsert].} 1869 | {.deprecated: [PyList_New: listNew].} 1870 | {.deprecated: [PyList_Reverse: listReverse].} 1871 | {.deprecated: [PyList_SetItem: listSetItem].} 1872 | {.deprecated: [PyList_SetSlice: listSetSlice].} 1873 | {.deprecated: [PyList_Size: listSize].} 1874 | {.deprecated: [PyList_Sort: listSort].} 1875 | {.deprecated: [PyLong_AsDouble: longAsDouble].} 1876 | {.deprecated: [PyLong_AsLong: longAsLong].} 1877 | {.deprecated: [PyLong_FromDouble: longFromDouble].} 1878 | {.deprecated: [PyLong_FromLong: longFromLong].} 1879 | {.deprecated: [PyLong_FromString: longFromString].} 1880 | {.deprecated: [PyLong_FromUnsignedLong: longFromUnsignedLong].} 1881 | {.deprecated: [PyLong_AsUnsignedLong: longAsUnsignedLong].} 1882 | {.deprecated: [PyLong_FromUnicode: longFromUnicode].} 1883 | {.deprecated: [PyLong_FromLongLong: longFromLongLong].} 1884 | {.deprecated: [PyLong_AsLongLong: longAsLongLong].} 1885 | {.deprecated: [PyMapping_Check: mappingCheck].} 1886 | {.deprecated: [PyMapping_GetItemString: mappingGetItemString].} 1887 | {.deprecated: [PyMapping_HasKey: mappingHasKey].} 1888 | {.deprecated: [PyMapping_HasKeyString: mappingHasKeyString].} 1889 | {.deprecated: [PyMapping_Length: mappingLength].} 1890 | {.deprecated: [PyMapping_SetItemString: mappingSetItemString].} 1891 | {.deprecated: [PyMethod_Class: methodClass].} 1892 | {.deprecated: [PyMethod_Function: methodFunction].} 1893 | {.deprecated: [PyMethod_New: methodNew].} 1894 | {.deprecated: [PyMethod_Self: methodSelf].} 1895 | {.deprecated: [PyModule_GetName: moduleGetName].} 1896 | {.deprecated: [PyModule_New: moduleNew].} 1897 | {.deprecated: [PyNumber_Absolute: numberAbsolute].} 1898 | {.deprecated: [PyNumber_Add: numberAdd].} 1899 | {.deprecated: [PyNumber_And: numberAnd].} 1900 | {.deprecated: [PyNumber_Check: numberCheck].} 1901 | {.deprecated: [PyNumber_Coerce: numberCoerce].} 1902 | {.deprecated: [PyNumber_Divide: numberDivide].} 1903 | {.deprecated: [PyNumber_FloorDivide: numberFloorDivide].} 1904 | {.deprecated: [PyNumber_TrueDivide: numberTrueDivide].} 1905 | {.deprecated: [PyNumber_Divmod: numberDivmod].} 1906 | {.deprecated: [PyNumber_Float: numberFloat].} 1907 | {.deprecated: [PyNumber_Int: numberInt].} 1908 | {.deprecated: [PyNumber_Invert: numberInvert].} 1909 | {.deprecated: [PyNumber_Long: numberLong].} 1910 | {.deprecated: [PyNumber_Lshift: numberLshift].} 1911 | {.deprecated: [PyNumber_Multiply: numberMultiply].} 1912 | {.deprecated: [PyNumber_Negative: numberNegative].} 1913 | {.deprecated: [PyNumber_Or: numberOr].} 1914 | {.deprecated: [PyNumber_Positive: numberPositive].} 1915 | {.deprecated: [PyNumber_Power: numberPower].} 1916 | {.deprecated: [PyNumber_Remainder: numberRemainder].} 1917 | {.deprecated: [PyNumber_Rshift: numberRshift].} 1918 | {.deprecated: [PyNumber_Subtract: numberSubtract].} 1919 | {.deprecated: [PyNumber_Xor: numberXor].} 1920 | {.deprecated: [PyOS_InitInterrupts: osInitInterrupts].} 1921 | {.deprecated: [PyOS_InterruptOccurred: osInterruptOccurred].} 1922 | {.deprecated: [PyObject_CallObject: objectCallObject].} 1923 | {.deprecated: [PyObject_Compare: objectCompare].} 1924 | {.deprecated: [PyObject_GetAttr: objectGetAttr].} 1925 | {.deprecated: [PyObject_GetAttrString: objectGetAttrString].} 1926 | {.deprecated: [PyObject_GetItem: objectGetItem].} 1927 | {.deprecated: [PyObject_DelItem: objectDelItem].} 1928 | {.deprecated: [PyObject_HasAttrString: objectHasAttrString].} 1929 | {.deprecated: [PyObject_Hash: objectHash].} 1930 | {.deprecated: [PyObject_IsTrue: objectIsTrue].} 1931 | {.deprecated: [PyObject_Length: objectLength].} 1932 | {.deprecated: [PyObject_Repr: objectRepr].} 1933 | {.deprecated: [PyObject_SetAttr: objectSetAttr].} 1934 | {.deprecated: [PyObject_SetAttrString: objectSetAttrString].} 1935 | {.deprecated: [PyObject_SetItem: objectSetItem].} 1936 | {.deprecated: [PyObject_Init: objectInit].} 1937 | {.deprecated: [PyObject_InitVar: objectInitVar].} 1938 | {.deprecated: [PyObject_New: objectNew].} 1939 | {.deprecated: [PyObject_NewVar: objectNewVar].} 1940 | {.deprecated: [PyObject_Free: objectFree].} 1941 | {.deprecated: [PyObject_IsInstance: objectIsInstance].} 1942 | {.deprecated: [PyObject_IsSubclass: objectIsSubclass].} 1943 | {.deprecated: [PyObject_GenericGetAttr: objectGenericGetAttr].} 1944 | {.deprecated: [PyObject_GenericSetAttr: objectGenericSetAttr].} 1945 | {.deprecated: [PyObject_GC_Malloc: objectGCMalloc].} 1946 | {.deprecated: [PyObject_GC_New: objectGCNew].} 1947 | {.deprecated: [PyObject_GC_NewVar: objectGCNewVar].} 1948 | {.deprecated: [PyObject_GC_Resize: objectGCResize].} 1949 | {.deprecated: [PyObject_GC_Del: objectGCDel].} 1950 | {.deprecated: [PyObject_GC_Track: objectGCTrack].} 1951 | {.deprecated: [PyObject_GC_UnTrack: objectGCUnTrack].} 1952 | {.deprecated: [PyRange_New: rangeNew].} 1953 | {.deprecated: [PySequence_Check: sequenceCheck].} 1954 | {.deprecated: [PySequence_Concat: sequenceConcat].} 1955 | {.deprecated: [PySequence_Count: sequenceCount].} 1956 | {.deprecated: [PySequence_GetItem: sequenceGetItem].} 1957 | {.deprecated: [PySequence_GetSlice: sequenceGetSlice].} 1958 | {.deprecated: [PySequence_In: sequenceIn].} 1959 | {.deprecated: [PySequence_Index: sequenceIndex].} 1960 | {.deprecated: [PySequence_Length: sequenceLength].} 1961 | {.deprecated: [PySequence_Repeat: sequenceRepeat].} 1962 | {.deprecated: [PySequence_SetItem: sequenceSetItem].} 1963 | {.deprecated: [PySequence_SetSlice: sequenceSetSlice].} 1964 | {.deprecated: [PySequence_DelSlice: sequenceDelSlice].} 1965 | {.deprecated: [PySequence_Tuple: sequenceTuple].} 1966 | {.deprecated: [PySequence_Contains: sequenceContains].} 1967 | {.deprecated: [PySlice_GetIndices: sliceGetIndices].} 1968 | {.deprecated: [PySlice_GetIndicesEx: sliceGetIndicesEx].} 1969 | {.deprecated: [PySlice_New: sliceNew].} 1970 | {.deprecated: [PyString_Concat: stringConcat].} 1971 | {.deprecated: [PyString_ConcatAndDel: stringConcatAndDel].} 1972 | {.deprecated: [PyString_Format: stringFormat].} 1973 | {.deprecated: [PyString_FromStringAndSize: stringFromStringAndSize].} 1974 | {.deprecated: [PyString_Size: stringSize].} 1975 | {.deprecated: [PyString_DecodeEscape: stringDecodeEscape].} 1976 | {.deprecated: [PyString_Repr: stringRepr].} 1977 | {.deprecated: [PySys_GetObject: sysGetObject].} 1978 | {.deprecated: [PySys_SetObject: sysSetObject].} 1979 | {.deprecated: [PySys_SetPath: sysSetPath].} 1980 | {.deprecated: [PyTraceBack_Here: tracebackHere].} 1981 | {.deprecated: [PyTraceBack_Print: tracebackPrint].} 1982 | {.deprecated: [PyTuple_GetItem: tupleGetItem].} 1983 | {.deprecated: [PyTuple_GetSlice: tupleGetSlice].} 1984 | {.deprecated: [PyTuple_New: tupleNew].} 1985 | {.deprecated: [PyTuple_SetItem: tupleSetItem].} 1986 | {.deprecated: [PyTuple_Size: tupleSize].} 1987 | {.deprecated: [PyType_IsSubtype: typeIsSubtype].} 1988 | {.deprecated: [PyType_GenericAlloc: typeGenericAlloc].} 1989 | {.deprecated: [PyType_GenericNew: typeGenericNew].} 1990 | {.deprecated: [PyType_Ready: typeReady].} 1991 | {.deprecated: [PyUnicode_FromWideChar: unicodeFromWideChar].} 1992 | {.deprecated: [PyUnicode_AsWideChar: unicodeAsWideChar].} 1993 | {.deprecated: [PyUnicode_FromOrdinal: unicodeFromOrdinal].} 1994 | {.deprecated: [PyWeakref_GetObject: weakrefGetObject].} 1995 | {.deprecated: [PyWeakref_NewProxy: weakrefNewProxy].} 1996 | {.deprecated: [PyWeakref_NewRef: weakrefNewRef].} 1997 | {.deprecated: [PyWrapper_New: wrapperNew].} 1998 | {.deprecated: [PyBool_FromLong: boolFromLong].} 1999 | {.deprecated: [Py_AtExit: atExit].} 2000 | {.deprecated: [Py_CompileString: compileString].} 2001 | {.deprecated: [Py_FatalError: fatalError].} 2002 | {.deprecated: [Py_FindMethod: findMethod].} 2003 | {.deprecated: [Py_FindMethodInChain: findMethodInChain].} 2004 | {.deprecated: [Py_FlushLine: flushLine].} 2005 | {.deprecated: [Py_Finalize: finalize].} 2006 | {.deprecated: [PyErr_ExceptionMatches: errExceptionMatches].} 2007 | {.deprecated: [PyErr_GivenExceptionMatches: errGivenExceptionMatches].} 2008 | {.deprecated: [PyEval_EvalCode: evalEvalCode].} 2009 | {.deprecated: [Py_GetVersion: getVersion].} 2010 | {.deprecated: [Py_GetCopyright: getCopyright].} 2011 | {.deprecated: [Py_GetExecPrefix: getExecPrefix].} 2012 | {.deprecated: [Py_GetPath: getPath].} 2013 | {.deprecated: [Py_GetPrefix: getPrefix].} 2014 | {.deprecated: [Py_GetProgramName: getProgramName].} 2015 | {.deprecated: [PyParser_SimpleParseString: parserSimpleParseString].} 2016 | {.deprecated: [PyNode_Free: nodeFree].} 2017 | {.deprecated: [PyErr_NewException: errNewException].} 2018 | {.deprecated: [Py_Malloc: malloc].} 2019 | {.deprecated: [PyMem_Malloc: memMalloc].} 2020 | {.deprecated: [PyObject_CallMethod: objectCallMethod].} 2021 | {.deprecated: [Py_SetProgramName: setProgramName].} 2022 | {.deprecated: [Py_IsInitialized: isInitialized].} 2023 | {.deprecated: [Py_GetProgramFullPath: getProgramFullPath].} 2024 | {.deprecated: [Py_NewInterpreter: newInterpreter].} 2025 | {.deprecated: [Py_EndInterpreter: endInterpreter].} 2026 | {.deprecated: [PyEval_AcquireLock: evalAcquireLock].} 2027 | {.deprecated: [PyEval_ReleaseLock: evalReleaseLock].} 2028 | {.deprecated: [PyEval_AcquireThread: evalAcquireThread].} 2029 | {.deprecated: [PyEval_ReleaseThread: evalReleaseThread].} 2030 | {.deprecated: [PyInterpreterState_New: interpreterstateNew].} 2031 | {.deprecated: [PyInterpreterState_Clear: interpreterstateClear].} 2032 | {.deprecated: [PyInterpreterState_Delete: interpreterstateDelete].} 2033 | {.deprecated: [PyThreadState_New: threadStateNew].} 2034 | {.deprecated: [PyThreadState_Clear: threadStateClear].} 2035 | {.deprecated: [PyThreadState_Delete: threadStateDelete].} 2036 | {.deprecated: [PyThreadState_Get: threadStateGet].} 2037 | {.deprecated: [PyThreadState_Swap: threadStateSwap].} 2038 | 2039 | # Run the interpreter independantly of the Nim application 2040 | proc main*(argc: int, argv: CstringPtr): int{.cdecl, importc: 2041 | "Py_Main", dynlib: dllname.} 2042 | {.deprecated: [Py_Main: main].} 2043 | # Execute a script from a file 2044 | proc runAnyFile*(filename: string): int = 2045 | result = runSimpleString(readFile(filename)) 2046 | 2047 | #Further exported Objects, may be implemented later 2048 | # 2049 | # PyCode_New: Pointer; 2050 | # PyErr_SetInterrupt: Pointer; 2051 | # PyFile_AsFile: Pointer; 2052 | # PyFile_FromFile: Pointer; 2053 | # PyFloat_AsString: Pointer; 2054 | # PyFrame_BlockPop: Pointer; 2055 | # PyFrame_BlockSetup: Pointer; 2056 | # PyFrame_ExtendStack: Pointer; 2057 | # PyFrame_FastToLocals: Pointer; 2058 | # PyFrame_LocalsToFast: Pointer; 2059 | # PyFrame_New: Pointer; 2060 | # PyGrammar_AddAccelerators: Pointer; 2061 | # PyGrammar_FindDFA: Pointer; 2062 | # PyGrammar_LabelRepr: Pointer; 2063 | # PyInstance_DoBinOp: Pointer; 2064 | # PyInt_GetMax: Pointer; 2065 | # PyMarshal_Init: Pointer; 2066 | # PyMarshal_ReadLongFromFile: Pointer; 2067 | # PyMarshal_ReadObjectFromFile: Pointer; 2068 | # PyMarshal_ReadObjectFromString: Pointer; 2069 | # PyMarshal_WriteLongToFile: Pointer; 2070 | # PyMarshal_WriteObjectToFile: Pointer; 2071 | # PyMember_Get: Pointer; 2072 | # PyMember_Set: Pointer; 2073 | # PyNode_AddChild: Pointer; 2074 | # PyNode_Compile: Pointer; 2075 | # PyNode_New: Pointer; 2076 | # PyOS_GetLastModificationTime: Pointer; 2077 | # PyOS_Readline: Pointer; 2078 | # PyOS_strtol: Pointer; 2079 | # PyOS_strtoul: Pointer; 2080 | # PyObject_CallFunction: Pointer; 2081 | # PyObject_CallMethod: Pointer; 2082 | # PyObject_Print: Pointer; 2083 | # PyParser_AddToken: Pointer; 2084 | # PyParser_Delete: Pointer; 2085 | # PyParser_New: Pointer; 2086 | # PyParser_ParseFile: Pointer; 2087 | # PyParser_ParseString: Pointer; 2088 | # PyParser_SimpleParseFile: Pointer; 2089 | # PyRun_File: Pointer; 2090 | # PyRun_InteractiveLoop: Pointer; 2091 | # PyRun_InteractiveOne: Pointer; 2092 | # PyRun_SimpleFile: Pointer; 2093 | # PySys_GetFile: Pointer; 2094 | # PyToken_OneChar: Pointer; 2095 | # PyToken_TwoChars: Pointer; 2096 | # PyTokenizer_Free: Pointer; 2097 | # PyTokenizer_FromFile: Pointer; 2098 | # PyTokenizer_FromString: Pointer; 2099 | # PyTokenizer_Get: Pointer; 2100 | # _PyObject_NewVar: Pointer; 2101 | # _PyParser_Grammar: Pointer; 2102 | # _PyParser_TokenNames: Pointer; 2103 | # _PyThread_Started: Pointer; 2104 | # _Py_c_diff: Pointer; 2105 | # _Py_c_neg: Pointer; 2106 | # _Py_c_pow: Pointer; 2107 | # _Py_c_prod: Pointer; 2108 | # _Py_c_quot: Pointer; 2109 | # _Py_c_sum: Pointer; 2110 | # 2111 | 2112 | # This function handles all cardinals, pointer types (with no adjustment of pointers!) 2113 | # (Extended) floats, which are handled as Python doubles and currencies, handled 2114 | # as (normalized) Python doubles. 2115 | proc importExecCodeModule*(name: string, codeobject: PyObjectPtr): PyObjectPtr 2116 | {.deprecated: [PyImport_ExecCodeModule: importExecCodeModule].} 2117 | proc stringCheck*(obj: PyObjectPtr): bool 2118 | {.deprecated: [PyString_Check: stringCheck].} 2119 | proc stringCheckExact*(obj: PyObjectPtr): bool 2120 | {.deprecated: [PyString_CheckExact: stringCheckExact].} 2121 | proc floatCheck*(obj: PyObjectPtr): bool 2122 | {.deprecated: [PyFloat_Check: floatCheck].} 2123 | proc floatCheckExact*(obj: PyObjectPtr): bool 2124 | {.deprecated: [PyFloat_CheckExact: floatCheckExact].} 2125 | proc intCheck*(obj: PyObjectPtr): bool 2126 | {.deprecated: [PyInt_Check: intCheck].} 2127 | proc intCheckExact*(obj: PyObjectPtr): bool 2128 | {.deprecated: [PyInt_CheckExact: intCheckExact].} 2129 | proc longCheck*(obj: PyObjectPtr): bool 2130 | {.deprecated: [PyLong_Check: longCheck].} 2131 | proc longCheckExact*(obj: PyObjectPtr): bool 2132 | {.deprecated: [PyLong_CheckExact: longCheckExact].} 2133 | proc tupleCheck*(obj: PyObjectPtr): bool 2134 | {.deprecated: [PyTuple_Check: tupleCheck].} 2135 | proc tupleCheckExact*(obj: PyObjectPtr): bool 2136 | {.deprecated: [PyTuple_CheckExact: tupleCheckExact].} 2137 | proc instanceCheck*(obj: PyObjectPtr): bool 2138 | {.deprecated: [PyInstance_Check: instanceCheck].} 2139 | proc classCheck*(obj: PyObjectPtr): bool 2140 | {.deprecated: [PyClass_Check: classCheck].} 2141 | proc methodCheck*(obj: PyObjectPtr): bool 2142 | {.deprecated: [PyMethod_Check: methodCheck].} 2143 | proc listCheck*(obj: PyObjectPtr): bool 2144 | {.deprecated: [PyList_Check: listCheck].} 2145 | proc listCheckExact*(obj: PyObjectPtr): bool 2146 | {.deprecated: [PyList_CheckExact: listCheckExact].} 2147 | proc dictCheck*(obj: PyObjectPtr): bool 2148 | {.deprecated: [PyDict_Check: dictCheck].} 2149 | proc dictCheckExact*(obj: PyObjectPtr): bool 2150 | {.deprecated: [PyDict_CheckExact: dictCheckExact].} 2151 | proc moduleCheck*(obj: PyObjectPtr): bool 2152 | {.deprecated: [PyModule_Check: moduleCheck].} 2153 | proc moduleCheckExact*(obj: PyObjectPtr): bool 2154 | {.deprecated: [PyModule_CheckExact: moduleCheckExact].} 2155 | proc sliceCheck*(obj: PyObjectPtr): bool 2156 | {.deprecated: [PySlice_Check: sliceCheck].} 2157 | proc functionCheck*(obj: PyObjectPtr): bool 2158 | {.deprecated: [PyFunction_Check: functionCheck].} 2159 | proc unicodeCheck*(obj: PyObjectPtr): bool 2160 | {.deprecated: [PyUnicode_Check: unicodeCheck].} 2161 | proc unicodeCheckExact*(obj: PyObjectPtr): bool 2162 | {.deprecated: [PyUnicode_CheckExact: unicodeCheckExact].} 2163 | proc typeISGC*(t: PyTypeObjectPtr): bool 2164 | {.deprecated: [PyType_IS_GC: typeISGC].} 2165 | proc objectISGC*(obj: PyObjectPtr): bool 2166 | {.deprecated: [PyObject_IS_GC: objectISGC].} 2167 | proc boolCheck*(obj: PyObjectPtr): bool 2168 | {.deprecated: [PyBool_Check: boolCheck].} 2169 | proc basestringCheck*(obj: PyObjectPtr): bool 2170 | {.deprecated: [PyBaseString_Check: basestringCheck].} 2171 | proc enumCheck*(obj: PyObjectPtr): bool 2172 | {.deprecated: [PyEnum_Check: enumCheck].} 2173 | proc objectTypeCheck*(obj: PyObjectPtr, t: PyTypeObjectPtr): bool 2174 | {.deprecated: [PyObject_TypeCheck: objectTypeCheck].} 2175 | proc initModule*(name: cstring, md: PyMethodDefPtr): PyObjectPtr 2176 | {.deprecated: [Py_InitModule: initModule].} 2177 | proc typeHasFeature*(AType: PyTypeObjectPtr, AFlag: int): bool 2178 | {.deprecated: [PyType_HasFeature: typeHasFeature].} 2179 | 2180 | # implementation 2181 | proc incref*(op: PyObjectPtr) {.inline.} = 2182 | inc(op.obRefcnt) 2183 | {.deprecated: [Py_INCREF: incref].} 2184 | 2185 | proc decref*(op: PyObjectPtr) {.inline.} = 2186 | dec(op.obRefcnt) 2187 | if op.obRefcnt == 0: 2188 | op.obType.tpDealloc(op) 2189 | {.deprecated: [Py_DECREF: decref].} 2190 | 2191 | proc xIncref*(op: PyObjectPtr) {.inline.} = 2192 | if op != nil: incref(op) 2193 | {.deprecated: [Py_XINCREF: xIncref].} 2194 | 2195 | proc xDecref*(op: PyObjectPtr) {.inline.} = 2196 | if op != nil: decref(op) 2197 | {.deprecated: [Py_XDECREF: xDecref].} 2198 | 2199 | proc importExecCodeModule(name: string, codeobject: PyObjectPtr): PyObjectPtr = 2200 | var m, d, v, modules: PyObjectPtr 2201 | m = importAddModule(cstring(name)) 2202 | if m == nil: 2203 | return nil 2204 | d = moduleGetDict(m) 2205 | if dictGetItemString(d, "__builtins__") == nil: 2206 | if dictSetItemString(d, "__builtins__", evalGetBuiltins()) != 0: 2207 | return nil 2208 | if dictSetItemString(d, "__file__", 2209 | PyCodeObjectPtr(codeobject).coFilename) != 0: 2210 | errClear() # Not important enough to report 2211 | v = evalEvalCode(PyCodeObjectPtr(codeobject), d, d) # XXX owner ? 2212 | if v == nil: 2213 | return nil 2214 | xDecref(v) 2215 | modules = importGetModuleDict() 2216 | if dictGetItemString(modules, cstring(name)) == nil: 2217 | errSetString(excImportError[] , cstring( 2218 | "Loaded module " & name & "not found in sys.modules")) 2219 | return nil 2220 | xIncref(m) 2221 | result = m 2222 | 2223 | proc stringCheck(obj: PyObjectPtr): bool = 2224 | result = objectTypeCheck(obj, stringType) 2225 | 2226 | proc stringCheckExact(obj: PyObjectPtr): bool = 2227 | result = (obj != nil) and (obj.obType == stringType) 2228 | 2229 | proc floatCheck(obj: PyObjectPtr): bool = 2230 | result = objectTypeCheck(obj, floatType) 2231 | 2232 | proc floatCheckExact(obj: PyObjectPtr): bool = 2233 | result = (obj != nil) and (obj.obType == floatType) 2234 | 2235 | proc intCheck(obj: PyObjectPtr): bool = 2236 | result = objectTypeCheck(obj, intType) 2237 | 2238 | proc intCheckExact(obj: PyObjectPtr): bool = 2239 | result = (obj != nil) and (obj.obType == intType) 2240 | 2241 | proc longCheck(obj: PyObjectPtr): bool = 2242 | result = objectTypeCheck(obj, longType) 2243 | 2244 | proc longCheckExact(obj: PyObjectPtr): bool = 2245 | result = (obj != nil) and (obj.obType == longType) 2246 | 2247 | proc tupleCheck(obj: PyObjectPtr): bool = 2248 | result = objectTypeCheck(obj, tupleType) 2249 | 2250 | proc tupleCheckExact(obj: PyObjectPtr): bool = 2251 | result = (obj != nil) and (obj[].obType == tupleType) 2252 | 2253 | proc instanceCheck(obj: PyObjectPtr): bool = 2254 | result = (obj != nil) and (obj[].obType == instanceType) 2255 | 2256 | proc classCheck(obj: PyObjectPtr): bool = 2257 | result = (obj != nil) and (obj[].obType == classType) 2258 | 2259 | proc methodCheck(obj: PyObjectPtr): bool = 2260 | result = (obj != nil) and (obj[].obType == methodType) 2261 | 2262 | proc listCheck(obj: PyObjectPtr): bool = 2263 | result = objectTypeCheck(obj, listType) 2264 | 2265 | proc listCheckExact(obj: PyObjectPtr): bool = 2266 | result = (obj != nil) and (obj[].obType == listType) 2267 | 2268 | proc dictCheck(obj: PyObjectPtr): bool = 2269 | result = objectTypeCheck(obj, dictType) 2270 | 2271 | proc dictCheckExact(obj: PyObjectPtr): bool = 2272 | result = (obj != nil) and (obj[].obType == dictType) 2273 | 2274 | proc moduleCheck(obj: PyObjectPtr): bool = 2275 | result = objectTypeCheck(obj, moduleType) 2276 | 2277 | proc moduleCheckExact(obj: PyObjectPtr): bool = 2278 | result = (obj != nil) and (obj[].obType == moduleType) 2279 | 2280 | proc sliceCheck(obj: PyObjectPtr): bool = 2281 | result = (obj != nil) and (obj[].obType == sliceType) 2282 | 2283 | proc functionCheck(obj: PyObjectPtr): bool = 2284 | result = (obj != nil) and 2285 | ((obj.obType == cfunctionType) or 2286 | (obj.obType == functionType)) 2287 | 2288 | proc unicodeCheck(obj: PyObjectPtr): bool = 2289 | result = objectTypeCheck(obj, unicodeType) 2290 | 2291 | proc unicodeCheckExact(obj: PyObjectPtr): bool = 2292 | result = (obj != nil) and (obj.obType == unicodeType) 2293 | 2294 | proc typeISGC(t: PyTypeObjectPtr): bool = 2295 | result = typeHasFeature(t, tpflagsHaveGc) 2296 | 2297 | proc objectISGC(obj: PyObjectPtr): bool = 2298 | result = typeISGC(obj.obType) and 2299 | ((obj.obType.tpIsGc == nil) or (obj.obType.tpIsGc(obj) == 1)) 2300 | 2301 | proc boolCheck(obj: PyObjectPtr): bool = 2302 | result = (obj != nil) and (obj.obType == boolType) 2303 | 2304 | proc basestringCheck(obj: PyObjectPtr): bool = 2305 | result = objectTypeCheck(obj, basestringType) 2306 | 2307 | proc enumCheck(obj: PyObjectPtr): bool = 2308 | result = (obj != nil) and (obj.obType == enumType) 2309 | 2310 | proc objectTypeCheck(obj: PyObjectPtr, t: PyTypeObjectPtr): bool = 2311 | result = (obj != nil) and (obj.obType == t) 2312 | if not result and (obj != nil) and (t != nil): 2313 | result = typeIsSubtype(obj.obType, t) == 1 2314 | 2315 | proc initModule(name: cstring, md: PyMethodDefPtr): PyObjectPtr = 2316 | result = initModule4(name, md, nil, nil, 1012) 2317 | 2318 | proc typeHasFeature(AType: PyTypeObjectPtr, AFlag: int): bool = 2319 | #(((t)->tp_flags & (f)) != 0) 2320 | result = (AType.tpFlags and AFlag) != 0 2321 | 2322 | proc init(lib: LibHandle) = 2323 | debugFlag = cast[IntPtr](symAddr(lib, "Py_DebugFlag")) 2324 | verboseFlag = cast[IntPtr](symAddr(lib, "Py_VerboseFlag")) 2325 | interactiveFlag = cast[IntPtr](symAddr(lib, "Py_InteractiveFlag")) 2326 | optimizeFlag = cast[IntPtr](symAddr(lib, "Py_OptimizeFlag")) 2327 | noSiteFlag = cast[IntPtr](symAddr(lib, "Py_NoSiteFlag")) 2328 | useClassExceptionsFlag = cast[IntPtr]( 2329 | symAddr(lib, "Py_UseClassExceptionsFlag") 2330 | ) 2331 | frozenFlag = cast[IntPtr](symAddr(lib, "Py_FrozenFlag")) 2332 | tabcheckFlag = cast[IntPtr](symAddr(lib, "Py_TabcheckFlag")) 2333 | unicodeFlag = cast[IntPtr](symAddr(lib, "Py_UnicodeFlag")) 2334 | ignoreEnvironmentFlag = cast[IntPtr]( 2335 | symAddr(lib, "Py_IgnoreEnvironmentFlag") 2336 | ) 2337 | divisionWarningFlag = cast[IntPtr](symAddr(lib, "Py_DivisionWarningFlag")) 2338 | noneVar = cast[PyObjectPtr](symAddr(lib, "_Py_NoneStruct")) 2339 | ellipsis = cast[PyObjectPtr](symAddr(lib, "_Py_EllipsisObject")) 2340 | falseVar = cast[PyIntObjectPtr](symAddr(lib, "_Py_ZeroStruct")) 2341 | trueVar = cast[PyIntObjectPtr](symAddr(lib, "_Py_TrueStruct")) 2342 | notImplemented = cast[PyObjectPtr](symAddr(lib, "_Py_NotImplementedStruct")) 2343 | importFrozenModules = cast[FrozenPtrPtr]( 2344 | symAddr(lib, "PyImport_FrozenModules") 2345 | ) 2346 | excAttributeError = cast[PyObjectPtrPtr]( 2347 | symAddr(lib, "PyExc_AttributeError") 2348 | ) 2349 | excEOFError = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_EOFError")) 2350 | excIOError = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_IOError")) 2351 | excImportError = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_ImportError")) 2352 | excIndexError = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_IndexError")) 2353 | excKeyError = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_KeyError")) 2354 | excKeyboardInterrupt = cast[PyObjectPtrPtr]( 2355 | symAddr(lib, "PyExc_KeyboardInterrupt") 2356 | ) 2357 | excMemoryError = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_MemoryError")) 2358 | excNameError = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_NameError")) 2359 | excOverflowError = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_OverflowError")) 2360 | excRuntimeError = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_RuntimeError")) 2361 | excSyntaxError = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_SyntaxError")) 2362 | excSystemError = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_SystemError")) 2363 | excSystemExit = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_SystemExit")) 2364 | excTypeError = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_TypeError")) 2365 | excValueError = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_ValueError")) 2366 | excZeroDivisionError = cast[PyObjectPtrPtr]( 2367 | symAddr(lib, "PyExc_ZeroDivisionError") 2368 | ) 2369 | excArithmeticError = cast[PyObjectPtrPtr]( 2370 | symAddr(lib, "PyExc_ArithmeticError") 2371 | ) 2372 | excException = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_Exception")) 2373 | excFloatingPointError = cast[PyObjectPtrPtr]( 2374 | symAddr(lib, "PyExc_FloatingPointError") 2375 | ) 2376 | excLookupError = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_LookupError")) 2377 | excStandardError = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_StandardError")) 2378 | excAssertionError = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_AssertionError")) 2379 | excEnvironmentError = cast[PyObjectPtrPtr]( 2380 | symAddr(lib, "PyExc_EnvironmentError") 2381 | ) 2382 | excIndentationError = cast[PyObjectPtrPtr]( 2383 | symAddr(lib, "PyExc_IndentationError") 2384 | ) 2385 | excMemoryErrorInst = cast[PyObjectPtrPtr]( 2386 | symAddr(lib, "PyExc_MemoryErrorInst") 2387 | ) 2388 | excNotImplementedError = cast[PyObjectPtrPtr]( 2389 | symAddr(lib, "PyExc_NotImplementedError") 2390 | ) 2391 | excOSError = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_OSError")) 2392 | excTabError = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_TabError")) 2393 | excUnboundLocalError = cast[PyObjectPtrPtr]( 2394 | symAddr(lib, "PyExc_UnboundLocalError") 2395 | ) 2396 | excUnicodeError = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_UnicodeError")) 2397 | excWarning = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_Warning")) 2398 | excDeprecationWarning = cast[PyObjectPtrPtr]( 2399 | symAddr(lib, "PyExc_DeprecationWarning") 2400 | ) 2401 | excRuntimeWarning = cast[PyObjectPtrPtr]( 2402 | symAddr(lib, "PyExc_RuntimeWarning") 2403 | ) 2404 | excSyntaxWarning = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_SyntaxWarning")) 2405 | excUserWarning = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_UserWarning")) 2406 | excOverflowWarning = cast[PyObjectPtrPtr]( 2407 | symAddr(lib, "PyExc_OverflowWarning") 2408 | ) 2409 | excReferenceError = cast[PyObjectPtrPtr]( 2410 | symAddr(lib, "PyExc_ReferenceError") 2411 | ) 2412 | excStopIteration = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_StopIteration")) 2413 | excFutureWarning = cast[PyObjectPtrPtr](symAddr(lib, "PyExc_FutureWarning")) 2414 | excPendingDeprecationWarning = cast[PyObjectPtrPtr]( 2415 | symAddr(lib, "PyExc_PendingDeprecationWarning") 2416 | ) 2417 | excUnicodeDecodeError = cast[PyObjectPtrPtr]( 2418 | symAddr(lib, "PyExc_UnicodeDecodeError") 2419 | ) 2420 | excUnicodeEncodeError = cast[PyObjectPtrPtr]( 2421 | symAddr(lib, "PyExc_UnicodeEncodeError") 2422 | ) 2423 | excUnicodeTranslateError = cast[PyObjectPtrPtr]( 2424 | symAddr(lib, "PyExc_UnicodeTranslateError") 2425 | ) 2426 | typeType = cast[PyTypeObjectPtr](symAddr(lib, "PyType_Type")) 2427 | cfunctionType = cast[PyTypeObjectPtr](symAddr(lib, "PyCFunction_Type")) 2428 | cobjectType = cast[PyTypeObjectPtr](symAddr(lib, "PyCObject_Type")) 2429 | classType = cast[PyTypeObjectPtr](symAddr(lib, "PyClass_Type")) 2430 | codeType = cast[PyTypeObjectPtr](symAddr(lib, "PyCode_Type")) 2431 | complexType = cast[PyTypeObjectPtr](symAddr(lib, "PyComplex_Type")) 2432 | dictType = cast[PyTypeObjectPtr](symAddr(lib, "PyDict_Type")) 2433 | fileType = cast[PyTypeObjectPtr](symAddr(lib, "PyFile_Type")) 2434 | floatType = cast[PyTypeObjectPtr](symAddr(lib, "PyFloat_Type")) 2435 | frameType = cast[PyTypeObjectPtr](symAddr(lib, "PyFrame_Type")) 2436 | functionType = cast[PyTypeObjectPtr](symAddr(lib, "PyFunction_Type")) 2437 | instanceType = cast[PyTypeObjectPtr](symAddr(lib, "PyInstance_Type")) 2438 | intType = cast[PyTypeObjectPtr](symAddr(lib, "PyInt_Type")) 2439 | listType = cast[PyTypeObjectPtr](symAddr(lib, "PyList_Type")) 2440 | longType = cast[PyTypeObjectPtr](symAddr(lib, "PyLong_Type")) 2441 | methodType = cast[PyTypeObjectPtr](symAddr(lib, "PyMethod_Type")) 2442 | moduleType = cast[PyTypeObjectPtr](symAddr(lib, "PyModule_Type")) 2443 | objectType = cast[PyTypeObjectPtr](symAddr(lib, "PyObject_Type")) 2444 | rangeType = cast[PyTypeObjectPtr](symAddr(lib, "PyRange_Type")) 2445 | sliceType = cast[PyTypeObjectPtr](symAddr(lib, "PySlice_Type")) 2446 | stringType = cast[PyTypeObjectPtr](symAddr(lib, "PyString_Type")) 2447 | tupleType = cast[PyTypeObjectPtr](symAddr(lib, "PyTuple_Type")) 2448 | unicodeType = cast[PyTypeObjectPtr](symAddr(lib, "PyUnicode_Type")) 2449 | baseobjectType = cast[PyTypeObjectPtr](symAddr(lib, "PyBaseObject_Type")) 2450 | bufferType = cast[PyTypeObjectPtr](symAddr(lib, "PyBuffer_Type")) 2451 | calliterType = cast[PyTypeObjectPtr](symAddr(lib, "PyCallIter_Type")) 2452 | cellType = cast[PyTypeObjectPtr](symAddr(lib, "PyCell_Type")) 2453 | classmethodType = cast[PyTypeObjectPtr](symAddr(lib, "PyClassMethod_Type")) 2454 | propertyType = cast[PyTypeObjectPtr](symAddr(lib, "PyProperty_Type")) 2455 | seqiterType = cast[PyTypeObjectPtr](symAddr(lib, "PySeqIter_Type")) 2456 | staticmethodType = cast[PyTypeObjectPtr]( 2457 | symAddr(lib, "PyStaticMethod_Type") 2458 | ) 2459 | superType = cast[PyTypeObjectPtr](symAddr(lib, "PySuper_Type")) 2460 | symtableentryType = cast[PyTypeObjectPtr]( 2461 | symAddr(lib, "PySymtableEntry_Type") 2462 | ) 2463 | tracebackType = cast[PyTypeObjectPtr](symAddr(lib, "PyTraceBack_Type")) 2464 | wrapperdescrType = cast[PyTypeObjectPtr]( 2465 | symAddr(lib, "PyWrapperDescr_Type") 2466 | ) 2467 | basestringType = cast[PyTypeObjectPtr](symAddr(lib, "PyBaseString_Type")) 2468 | boolType = cast[PyTypeObjectPtr](symAddr(lib, "PyBool_Type")) 2469 | enumType = cast[PyTypeObjectPtr](symAddr(lib, "PyEnum_Type")) 2470 | 2471 | 2472 | # Unfortunately we have to duplicate the loading mechanism here, because Nimrod 2473 | # used to not support variables from dynamic libraries. Well designed API's 2474 | # don't require this anyway. Python is an exception. 2475 | 2476 | var 2477 | lib: LibHandle 2478 | 2479 | when defined(windows): 2480 | const 2481 | LibNames = ["python27.dll", "python26.dll", "python25.dll", 2482 | "python24.dll", "python23.dll", "python22.dll", "python21.dll", 2483 | "python20.dll", "python16.dll", "python15.dll"] 2484 | elif defined(macosx): 2485 | const 2486 | LibNames = ["libpython2.7.dylib", "libpython2.6.dylib", 2487 | "libpython2.5.dylib", "libpython2.4.dylib", "libpython2.3.dylib", 2488 | "libpython2.2.dylib", "libpython2.1.dylib", "libpython2.0.dylib", 2489 | "libpython1.6.dylib", "libpython1.5.dylib"] 2490 | else: 2491 | const 2492 | LibNames = [ 2493 | "libpython2.7.so" & dllver, 2494 | "libpython2.6.so" & dllver, 2495 | "libpython2.5.so" & dllver, 2496 | "libpython2.4.so" & dllver, 2497 | "libpython2.3.so" & dllver, 2498 | "libpython2.2.so" & dllver, 2499 | "libpython2.1.so" & dllver, 2500 | "libpython2.0.so" & dllver, 2501 | "libpython1.6.so" & dllver, 2502 | "libpython1.5.so" & dllver] 2503 | 2504 | for libName in items(LibNames): 2505 | lib = loadLib(libName, global_symbols=true) 2506 | if lib != nil: 2507 | # echo "Loaded dynamic library: '$1'" % libName 2508 | break 2509 | 2510 | if lib == nil: 2511 | quit("could not load python library") 2512 | init(lib) 2513 | 2514 | 2515 | --------------------------------------------------------------------------------