ariovistus avatar ariovistus committed f559768

Fix issue 1.
Linking to global vars from dll requires "extern export" attributes.
Added appropriate unittest to deimos_unittests
scons won't build things on windows (but if it did, it would build my unittests)
added some powershell scripts for the meantime
pyd.def wants util.conv's module info for some dumb reason
Extension examples work again. dmd 2.060/win32
CeleriD should always supply infrastructure as include dir
Added version PydPythonExtension for CeleriD builds
rawexample, testdll seemed not to have been updated since switch to deimos headers
*^*&%* cast(int)(1000*3.3) == 3299 sometimes, so use 1000*3.5 instead

Comments (0)

Files changed (56)

 *.o
 *.so
 *.x
+*.lib
+*.exe
+*.obj
 junk.txt
 from os.path import join
-import re
+import re, sys
 rx = re.compile("(\d+)\.(\d+)")
 
 def pv_split(pyversion):
     DFLAGS = ['-unittest', '-property', '-debug', '-gc'],
     DLINKFLAGS = py_lib("2.7"),
     )
-Export('infra', 'py_versions', 'py_lib', 'pydfiles', 'join', 'env27')
+if sys.platform.lower().startswith("win"): exe_suffix = ".exe"
+else: exe_suffix = ".x"
+Export('infra', 'py_versions', 'py_lib', 'pydfiles', 'join', 'env27', "exe_suffix")
 SConscript([
     join("examples","pyind","SConscript"),
     join("examples", "pyd_unittests","SConscript"),
 ]
 
 _utilFiles = [
+    'conv.d',
     'typelist.d',
     'multi_index.d',
     'replace.d',
                     )
                 sources.append((winpath(filePath,self.winonly), 'infra'))
         # Add the infraDir to the include path for pyd, st, and meta.
-        if True in (with_pyd, with_st, with_meta):
-            includePathOpts += self._includeOpts
-            includePathOpts[-1] = includePathOpts[-1] % winpath(os.path.join(_infraDir), self.winonly)
+        includePathOpts += self._includeOpts
+        includePathOpts[-1] = includePathOpts[-1] % winpath(os.path.join(_infraDir), self.winonly)
         
         # Add DLL/SO boilerplate code file.
         if _isPlatWin:
             major = sys.version_info[0]
             minor = sys.version_info[1]
             optf = 'Python_%d_%d_Or_Later'
-            return [opt % (optf % (major,m)) for m in range(4,minor+1)]
+            return [opt % 'PydPythonExtension'] + [opt % (optf % (major,m)) for m in range(4,minor+1)]
+
             
         pythonVersionOpts = pvo(self._versionOpt) 
 

examples/deimos_unittests/build.ps1

+
+$PYTHON_2_7 = @(
+            "-version=Python_2_7_Or_Later",
+            "-version=Python_2_6_Or_Later",
+            "-version=Python_2_5_Or_Later",
+	        "-version=Python_2_4_Or_Later",
+            "-version=Python_Unicode_UCS2",
+	        "..\..\infrastructure\python/python27_digitalmars.lib")
+dmd (@("object_.d", "-unittest", "-I..\..\infrastructure\") + $PYTHON_2_7)

examples/deimos_unittests/object_.d

-import deimos.python.object;
+import std.string;
+
+import deimos.python.Python;
+
+shared static this() {
+    Py_Initialize();
+}
+
+unittest {
+    PyObject* type1 = PyObject_Type(PyObject_Type(PyDict_New()));
+    PyObject* type2 = cast(PyObject*) &PyType_Type;
+    // linker broken?
+    assert(type1 == type2, format("problem: deimos' PyType_Type isn't pointing at python's PyType_Type (py:%x, d:%x)",type1, type2));
+}
 
 unittest {
     // breaks linking?

examples/pyd_unittests/SConscript

 Import('*')
-env27.Program("buffer.x",["buffer.d", ] + pydfiles)
-env27.Program("class_wrap.x",["class_wrap.d", ] + pydfiles)
-env27.Program("def.x",["def.d", ] + pydfiles)
-env27.Program("embedded.x",["embedded.d", ] + pydfiles)
-env27.Program("func_wrap.x",["func_wrap.d", ] + pydfiles)
-env27.Program("make_object.x",["make_object.d", ] + pydfiles)
-env27.Program("pydobject.x",["pydobject.d", ] + pydfiles)
-env27.Program("struct_wrap.x",["struct_wrap.d", ] + pydfiles)
+env27.Program("buffer"+exe_suffix,["buffer.d", ] + pydfiles)
+env27.Program("class_wrap"+exe_suffix,["class_wrap.d", ] + pydfiles)
+env27.Program("def"+exe_suffix,["def.d", ] + pydfiles)
+env27.Program("embedded"+exe_suffix,["embedded.d", ] + pydfiles)
+env27.Program("func_wrap"+exe_suffix,["func_wrap.d", ] + pydfiles)
+env27.Program("make_object"+exe_suffix,["make_object.d", ] + pydfiles)
+env27.Program("pydobject"+exe_suffix,["pydobject.d", ] + pydfiles)
+env27.Program("struct_wrap"+exe_suffix,["struct_wrap.d", ] + pydfiles)

examples/pyd_unittests/build.ps1

+
+$DC = @("-unittest", "-property", "-debug")
+
+$PYTHON_2_7 = @(
+            "-version=Python_2_7_Or_Later",
+            "-version=Python_2_6_Or_Later",
+            "-version=Python_2_5_Or_Later",
+	        "-version=Python_2_4_Or_Later",
+            "-version=Python_Unicode_UCS2",
+	        "..\..\infrastructure\python/python27_digitalmars.lib")
+$PYD_FILES = ls ../../infrastructure/pyd/ *.d -recurse | foreach-object { $_.FullName } 
+$PYD_FILES += ls ../../infrastructure/meta/ *.d -recurse | foreach-object { $_.FullName } 
+$PYD_FILES += ls ../../infrastructure/util/ *.d -recurse | foreach-object { $_.FullName } 
+$global:args = $DC + $PYTHON_2_7 + $PYD_FILES + @("-I..\..\infrastructure\")
+
+$dfiles = ls *.d | where {$_ -match ".*[^3]\.d"}
+
+$dfiles | foreach {`
+    . "dmd" ($global:args + @($_, "-of$($_.BaseName).exe")) }
+
+#. "dmd" ($global:args + @("class_wrap.d", "-ofclass_wrap.exe")) 
+#. ".\class_wrap.exe"
+$dfiles | foreach {. ".\$($_.BaseName).exe" }

examples/pyd_unittests/class_wrap.d

 assert bizzy.m == 36
 bizzy **= 4
 assert bizzy.m == 48
-bizzy[2] = 3.3
-assert bizzy.m == 3302
-bizzy[2:3] = 4.3
-assert bizzy.m == 4323
-assert bizzy(40.5) == 44823
+bizzy[2] = 3.5
+assert bizzy.m == 3502
+bizzy[2:3] = 4.5
+assert bizzy.m == 4523
+assert bizzy(40.5) == 45023
 }", "testing");
 
 py_stmts(q"{

examples/pyind/SConscript

 Import('*')
-env27.Program("pyind",["pyind.d", ] + pydfiles)
+env27.Program("pyind"+exe_suffix,["pyind.d", ] + pydfiles)

examples/pyind/build.ps1

+
+$DC = @("-unittest", "-property", "-debug")
+
+$PYTHON_2_7 = @(
+            "-version=Python_2_7_Or_Later",
+            "-version=Python_2_6_Or_Later",
+            "-version=Python_2_5_Or_Later",
+	        "-version=Python_2_4_Or_Later",
+            "-version=Python_Unicode_UCS2",
+	        "..\..\infrastructure\python/python27_digitalmars.lib")
+$PYD_FILES = ls ../../infrastructure/pyd/ *.d -recurse | foreach-object { $_.FullName } 
+$PYD_FILES += ls ../../infrastructure/meta/ *.d -recurse | foreach-object { $_.FullName } 
+$PYD_FILES += ls ../../infrastructure/util/ *.d -recurse | foreach-object { $_.FullName } 
+$args = $DC + $PYTHON_2_7 + $PYD_FILES + @("pyind.d","-I..\..\infrastructure\", "-ofpyind.exe")
+. "dmd" $args
+

examples/rawexample/rawexample.d

 // A module written to the raw Python/C API.
 module rawexample;
 
-import python;
+import deimos.python.Python;
 import std.stdio;
 
 // our druntime handling is still a bit crummy
 extern(C)
 PyObject* Base_foo(PyObject* self, PyObject* args) {
     writefln("Base.foo");
-    Py_INCREF(Py_None);
-    return Py_None;
+    return Py_INCREF(Py_None);
 }
 
 extern(C)
 PyObject* Base_bar(PyObject* self, PyObject* args) {
     writefln("Base.bar");
-    Py_INCREF(Py_None);
-    return Py_None;
+    return Py_INCREF(Py_None);
 }
 
 PyMethodDef[] Base_methods = [
 extern(C)
 PyObject* Derived_bar(PyObject* self, PyObject* args) {
     writefln("Derived.bar");
-    Py_INCREF(Py_None);
-    return Py_None;
+    return Py_INCREF(Py_None);
 }
 
 PyMethodDef[] Derived_methods = [
 extern(C)
 PyObject* hello(PyObject* self, PyObject* args) {
     writefln("Hello, world!");
-    Py_INCREF(Py_None);
-    return Py_None;
+    return Py_INCREF(Py_None);
 }
 
 PyMethodDef[] rawexample_methods = [
 export void initrawexample() {
     PyObject* m = Py_INCREF(Py_InitModule("rawexample", rawexample_methods.ptr));
 
-    Base_type.ob_type = PyType_Type_p;
+    Base_type.ob_type = &PyType_Type;
     Base_type.tp_basicsize = Base_object.sizeof;
     Base_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
     Base_type.tp_methods = Base_methods.ptr;
     Py_INCREF(cast(PyObject*)&Base_type);
     PyModule_AddObject(m, "Base", cast(PyObject*)&Base_type);
 
-    Derived_type.ob_type = PyType_Type_p;
+    Derived_type.ob_type = &PyType_Type;
     Derived_type.tp_basicsize = Derived_object.sizeof;
     Derived_type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
     Derived_type.tp_methods = Derived_methods.ptr;

examples/testdll/testdll.d

 module testdll;
 
-import python;
+import deimos.python.Python;
 import pyd.pyd;
 import std.stdio, std.string;
 
         Member!("i", Docstring!"One sample data member of S."),
         Member!("s", Docstring!"Another sample data member of S."),
     )();
+
 }
 

infrastructure/deimos/python/boolobject.d

 }
 
 /// _
-__gshared PyTypeObject PyBool_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyBool_Type");
 
 // D translation of C macro:
 /// _
 }
 
 version(Python_3_0_Or_Later) {
-    __gshared PyLongObject _Py_FalseStruct;
-    __gshared PyLongObject _Py_TrueStruct;
+    mixin(PyAPI_DATA!"PyLongObject _Py_FalseStruct");
+    mixin(PyAPI_DATA!"PyLongObject _Py_TrueStruct");
 }else {
-    __gshared PyIntObject _Py_ZeroStruct;
-    __gshared PyIntObject _Py_TrueStruct;
+    mixin(PyAPI_DATA!"PyIntObject _Py_ZeroStruct");
+    mixin(PyAPI_DATA!"PyIntObject _Py_TrueStruct");
 }
 
 /// _

infrastructure/deimos/python/bufferobject.d

 }else{
 
 /// Availability: 2.*
-__gshared PyTypeObject PyBuffer_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyBuffer_Type");
 
 // D translation of C macro:
 /// Availability: 2.*

infrastructure/deimos/python/bytearrayobject.d

 
     /* Type object */
 /// Availability: >= 2.6
-    __gshared PyTypeObject PyByteArray_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyByteArray_Type");
 /// Availability: >= 2.6
-    __gshared PyTypeObject PyByteArrayIter_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyByteArrayIter_Type");
 
     /** Type check macro 
 Availability: >= 2.6

infrastructure/deimos/python/bytesobject.d

     } 
 
     /// 
-    __gshared PyTypeObject PyBytes_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyBytes_Type");
     /// 
-    __gshared PyTypeObject PyBytesIter_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyBytesIter_Type");
     // D translation of C macro:
     /// 
     int PyBytes_Check()(PyObject* op) {

infrastructure/deimos/python/cellobject.d

 }
 
 ///_
-__gshared PyTypeObject PyCell_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyCell_Type");
 
 // D translation of C macro:
 ///_

infrastructure/deimos/python/ceval.d

 /// _
 int _Py_CheckRecursiveCall(char* where);
 /// _
-__gshared int _Py_CheckRecursionLimit;
+mixin(PyAPI_DATA!"int _Py_CheckRecursionLimit");
 
 // TODO: version(STACKCHECK)
 /// _
 version(Python_3_0_Or_Later) {
 }else{
     /// _
-    __gshared /*volatile*/ int _Py_Ticker;
+    mixin(PyAPI_DATA!"/*volatile*/ int _Py_Ticker");
     /// _
-    __gshared int _Py_CheckInterval;
+    mixin(PyAPI_DATA!"int _Py_CheckInterval");
 }
 
 /// _

infrastructure/deimos/python/classobject.d

 }
 
 /// _
-__gshared PyTypeObject PyMethod_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyMethod_Type");
 
 // D translation of C macro:
 int PyMethod_Check()(PyObject *op) {
     PyObject* PyMethod_New(PyObject*, PyObject*);
 }else{
     /// Availability: 2.*
-    __gshared PyTypeObject PyClass_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyClass_Type");
     /// Availability: 2.*
-    __gshared PyTypeObject PyInstance_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyInstance_Type");
     // D translation of C macro:
     /// Availability: 2.*
     int PyClass_Check()(PyObject *op) {
     }
 
     /// Availability: 3.*
-    __gshared PyTypeObject PyInstanceMethod_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyInstanceMethod_Type");
 
     /// Availability: 3.*
     int PyInstanceMethod_Check()(PyObject* op) {

infrastructure/deimos/python/cobject.d

 // from the C level to Python and back (in essence, an opaque handle).
 
 /// Availaibility: 2.*, 3.0, 3.1
-__gshared PyTypeObject PyCObject_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyCObject_Type");
 
 // D translation of C macro:
 /// Availaibility: 2.*, 3.0, 3.1

infrastructure/deimos/python/code.d

 enum int CO_MAXBLOCKS = 20;
 
 /// _
-__gshared PyTypeObject PyCode_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyCode_Type");
 
 // D translations of C macros:
 /// _

infrastructure/deimos/python/complexobject.d

 }
 
 /// _
-__gshared PyTypeObject PyComplex_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyComplex_Type");
 
 // D translation of C macro:
 /// _

infrastructure/deimos/python/descrobject.d

 }
 
 /// _
-__gshared PyTypeObject PyWrapperDescr_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyWrapperDescr_Type");
 version(Python_2_6_Or_Later) {
     /// Availability: >= 2.6
-    __gshared PyTypeObject PyDictProxy_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyDictProxy_Type");
     /// Availability: >= 2.6
-    __gshared PyTypeObject PyGetSetDescr_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyGetSetDescr_Type");
     /// Availability: >= 2.6
-    __gshared PyTypeObject PyMemberDescr_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyMemberDescr_Type");
 }
 version(Python_3_0_Or_Later) {
     /// Availability: 3.2
-    __gshared PyTypeObject PyClassMethodDescr_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyClassMethodDescr_Type");
     /// Availability: 3.2
-    __gshared PyTypeObject PyMethodDescr_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyMethodDescr_Type");
     /// Availability: 3.2
-    __gshared PyTypeObject _PyMethodWrapper_Type;
+    mixin(PyAPI_DATA!"PyTypeObject _PyMethodWrapper_Type");
 }
 
 /// _
 PyObject* PyWrapper_New(PyObject*, PyObject*);
 
 /// _
-__gshared PyTypeObject PyProperty_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyProperty_Type");
 
 

infrastructure/deimos/python/dictobject.d

 }
 
 /// _
-__gshared PyTypeObject PyDict_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyDict_Type");
 version(Python_2_7_Or_Later) {
     /// Availability: >= 2.7
-    __gshared PyTypeObject PyDictIterKey_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyDictIterKey_Type");
     /// Availability: >= 2.7
-    __gshared PyTypeObject PyDictIterValue_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyDictIterValue_Type");
     /// Availability: >= 2.7
-    __gshared PyTypeObject PyDictIterItem_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyDictIterItem_Type");
     /// Availability: >= 2.7
-    __gshared PyTypeObject PyDictKeys_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyDictKeys_Type");
     /// Availability: >= 2.7
-    __gshared PyTypeObject PyDictItems_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyDictItems_Type");
     /// Availability: >= 2.7
-    __gshared PyTypeObject PyDictValues_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyDictValues_Type");
 }
 
 // D translation of C macro:

infrastructure/deimos/python/enumobject.d

   */
 module deimos.python.enumobject;
 
+import deimos.python.pyport;
 import deimos.python.object;
 
 /// _
-__gshared PyTypeObject PyEnum_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyEnum_Type");
 /// _
-__gshared PyTypeObject PyReversed_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyReversed_Type");

infrastructure/deimos/python/fileobject.d

     }
 
     /// Availability: 2.*
-    __gshared PyTypeObject PyFile_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyFile_Type");
 
     // D translation of C macro:
     /// Availability: 2.*
 /** The default encoding used by the platform file system APIs
    If non-NULL, this is different than the default encoding for strings
 */
-__gshared const(char)* Py_FileSystemDefaultEncoding;
+mixin(PyAPI_DATA!"const(char)* Py_FileSystemDefaultEncoding");
 
 /// _
 enum PY_STDIOTEXTMODE = "b";
 char* Py_UniversalNewlineFgets(char*, int, FILE*, PyObject*);
 version(Python_3_0_Or_Later) {
     /// Availability: 3.*
-    __gshared int Py_HasFileSystemDefaultEncoding;
+    mixin(PyAPI_DATA!"int Py_HasFileSystemDefaultEncoding");
     /// Availability: 3.*
     PyObject* PyFile_NewStdPrinter(int);
     /// Availability: 3.*
-    __gshared PyTypeObject PyStdPrinter_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyStdPrinter_Type");
 }else{
     /** Routines to replace fread() and fgets() which accept any of \r, \n
       or \r\n as line terminators.

infrastructure/deimos/python/floatobject.d

 }
 
 /// _
-__gshared PyTypeObject PyFloat_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyFloat_Type");
 
 // D translation of C macro:
 /// _

infrastructure/deimos/python/frameobject.d

 }
 
 /// _
-__gshared PyTypeObject PyFrame_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyFrame_Type");
 
 // D translation of C macro:
 /// _

infrastructure/deimos/python/funcobject.d

 }
 
 /// _
-__gshared PyTypeObject PyFunction_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyFunction_Type");
 
 // D translation of C macro:
 /// _
 }
 
 /// _
-__gshared PyTypeObject PyClassMethod_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyClassMethod_Type");
 /// _
-__gshared PyTypeObject PyStaticMethod_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyStaticMethod_Type");
 
 /// _
 PyObject* PyClassMethod_New(PyObject*);

infrastructure/deimos/python/genobject.d

 }
 
 /// _
-__gshared PyTypeObject PyGen_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyGen_Type");
 
 // D translations of C macros:
 /// _

infrastructure/deimos/python/import_.d

 }
 
 /// _
-__gshared PyTypeObject PyNullImporter_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyNullImporter_Type");
 /// _
-__gshared _inittab* PyImport_Inittab;
+mixin(PyAPI_DATA!"_inittab* PyImport_Inittab");
 
 version(Python_3_0_Or_Later) {
     /// Availability: 3.*
 
 /** Embedding apps may change this pointer to point to their favorite
    collection of frozen modules: */
-__gshared _frozen* PyImport_FrozenModules;
+mixin(PyAPI_DATA!"_frozen* PyImport_FrozenModules");
 

infrastructure/deimos/python/intobject.d

 }
 
 /// Availability: 2.*
-__gshared PyTypeObject PyInt_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyInt_Type");
 
 // D translation of C macro:
 /// Availability: 2.*

infrastructure/deimos/python/iterobject.d

 // Python-header-file: Include/iterobject.h:
 
 /// _
-__gshared PyTypeObject PySeqIter_Type;
+mixin(PyAPI_DATA!"PyTypeObject PySeqIter_Type");
 
 // D translation of C macro:
 /// _
 PyObject* PySeqIter_New(PyObject*);
 
 /// _
-__gshared PyTypeObject PyCallIter_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyCallIter_Type");
 version(Python_3_0_Or_Later) {
     /// Availability: 3.*
-    __gshared PyTypeObject PyCmpWrapper_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyCmpWrapper_Type");
 }
 
 // D translation of C macro:

infrastructure/deimos/python/listobject.d

 }
 
 /// _
-__gshared PyTypeObject PyList_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyList_Type");
 version(Python_3_0_Or_Later) {
     /// Availability: 3.*
-    __gshared PyTypeObject PyListIter_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyListIter_Type");
     /// Availability: 3.*
-    __gshared PyTypeObject PyListRevIter_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyListRevIter_Type");
     /// Availability: 3.*
-    __gshared PyTypeObject PySortWrapper_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PySortWrapper_Type");
 }
 
 // D translation of C macro:

infrastructure/deimos/python/longobject.d

 // Python-header-file: Include/longobject.h:
 
 /// _
-__gshared PyTypeObject PyLong_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyLong_Type");
 
 // D translation of C macro:
 /// _

infrastructure/deimos/python/memoryobject.d

 // Python-header-file: Include/memoryobject.h:
 version(Python_2_7_Or_Later) {
     /// Availability: >= 2.7
-    __gshared PyTypeObject PyMemoryView_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PyMemoryView_Type");
 
     /// Availability: >= 2.7
     int PyMemoryView_Check()(PyObject* op) {

infrastructure/deimos/python/methodobject.d

 /** This is about the type 'builtin_function_or_method',
    not Python methods in user-defined classes.  See classobject.h
    for the latter. */
-__gshared PyTypeObject PyCFunction_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyCFunction_Type");
 
 // D translation of C macro:
 /// _

infrastructure/deimos/python/moduleobject.d

 // Python-header-file: Include/moduleobject.h:
 
 /// _
-__gshared PyTypeObject PyModule_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyModule_Type");
 
 // D translation of C macro:
 /// _

infrastructure/deimos/python/object.d

 }
 
 /** built-in 'type' */
-__gshared PyTypeObject PyType_Type; 
+mixin(PyAPI_DATA!"PyTypeObject PyType_Type"); 
 /** built-in 'object' */
-__gshared PyTypeObject PyBaseObject_Type; 
+mixin(PyAPI_DATA!"PyTypeObject PyBaseObject_Type"); 
 /** built-in 'super' */
-__gshared PyTypeObject PySuper_Type; 
+mixin(PyAPI_DATA!"PyTypeObject PySuper_Type"); 
 
 version(Python_3_0_Or_Later) {
     /// Availability: 3.*
         Py_hash_t suffix;
     } 
     /// Availability: 3.*
-    __gshared _Py_HashSecret_t _Py_HashSecret;
+    mixin(PyAPI_DATA!"_Py_HashSecret_t _Py_HashSecret");
 }else{
     /// _
     C_long _Py_HashDouble(double);
             C_long suffix;
         } 
         /// _
-        __gshared _Py_HashSecret_t _Py_HashSecret;
+        mixin(PyAPI_DATA!"_Py_HashSecret_t _Py_HashSecret");
     }
 }
 
 /// ditto
 void Py_DecRef(PyObject *);
 
-__gshared PyObject _Py_NoneStruct;
+mixin(PyAPI_DATA!"PyObject _Py_NoneStruct");
 
 // issue 8683 gets in the way of this being a property
 Borrowed!PyObject* Py_None()() {

infrastructure/deimos/python/pycapsule.d

   */
 module deimos.python.pycapsule;
 
+import deimos.python.pyport;
 import deimos.python.object;
 
 version(Python_2_7_Or_Later) {
 // Python-header-file: Include/pycapsule.h:
 
 /// Availability: >= 2.7
-__gshared PyTypeObject PyCapsule_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyCapsule_Type");
 
 /// Availability: >= 2.7
 alias void function(PyObject*) PyCapsule_Destructor;

infrastructure/deimos/python/pydebug.d

 
 import std.c.stdlib;
 
+import deimos.python.pyport;
+
 extern(C):
 // Python-header-file: Include/node.h
 
 /// _
-__gshared int Py_DebugFlag;
+mixin(PyAPI_DATA!"int Py_DebugFlag");
 /// _
-__gshared int Py_VerboseFlag;
+mixin(PyAPI_DATA!"int Py_VerboseFlag");
 version(Python_3_0_Or_Later) {
-    __gshared int Py_QuietFlag;
+    mixin(PyAPI_DATA!"int Py_QuietFlag");
 }
 /// _
-__gshared int Py_InteractiveFlag;
+mixin(PyAPI_DATA!"int Py_InteractiveFlag");
 /// _
-__gshared int Py_OptimizeFlag;
+mixin(PyAPI_DATA!"int Py_OptimizeFlag");
 /// _
-__gshared int Py_NoSiteFlag;
+mixin(PyAPI_DATA!"int Py_NoSiteFlag");
 /// _
-__gshared int Py_UseClassExceptionsFlag;
+mixin(PyAPI_DATA!"int Py_UseClassExceptionsFlag");
 /// _
-__gshared int Py_FrozenFlag;
+mixin(PyAPI_DATA!"int Py_FrozenFlag");
 version(Python_3_0_Or_Later) {
 }else{
     /// Availability: 2.*
-    __gshared int Py_TabcheckFlag;
+    mixin(PyAPI_DATA!"int Py_TabcheckFlag");
     /// Availability: 2.*
-    __gshared int Py_UnicodeFlag;
+    mixin(PyAPI_DATA!"int Py_UnicodeFlag");
 }
 /// _
-__gshared int Py_IgnoreEnvironmentFlag;
+mixin(PyAPI_DATA!"int Py_IgnoreEnvironmentFlag");
 /// _
-__gshared int Py_DivisionWarningFlag;
+mixin(PyAPI_DATA!"int Py_DivisionWarningFlag");
 version(Python_2_6_Or_Later) {
     /// Availability: >= 2.6
-    __gshared int Py_DontWriteBytecodeFlag;
+    mixin(PyAPI_DATA!"int Py_DontWriteBytecodeFlag");
     /// Availability: >= 2.6
-    __gshared int Py_NoUserSiteDirectory;
+    mixin(PyAPI_DATA!"int Py_NoUserSiteDirectory");
 }
 
 version(Python_3_0_Or_Later) {
        on the command line, and is used in 2.2 by ceval.c to make all "/" divisions
        true divisions (which they will be in 3.0). */
     /// Availability: 2.*
-    __gshared int _Py_QnewFlag;
+    mixin(PyAPI_DATA!"int _Py_QnewFlag");
 
     version(Python_2_6_Or_Later) {
         /// Availability: 2.6, 2.7
-        __gshared int Py_Py3kWarningFlag;
+        mixin(PyAPI_DATA!"int Py_Py3kWarningFlag");
     }
 }
 version(Python_3_0_Or_Later) {
     /// Availability: 3.*
-    __gshared int Py_UnbufferedStdioFlag;
+    mixin(PyAPI_DATA!"int Py_UnbufferedStdioFlag");
 }
 version(Python_2_7_Or_Later) {
     /// Availability: >= 2.7
-    __gshared int Py_HashRandomizationFlag;
+    mixin(PyAPI_DATA!"int Py_HashRandomizationFlag");
 }
 
 /** this is a wrapper around getenv() that pays attention to

infrastructure/deimos/python/pyerrors.d

 
 version(Python_2_5_Or_Later) {
     /// Availability: >= 2.5
-    __gshared PyObject* PyExc_BaseException;
+    mixin(PyAPI_DATA!"PyObject* PyExc_BaseException");
 }
 /// _
-__gshared PyObject* PyExc_Exception;
+mixin(PyAPI_DATA!"PyObject* PyExc_Exception");
 /// _
-__gshared PyObject* PyExc_StopIteration;
+mixin(PyAPI_DATA!"PyObject* PyExc_StopIteration");
 version(Python_2_5_Or_Later) {
     /// Availability: >= 2.5
-    __gshared PyObject* PyExc_GeneratorExit;
+    mixin(PyAPI_DATA!"PyObject* PyExc_GeneratorExit");
 }
 version(Python_3_0_Or_Later) {
 }else{
     /// Availability: 2.*
-    __gshared PyObject* PyExc_StandardError;
+    mixin(PyAPI_DATA!"PyObject* PyExc_StandardError");
 }
 /// _
-__gshared PyObject* PyExc_ArithmeticError;
+mixin(PyAPI_DATA!"PyObject* PyExc_ArithmeticError");
 /// _
-__gshared PyObject* PyExc_LookupError;
+mixin(PyAPI_DATA!"PyObject* PyExc_LookupError");
 
 /// _
-__gshared PyObject* PyExc_AssertionError;
+mixin(PyAPI_DATA!"PyObject* PyExc_AssertionError");
 /// _
-__gshared PyObject* PyExc_AttributeError;
+mixin(PyAPI_DATA!"PyObject* PyExc_AttributeError");
 /// _
-__gshared PyObject* PyExc_EOFError;
+mixin(PyAPI_DATA!"PyObject* PyExc_EOFError");
 /// _
-__gshared PyObject* PyExc_FloatingPointError;
+mixin(PyAPI_DATA!"PyObject* PyExc_FloatingPointError");
 /// _
-__gshared PyObject* PyExc_EnvironmentError;
+mixin(PyAPI_DATA!"PyObject* PyExc_EnvironmentError");
 /// _
-__gshared PyObject* PyExc_IOError;
+mixin(PyAPI_DATA!"PyObject* PyExc_IOError");
 /// _
-__gshared PyObject* PyExc_OSError;
+mixin(PyAPI_DATA!"PyObject* PyExc_OSError");
 /// _
-__gshared PyObject* PyExc_ImportError;
+mixin(PyAPI_DATA!"PyObject* PyExc_ImportError");
 /// _
-__gshared PyObject* PyExc_IndexError;
+mixin(PyAPI_DATA!"PyObject* PyExc_IndexError");
 /// _
-__gshared PyObject* PyExc_KeyError;
+mixin(PyAPI_DATA!"PyObject* PyExc_KeyError");
 /// _
-__gshared PyObject* PyExc_KeyboardInterrupt;
+mixin(PyAPI_DATA!"PyObject* PyExc_KeyboardInterrupt");
 /// _
-__gshared PyObject* PyExc_MemoryError;
+mixin(PyAPI_DATA!"PyObject* PyExc_MemoryError");
 /// _
-__gshared PyObject* PyExc_NameError;
+mixin(PyAPI_DATA!"PyObject* PyExc_NameError");
 /// _
-__gshared PyObject* PyExc_OverflowError;
+mixin(PyAPI_DATA!"PyObject* PyExc_OverflowError");
 /// _
-__gshared PyObject* PyExc_RuntimeError;
+mixin(PyAPI_DATA!"PyObject* PyExc_RuntimeError");
 /// _
-__gshared PyObject* PyExc_NotImplementedError;
+mixin(PyAPI_DATA!"PyObject* PyExc_NotImplementedError");
 /// _
-__gshared PyObject* PyExc_SyntaxError;
+mixin(PyAPI_DATA!"PyObject* PyExc_SyntaxError");
 /// _
-__gshared PyObject* PyExc_IndentationError;
+mixin(PyAPI_DATA!"PyObject* PyExc_IndentationError");
 /// _
-__gshared PyObject* PyExc_TabError;
+mixin(PyAPI_DATA!"PyObject* PyExc_TabError");
 /// _
-__gshared PyObject* PyExc_ReferenceError;
+mixin(PyAPI_DATA!"PyObject* PyExc_ReferenceError");
 /// _
-__gshared PyObject* PyExc_SystemError;
+mixin(PyAPI_DATA!"PyObject* PyExc_SystemError");
 /// _
-__gshared PyObject* PyExc_SystemExit;
+mixin(PyAPI_DATA!"PyObject* PyExc_SystemExit");
 /// _
-__gshared PyObject* PyExc_TypeError;
+mixin(PyAPI_DATA!"PyObject* PyExc_TypeError");
 /// _
-__gshared PyObject* PyExc_UnboundLocalError;
+mixin(PyAPI_DATA!"PyObject* PyExc_UnboundLocalError");
 /// _
-__gshared PyObject* PyExc_UnicodeError;
+mixin(PyAPI_DATA!"PyObject* PyExc_UnicodeError");
 /// _
-__gshared PyObject* PyExc_UnicodeEncodeError;
+mixin(PyAPI_DATA!"PyObject* PyExc_UnicodeEncodeError");
 /// _
-__gshared PyObject* PyExc_UnicodeDecodeError;
+mixin(PyAPI_DATA!"PyObject* PyExc_UnicodeDecodeError");
 /// _
-__gshared PyObject* PyExc_UnicodeTranslateError;
+mixin(PyAPI_DATA!"PyObject* PyExc_UnicodeTranslateError");
 /// _
-__gshared PyObject* PyExc_ValueError;
+mixin(PyAPI_DATA!"PyObject* PyExc_ValueError");
 /// _
-__gshared PyObject* PyExc_ZeroDivisionError;
+mixin(PyAPI_DATA!"PyObject* PyExc_ZeroDivisionError");
 version(Windows) {
     /// Availability: Windows only
-    __gshared PyObject* PyExc_WindowsError;
+    mixin(PyAPI_DATA!"PyObject* PyExc_WindowsError");
 }
 // ??!
 version(VMS) {
     /// Availability: VMS only
-    __gshared PyObject* PyExc_VMSError;
+    mixin(PyAPI_DATA!"PyObject* PyExc_VMSError");
 }
 version(Python_2_6_Or_Later) {
     /// Availability: >= 2.6
-    __gshared PyObject* PyExc_BufferError;
+    mixin(PyAPI_DATA!"PyObject* PyExc_BufferError");
 }
 
 version(Python_3_0_Or_Later) {
 }else{
     /// Availability: 2.*
-    __gshared PyObject* PyExc_MemoryErrorInst;
+    mixin(PyAPI_DATA!"PyObject* PyExc_MemoryErrorInst");
 }
 version(Python_2_6_Or_Later) {
     /// Availability: >= 2.6
-    __gshared PyObject* PyExc_RecursionErrorInst;
+    mixin(PyAPI_DATA!"PyObject* PyExc_RecursionErrorInst");
 }
 
 /** Predefined warning categories */
-__gshared PyObject* PyExc_Warning;
+mixin(PyAPI_DATA!"PyObject* PyExc_Warning");
 /// ditto
-__gshared PyObject* PyExc_UserWarning;
+mixin(PyAPI_DATA!"PyObject* PyExc_UserWarning");
 /// ditto
-__gshared PyObject* PyExc_DeprecationWarning;
+mixin(PyAPI_DATA!"PyObject* PyExc_DeprecationWarning");
 /// ditto
-__gshared PyObject* PyExc_PendingDeprecationWarning;
+mixin(PyAPI_DATA!"PyObject* PyExc_PendingDeprecationWarning");
 /// ditto
-__gshared PyObject* PyExc_SyntaxWarning;
+mixin(PyAPI_DATA!"PyObject* PyExc_SyntaxWarning");
 /* PyExc_OverflowWarning will go away for Python 2.5 */
 version(Python_2_5_Or_Later) {
 }else{
     /// Availability: 2.4
-    __gshared PyObject* PyExc_OverflowWarning;
+    mixin(PyAPI_DATA!"PyObject* PyExc_OverflowWarning");
 }
 /// _
-__gshared PyObject* PyExc_RuntimeWarning;
+mixin(PyAPI_DATA!"PyObject* PyExc_RuntimeWarning");
 /// _
-__gshared PyObject* PyExc_FutureWarning;
+mixin(PyAPI_DATA!"PyObject* PyExc_FutureWarning");
 version(Python_2_5_Or_Later) {
     /// Availability: >= 2.5
-    __gshared PyObject* PyExc_ImportWarning;
+    mixin(PyAPI_DATA!"PyObject* PyExc_ImportWarning");
     /// Availability: >= 2.5
-    __gshared PyObject* PyExc_UnicodeWarning;
+    mixin(PyAPI_DATA!"PyObject* PyExc_UnicodeWarning");
 }
 version(Python_2_6_Or_Later) {
     /// Availability: >= 2.6
-    __gshared PyObject* PyExc_BytesWarning;
+    mixin(PyAPI_DATA!"PyObject* PyExc_BytesWarning");
 }
 
 version(Python_3_0_Or_Later) {
     /// Availability: 3.*
-    __gshared PyObject* PyExc_ResourceWarning;
+    mixin(PyAPI_DATA!"PyObject* PyExc_ResourceWarning");
 
     /** Traceback manipulation (PEP 3134) */
     int PyException_SetTraceback(PyObject*, PyObject*);

infrastructure/deimos/python/pyport.d

     alias int Py_ssize_t;
 }
 
+template PyAPI_DATA(string decl) {
+    version(Windows) {
+    enum PyAPI_DATA = (q{
+        extern(C)
+        extern
+        export
+        __gshared
+    } ~ decl ~ ";");
+    }else{
+    // todo: check that extern export doesn't break linux build somehow
+    enum PyAPI_DATA = (q{
+        extern(C)
+        __gshared
+    } ~ decl ~ ";");
+    }
+}

infrastructure/deimos/python/pystate.d

 
 version(Python_3_0_Or_Later) {
     /// _
-    __gshared _Py_atomic_address _PyThreadState_Current;
+    mixin(PyAPI_DATA!"_Py_atomic_address _PyThreadState_Current");
 
     /// _
     auto PyThreadState_GET()() { 
     }
 }else{
     /// _
-    __gshared PyThreadState* _PyThreadState_Current;
+    mixin(PyAPI_DATA!"PyThreadState* _PyThreadState_Current");
 
     /// _
     auto PyThreadState_GET()() { 
 alias PyFrameObject* function(PyThreadState* self_) PyThreadFrameGetter;
 
 /// _
-__gshared PyThreadFrameGetter _PyThreadState_GetFrame;
+mixin(PyAPI_DATA!"PyThreadFrameGetter _PyThreadState_GetFrame");

infrastructure/deimos/python/pythonrun.d

 char* PyOS_Readline(FILE*, FILE*, char*);
 
 /// _
-__gshared int function() PyOS_InputHook;
+mixin(PyAPI_DATA!"int function() PyOS_InputHook");
 /// _
-__gshared char* function(FILE*, FILE*, char*) PyOS_ReadlineFunctionPointer;
+mixin(PyAPI_DATA!"char* function(FILE*, FILE*, char*) 
+    PyOS_ReadlineFunctionPointer");
 /// _
-__gshared PyThreadState* _PyOS_ReadlineTState;
+mixin(PyAPI_DATA!"PyThreadState* _PyOS_ReadlineTState");
 

infrastructure/deimos/python/rangeobject.d

 // Python-header-file: Include/rangeobject.h:
 
 /// _
-__gshared PyTypeObject PyRange_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyRange_Type");
 /// _
-__gshared PyTypeObject PyRangeIter_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyRangeIter_Type");
 /// _
-__gshared PyTypeObject PyLongRangeIter_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyLongRangeIter_Type");
 
 // D translation of C macro:
 /// _

infrastructure/deimos/python/setobject.d

 }
 
 /// _
-__gshared PyTypeObject PySet_Type;
+mixin(PyAPI_DATA!"PyTypeObject PySet_Type");
 /// _
-__gshared PyTypeObject PyFrozenSet_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyFrozenSet_Type");
 /// _
-__gshared PyTypeObject PySetIter_Type;
+mixin(PyAPI_DATA!"PyTypeObject PySetIter_Type");
 
 // D translations of C macros:
 /// _

infrastructure/deimos/python/sliceobject.d

 extern(C):
 // Python-header-file: Include/sliceobject.h:
 
-__gshared PyObject _Py_EllipsisObject;
+mixin(PyAPI_DATA!"PyObject _Py_EllipsisObject");
 
 /** The unique ellipsis object "..." */
 @property PyObject* Py_Ellipsis()() {
 }
 
 /// _
-__gshared PyTypeObject PySlice_Type;
+mixin(PyAPI_DATA!"PyTypeObject PySlice_Type");
 
 // D translation of C macro:
 /// _

infrastructure/deimos/python/stringobject.d

 }
 
 /// Availability: 2.*
-__gshared PyTypeObject PyBaseString_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyBaseString_Type");
 /// Availability: 2.*
-__gshared PyTypeObject PyString_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyString_Type");
 
 // D translation of C macro:
 /// Availability: 2.*

infrastructure/deimos/python/symtable.d

 
 version(Python_2_5_Or_Later) {
     /// Availability: >= 2.5
-    __gshared PyTypeObject PySTEntry_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PySTEntry_Type");
 
     /// _
     int PySymtableEntry_Check()(PyObject* op) {
     /// Availability: 2.4
     alias PySTEntryObject PySymtableEntryObject;
     /// Availability: 2.4
-    __gshared PyTypeObject PySymtableEntry_Type;
+    mixin(PyAPI_DATA!"PyTypeObject PySymtableEntry_Type");
 
     /// _
     int PySymtableEntry_Check()(PyObject* op) {

infrastructure/deimos/python/sysmodule.d

 }
 
 /// _
-__gshared PyObject* _PySys_TraceFunc;
+mixin(PyAPI_DATA!"PyObject* _PySys_TraceFunc");
 /// _
-__gshared PyObject** _PySys_ProfileFunc;
+mixin(PyAPI_DATA!"PyObject** _PySys_ProfileFunc");
 
 /// _
 void PySys_ResetWarnOptions();

infrastructure/deimos/python/traceback.d

 }
 
 /// _
-__gshared PyTypeObject PyTraceBack_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyTraceBack_Type");
 
 // D translation of C macro:
 /// _

infrastructure/deimos/python/tupleobject.d

 }
 
 /// _
-__gshared PyTypeObject PyTuple_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyTuple_Type");
 /// _
-__gshared PyTypeObject PyTupleIter_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyTupleIter_Type");
 
 // D translation of C macro:
 /// _

infrastructure/deimos/python/unicodeobject.d

 }
 
 /// _
-__gshared PyTypeObject PyUnicode_Type;
+mixin(PyAPI_DATA!"PyTypeObject PyUnicode_Type");
 
 // D translations of C macros:
 /** Fast access macros */

infrastructure/deimos/python/weakrefobject.d

 }
 
 /// _
-__gshared PyTypeObject _PyWeakref_RefType;
+mixin(PyAPI_DATA!"PyTypeObject _PyWeakref_RefType");
 /// _
-__gshared PyTypeObject _PyWeakref_ProxyType;
+mixin(PyAPI_DATA!"PyTypeObject _PyWeakref_ProxyType");
 /// _
-__gshared PyTypeObject _PyWeakref_CallableProxyType;
+mixin(PyAPI_DATA!"PyTypeObject _PyWeakref_CallableProxyType");
 
 // D translations of C macros:
 /// _

infrastructure/pyd/def.d

         PyImport_AppendInittab(modulename.ptr, &Py3_ModuleInit!modulename.func);
     }else{
         // schizophrenic arrangements, these
-        assert(py_init_called);
+        version(PydPythonExtension) {
+        }else{
+            assert(py_init_called);
+        }
         pyd_modules[modulename] = Py_INCREF(Py_InitModule3((modulename ~ "\0"), 
                     module_methods[modulename].ptr, (docstring ~ "\0")));
     }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.