Objects/pyobjectBase

Search:
Group by:
Source   Edit  

Types

BinaryMethod = proc (self, other: PyObject): PyObject {.pyCFuncPragma.}
Source   Edit  
BltinFunc = proc (args: openArray[PyObject]; kwargs: PyKwArgType): PyObject {.
    pyCFuncPragma.}
Source   Edit  
BltinMethod = proc (self: PyObject; args: openArray[PyObject];
                    kwargs: PyKwArgType): PyObject {.pyCFuncPragma.}
Source   Edit  
BltinMethodDef = tuple[meth: BltinMethod, classmethod: bool]
unstable Source   Edit  
destructor = proc (arg: var PyObjectObj) {.pyDestructorPragma.}
Source   Edit  
MagicMethods = tuple[add: BinaryMethod, sub: BinaryMethod, mul: BinaryMethod,
                     trueDiv: BinaryMethod, floorDiv: BinaryMethod,
                     Mod: BinaryMethod, divmod: BinaryMethod, pow: BinaryMethod,
                     matmul: BinaryMethod, iadd, isub, imul, itrueDiv,
    ifloorDiv, iMod, ipow, iAnd, iXor, iOr, iLshift, iRshift, iMatmul: BinaryMethod,
                     Not: UnaryMethod, negative: UnaryMethod,
                     positive: UnaryMethod, abs: UnaryMethod,
                     index: UnaryMethod, bool: UnaryMethod, int: UnaryMethod,
                     float: UnaryMethod, And: BinaryMethod, Xor: BinaryMethod,
                     Or: BinaryMethod, invert: UnaryMethod,
                     lshift: BinaryMethod, rshift: BinaryMethod,
                     lt: BinaryMethod, le: BinaryMethod, eq: BinaryMethod,
                     ne: BinaryMethod, gt: BinaryMethod, ge: BinaryMethod,
                     contains: BinaryMethod, len: UnaryMethod, str: UnaryMethod,
                     bytes: UnaryMethod, repr: UnaryMethod, New: BltinFunc,
                     init: BltinMethod, del: UnaryMethod, ## XXX: tp_del is deprecated over tp_finalize,
                                                           ## but NPython uses `del` to mean tp_finalize
                                                           ## (has to use the non-dunder name to ensure `magicNames` is correct)
                                                           ## 
                     getattr: BinaryMethod, setattr: TernaryMethod,
                     delattr: BinaryMethod, hash: UnaryMethod,
                     call: BltinMethod, getitem: BinaryMethod,
                     setitem: TernaryMethod, delitem: BinaryMethod,
                     get: BinaryMethod, set: TernaryMethod, iter: UnaryMethod,
                     iternext: UnaryMethod, reversed: UnaryMethod,
                     buffer: BinaryMethod, release_buffer: BinaryMethod,
                     await, aiter, anext: UnaryMethod]
Source   Edit  
PyKwArgType = PyObject
kw is of PyDictObject Source   Edit  
PyObject = ref object of RootObj
Source   Edit  
PyObjectObj = object
  when defined(js):
  pyType*: PyTypeObject
unstable Source   Edit  
PyObjectWithDict = ref object of PyObject
  dict*: PyObject
Source   Edit  
PyTypeObject = ref object of PyObjectWithDict
  name*: string
  base*: PyTypeObject
  kind*: PyTypeToken
  members*: RtArray[PyMemberDef]
  magicMethods*: MagicMethods
  bltinMethods*: Table[string, BltinMethodDef]
  getsetDescr*: Table[string, (UnaryMethod, BinaryMethod)]
  tp_dealloc*: destructor
  tp_alloc*: proc (self: PyTypeObject; nitems: int): PyObject {.pyCFuncPragma.} ## XXX: currently must not return exception
  tp_basicsize*: int         ## NPython won't use var-length struct, so no tp_itemsize needed.
Source   Edit  
PyTypeToken {.pure.} = enum
  NULL, Object, None, Ellipsis, BaseException, Int, Float, Bool, Type, Tuple,
  List, Dict, Bytes, Str, Code, NimFunc, Function, BoundMethod, Slice, Cell,
  Set, FrozenSet
Source   Edit  
TernaryMethod = proc (self, arg1, arg2: PyObject): PyObject {.pyCFuncPragma.}
Source   Edit  
UnaryMethod = proc (self: PyObject): PyObject {.pyCFuncPragma.}
Source   Edit  

