Commit d3e8946d authored by Simon Feltman's avatar Simon Feltman
Browse files

Merge gobject static code into the gi module

Remove gi._gobject._gobject as a separately compiled static module and
move all the files into gi._gi.
Remove dead module initialization macros from "pyglib-python-compat.h"

https://bugzilla.gnome.org/show_bug.cgi?id=712197
parent a329f559
......@@ -24,11 +24,32 @@ extension_ldflags += \
-no-undefined
endif
pkgincludedir = $(includedir)/pygobject-$(PLATFORM_VERSION)
pkginclude_HEADERS = pygobject.h
pygidir = $(pyexecdir)/gi
pygi_LTLIBRARIES = _gi.la
_gi_la_SOURCES = \
gobjectmodule.c \
pygboxed.c \
pygboxed.h \
pygenum.c \
pygenum.h \
pygflags.c \
pygflags.h \
pyginterface.c \
pyginterface.h \
pygobject.c \
pygobject.h \
pygobject-private.h \
pygparamspec.c \
pygparamspec.h \
pygpointer.c \
pygpointer.h \
pygtype.c \
pygtype.h \
pygi-repository.c \
pygi-repository.h \
pygi-info.c \
......@@ -69,13 +90,16 @@ _gi_la_SOURCES = \
pygi-marshal-cleanup.c \
pygi-marshal-cleanup.h
_gi_la_CFLAGS = \
$(extension_cppflags) \
-I$(top_srcdir)/gi/_glib \
$(GLIB_CFLAGS) \
$(GI_CFLAGS)
_gi_la_CPPFLAGS = \
$(extension_cppflags) \
-I$(top_srcdir)/gi/_glib \
-I$(top_srcdir)/gi/_gobject
-I$(top_srcdir)/gi/_glib
_gi_la_LIBADD = \
$(extension_libadd) \
$(GLIB_LIBS) \
$(GI_LIBS) \
$(top_builddir)/gi/_glib/libpyglib-gi-2.0-@PYTHON_BASENAME@.la
_gi_la_LDFLAGS = \
......@@ -93,8 +117,7 @@ _gi_cairo_la_CFLAGS = \
$(PYCAIRO_CFLAGS)
_gi_cairo_la_CPPFLAGS = \
$(extension_cppflags) \
-I$(top_srcdir)/gi/_glib \
-I$(top_srcdir)/gi/_gobject
-I$(top_srcdir)/gi/_glib
_gi_cairo_la_LIBADD = \
$(extension_libadd) \
$(GI_LIBS) \
......
......@@ -29,46 +29,6 @@
# define PYGLIB_CPointer_Import(module, symbol) \
PyCapsule_Import(##module##.##symbol##, FALSE)
#if PY_VERSION_HEX < 0x03000000
#define PYGLIB_INIT_FUNCTION(modname, fullpkgname, functions) \
static int _pyglib_init_##modname(PyObject *module); \
void init##modname(void) \
{ \
PyObject *module = Py_InitModule(fullpkgname, functions); \
_pyglib_init_##modname(module); \
} \
static int _pyglib_init_##modname(PyObject *module)
#else
#define PYGLIB_INIT_FUNCTION(modname, fullpkgname, functions) \
static struct PyModuleDef _##modname##module = { \
PyModuleDef_HEAD_INIT, \
fullpkgname, \
NULL, \
-1, \
functions, \
NULL, \
NULL, \
NULL, \
NULL \
}; \
static int _pyglib_init_##modname(PyObject *module); \
PyObject *PyInit_##modname(void) \
{ \
PyObject *module = PyModule_Create(&_##modname##module); \
if (module == NULL) \
return NULL; \
if (_pyglib_init_##modname(module) != 0 ) {\
Py_DECREF(module); \
return NULL; \
} \
return module; \
} \
static int _pyglib_init_##modname(PyObject *module)
#endif
/* Compilation on Python 2.x */
#if PY_VERSION_HEX < 0x03000000
......@@ -121,12 +81,18 @@ static int _pyglib_init_##modname(PyObject *module)
#endif
#define PYGLIB_MODULE_START(symbol, modname) \
DL_EXPORT(void) init##symbol(void); \
DL_EXPORT(void) init##symbol(void) \
PyObject * pyglib_##symbol##_module_create(void); \
DL_EXPORT(void) init##symbol(void); \
DL_EXPORT(void) init##symbol(void) { \
pyglib_##symbol##_module_create(); \
}; \
PyObject * pyglib_##symbol##_module_create(void) \
{ \
PyObject *module; \
module = Py_InitModule(modname, symbol##_functions);
#define PYGLIB_MODULE_END }
#define PYGLIB_MODULE_END return module; }
#define PYGLIB_DEFINE_TYPE(typename, symbol, csymbol) \
PyTypeObject symbol = { \
PyObject_HEAD_INIT(NULL) \
......@@ -135,6 +101,7 @@ PyTypeObject symbol = { \
sizeof(csymbol), \
0, \
};
#define PYGLIB_REGISTER_TYPE(d, type, name) \
if (!type.tp_alloc) \
type.tp_alloc = PyType_GenericAlloc; \
......@@ -160,18 +127,25 @@ PyTypeObject symbol = { \
NULL, \
NULL \
}; \
PyObject * pyglib_##symbol##_module_create(void); \
PyMODINIT_FUNC PyInit_##symbol(void); \
PyMODINIT_FUNC PyInit_##symbol(void) \
PyMODINIT_FUNC PyInit_##symbol(void) { \
return pyglib_##symbol##_module_create(); \
}; \
PyObject * pyglib_##symbol##_module_create(void) \
{ \
PyObject *module; \
module = PyModule_Create(&_##symbol##module);
#define PYGLIB_MODULE_END return module; }
#define PYGLIB_DEFINE_TYPE(typename, symbol, csymbol) \
PyTypeObject symbol = { \
PyVarObject_HEAD_INIT(NULL, 0) \
typename, \
sizeof(csymbol) \
};
#define PYGLIB_REGISTER_TYPE(d, type, name) \
if (!type.tp_alloc) \
type.tp_alloc = PyType_GenericAlloc; \
......
AUTOMAKE_OPTIONS = 1.7
PLATFORM_VERSION = 3.0
pkgincludedir = $(includedir)/pygobject-$(PLATFORM_VERSION)
pkginclude_HEADERS = pygobject.h
extension_cppflags = \
$(PYTHON_INCLUDES) \
-DPY_SSIZE_T_CLEAN
extension_ldflags = \
-module \
-avoid-version \
-shrext $(PYTHON_SO)
if OS_WIN32
# Windows requires Python modules to be explicitly linked to libpython.
# Extension modules are shared libaries (.dll), but need to be
# called .pyd for Python to load it as an extension module.
extension_libadd = \
$(PYTHON_LIBS)
extension_ldflags += \
-no-undefined
endif
pygobjectdir = $(pyexecdir)/gi/_gobject
pygobject_PYTHON = \
......@@ -32,44 +9,6 @@ pygobject_PYTHON = \
propertyhelper.py \
signalhelper.py
pygobject_LTLIBRARIES = _gobject.la
_gobject_la_SOURCES = \
gobjectmodule.c \
pygboxed.c \
pygboxed.h \
pygenum.c \
pygenum.h \
pygflags.c \
pygflags.h \
pyginterface.c \
pyginterface.h \
pygobject.c \
pygobject.h \
pygobject-private.h \
pygparamspec.c \
pygparamspec.h \
pygpointer.c \
pygpointer.h \
pygtype.c \
pygtype.h
_gobject_la_CFLAGS = \
$(extension_cppflags) \
-I$(top_srcdir)/gi/_glib \
-I$(top_srcdir)/gi \
$(GLIB_CFLAGS) \
$(GI_CFLAGS)
_gi_la_CPPFLAGS = \
$(extension_cppflags)
_gobject_la_LIBADD = \
$(extension_libadd) \
$(GLIB_LIBS) \
$(GI_LIBS) \
$(top_builddir)/gi/_glib/libpyglib-gi-2.0-@PYTHON_BASENAME@.la
_gobject_la_LDFLAGS = \
$(extension_ldflags) \
-export-symbols-regex "_gobject|PyInit__gobject"
# if we build in a separate tree, we need to symlink the *.py files from the
# source tree; Python does not accept the extensions and modules in different
# paths
......@@ -79,9 +18,5 @@ build_pylinks:
done
all: $(pygobject_LTLIBRARIES:.la=$(PYTHON_SO)) build_pylinks
check-local: $(pygobject_LTLIBRARIES:.la=$(PYTHON_SO)) build_pylinks
clean-local:
rm -f $(pygobject_LTLIBRARIES:.la=$(PYTHON_SO))
%$(PYTHON_SO): %.la
$(LN_S) -f .libs/$@ $@
all: build_pylinks
check-local: build_pylinks
......@@ -27,7 +27,9 @@ import sys
if 'gobject' in sys.modules:
raise ImportError('When using gi.repository you must not import static modules like "gobject". Please change all occurrences of "import gobject" to "from gi.repository import GObject".')
from . import _gobject
import gi._gi
_gobject = gi._gi._gobject
from . import propertyhelper
from . import signalhelper
......
......@@ -19,7 +19,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
# USA
from . import _gobject
import gi._gi
_gobject = gi._gi._gobject
TYPE_INVALID = _gobject.TYPE_INVALID
TYPE_NONE = _gobject.type_from_name('void')
......
......@@ -21,7 +21,8 @@
import sys
from . import _gobject
import gi._gi
_gobject = gi._gi._gobject
from .constants import \
TYPE_NONE, TYPE_INTERFACE, TYPE_CHAR, TYPE_UCHAR, \
......@@ -30,10 +31,15 @@ from .constants import \
TYPE_FLOAT, TYPE_DOUBLE, TYPE_STRING, \
TYPE_POINTER, TYPE_BOXED, TYPE_PARAM, TYPE_OBJECT, \
TYPE_PYOBJECT, TYPE_GTYPE, TYPE_STRV, TYPE_VARIANT
from ._gobject import \
G_MAXFLOAT, G_MAXDOUBLE, \
G_MININT, G_MAXINT, G_MAXUINT, G_MINLONG, G_MAXLONG, \
G_MAXULONG
G_MAXFLOAT = _gobject.G_MAXFLOAT
G_MAXDOUBLE = _gobject.G_MAXDOUBLE
G_MININT = _gobject.G_MININT
G_MAXINT = _gobject.G_MAXINT
G_MAXUINT = _gobject.G_MAXUINT
G_MINLONG = _gobject.G_MINLONG
G_MAXLONG = _gobject.G_MAXLONG
G_MAXULONG = _gobject.G_MAXULONG
if sys.version_info >= (3, 0):
_basestring = str
......
......@@ -22,7 +22,8 @@
import sys
import inspect
from . import _gobject
import gi._gi
_gobject = gi._gi._gobject
# Callable went away in python 3.0 and came back in 3.2.
# Use versioning to figure out when to define it, otherwise we have to deal with
......
......@@ -21,11 +21,12 @@
* USA
*/
#include "pygobject-private.h"
#include "pyginterface.h"
#include "pygi-private.h"
#include "pygi.h"
#include "pyglib.h"
#include <pygobject.h>
#include <pyglib-python-compat.h>
PyObject *PyGIDeprecationWarning;
......@@ -627,6 +628,7 @@ static struct PyGI_API CAPI = {
PYGLIB_MODULE_START(_gi, "_gi")
{
PyObject *api;
PyObject *_gobject_module;
/* Always enable Python threads since we cannot predict which GI repositories
* might accept Python callbacks run within non-Python threads or might trigger
......@@ -635,13 +637,12 @@ PYGLIB_MODULE_START(_gi, "_gi")
*/
PyEval_InitThreads ();
if (pygobject_init (-1, -1, -1) == NULL) {
return PYGLIB_MODULE_ERROR_RETURN;
}
if (_pygobject_import() < 0) {
_gobject_module = pyglib__gobject_module_create ();
if (_gobject_module == NULL) {
return PYGLIB_MODULE_ERROR_RETURN;
}
PyModule_AddObject (module, "_gobject", _gobject_module);
PyModule_AddStringConstant(module, "__package__", "gi._gi");
_pygi_repository_register_types (module);
_pygi_info_register_types (module);
......
......@@ -59,8 +59,8 @@ from .types import \
GObjectMeta, \
StructMeta
from ._gobject._gobject import \
GInterface
import gi._gi
GInterface = gi._gi._gobject.GInterface
from ._gobject.constants import \
TYPE_NONE, \
......
......@@ -22,12 +22,12 @@
*/
#include "pygi-private.h"
#include "pygobject-private.h"
#include <string.h>
#include <time.h>
#include <datetime.h>
#include <pygobject.h>
#include <pyglib-python-compat.h>
#include <pyglib.h>
......@@ -1981,6 +1981,5 @@ void
_pygi_argument_init (void)
{
PyDateTime_IMPORT;
_pygobject_import();
}
......@@ -22,8 +22,8 @@
*/
#include "pygi-private.h"
#include "pygobject-private.h"
#include <pygobject.h>
#include <girepository.h>
#include <pyglib-python-compat.h>
......
......@@ -22,8 +22,8 @@
*/
#include "pygi-private.h"
#include "pygobject-private.h"
#include <pygobject.h>
#include <girepository.h>
#include <pyglib-python-compat.h>
......
......@@ -26,7 +26,7 @@
# include <config.h>
#endif
#include "pygobject.h"
#include "pygobject-private.h"
#include "pygi-foreign.h"
#include <girepository.h>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment