Commits

ariovistus committed 6bc121e

Py_XINCREF caused linker to require ModuleInfos.
now it don't.

  • Participants
  • Parent commits ba2a69c

Comments (0)

Files changed (4)

examples/pyind/makefile

 	     -version=Python_2_5_Or_Later \
 	     -version=Python_2_4_Or_Later \
 	     -L-lpython2.7
-DC = dmd -m64 -unittest -property -debug 
+DC = dmd -m64 -unittest -property -debug  
 #DC = ldmd2 -unittest -property -debug -gc
 all: pyind
 clean:

examples/pyind/pyind.d

     )();
 }
 
-import deimos.python.datetime;
-__gshared PyDateTime_CAPI* gim;
-
 void main() {
-    gim = PyDateTime_IMPORT();
+    import deimos.python.object;
+    Py_XINCREF(Py_None());
     // simple expressions can be evaluated
     int i = py_eval!int("1+2", "office");
     writeln(i);

infrastructure/deimos/python/object.d

 }
 
 auto Py_INCREF(T)(T op) 
-if(is(T == PyObject*) || is(T == PyObject_BorrowedRef*))
+if(is(T == PyObject*) || is(T _unused : Borrowed!P*, P))
 {
-    static if(is(T == PyObject_BorrowedRef*)) {
+    static if(is(T _unused : Borrowed!P*, P)) {
         PyObject* pop = cast(PyObject*) op;
         ++pop.ob_refcnt;
-        return pop;
+        return cast(P*) pop;
     }else {
         ++op.ob_refcnt;
     }
 
 auto Py_XINCREF(T)(T op) {
     if (op == null) {
-        static if(is(typeof(return) == void))
+        //static if(is(typeof(return) == void))
+        static if(is(typeof(Py_INCREF!T(op)) == void))
             return;
         else {
-            import std.exception;
-            enforce(0, "INCREF on null");
+            assert(0, "INCREF on null");
         }
     }
     return Py_INCREF(op);
 void Py_IncRef(PyObject *);
 void Py_DecRef(PyObject *);
 
+__gshared PyObject _Py_NoneStruct;
+
+PyObject* Py_None()() {
+    return &_Py_NoneStruct;
+}
 /* Rich comparison opcodes */
 enum int Py_LT = 0;
 enum int Py_LE = 1;

infrastructure/deimos/python/pyport.d

 module deimos.python.pyport;
 
-import deimos.python.fiddle;
-
 /* D long is always 64 bits, but when the Python/C API mentions long, it is of
  * course referring to the C type long, the size of which is 32 bits on both
  * X86 and X86_64 under Windows, but 32 bits on X86 and 64 bits on X86_64 under