Lets

pyObjectType = newPyTypePrivate("object")
Source   Edit  

Consts

magicNames = ["__add__", "__sub__", "__mul__", "__truediv__", "__floordiv__",
              "__mod__", "__divmod__", "__pow__", "__matmul__", "__iadd__",
              "__isub__", "__imul__", "__itruediv__", "__ifloordiv__",
              "__imod__", "__ipow__", "__iand__", "__ixor__", "__ior__",
              "__ilshift__", "__irshift__", "__imatmul__", "__not__",
              "__negative__", "__positive__", "__abs__", "__index__",
              "__bool__", "__int__", "__float__", "__and__", "__xor__",
              "__or__", "__invert__", "__lshift__", "__rshift__", "__lt__",
              "__le__", "__eq__", "__ne__", "__gt__", "__ge__", "__contains__",
              "__len__", "__str__", "__bytes__", "__repr__", "__new__",
              "__init__", "__del__", "__getattr__", "__setattr__",
              "__delattr__", "__hash__", "__call__", "__getitem__",
              "__setitem__", "__delitem__", "__get__", "__set__", "__iter__",
              "__iternext__", "__reversed__", "__buffer__",
              "__release_buffer__", "__await__", "__aiter__", "__anext__"]
Source   Edit  

Procs

proc callTpDel[Py: PyObject](tp: PyTypeObject; obj: var PyObjectObj): PyObject
inner Source   Edit  
proc getDict(obj: PyObject): PyObject {.cdecl, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc getDictUnsafe(obj: PyObject): PyObject {.cdecl, ...raises: [], tags: [],
    forbids: [].}
assuming obj.hasDict Source   Edit  
proc hasDict(obj: PyObject): bool {.inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc id(obj: PyObject): int {.inline, cdecl, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc idStr(obj: PyObject): string {.inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc initPyMemberDef[T](name: string; type: typedesc[T]; offset: int;
                        flags = default PyMemberDefFlags; doc = cstring nil): PyMemberDef
Source   Edit  
proc isClass(obj: PyObject): bool {.cdecl, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc isType(a, b: PyTypeObject): bool {.cdecl, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc newPyType[T: PyObject](name: string; base = pyObjectType): PyTypeObject
Source   Edit  
proc ofPyTypeObject(obj: PyObject): bool {.cdecl, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc Py_IS(a, b: PyObject): bool {.cdecl, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc Py_IS_TYPE(a: PyObject; b: PyTypeObject): bool {.cdecl, ...raises: [],
    tags: [], forbids: [].}
Source   Edit  

Methods

method `$`(obj: PyObject): string {.base, cdecl, ...raises: [], tags: [RootEffect],
                                    forbids: [].}
Source   Edit  

Iterators

iterator iterMro(tp: PyTypeObject): PyTypeObject {....raises: [], tags: [],
    forbids: [].}
Source   Edit  

Converters

converter toObjSeq[Py: PyObject](s: seq[Py]): seq[PyObject] {.inline.}
allow auto upcast Source   Edit  

Macros

macro pyCFuncPragma(def): untyped
equiv for {.pragma: pyCFuncPragma, cdecl, raises: [].} but is exported Source   Edit  
macro typeToAnyKind[T](t: typedesc[T]): AnyKind
Source   Edit  

Templates

template callOnceFinalizerFromDealloc(self: var PyObjectObj; callBody)
Source   Edit  
template forMro(baseVar; tp: PyTypeObject; body)
Source   Edit  
template forMroNoSelf(baseVar; tp: PyTypeObject; body)
Source   Edit  
template mro(self: PyTypeObject): untyped
returns PyTupleObject, not declared yet Source   Edit  
template pyDestructorPragma(def): untyped
Source   Edit  
template pyType(self: PyObject): PyTypeObject
Source   Edit  
template tp_free(self: PyTypeObject; op: var PyObjectObj)
current no need Source   Edit  
template typeName(o: PyObject): string
Source   Edit  
template typeToAnyKind[Py: PyObject](t: typedesc[seq[Py]]): AnyKind
Source   Edit  
template typeToAnyKind[T: PyObject](t: typedesc[T]): AnyKind
Source   Edit