mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-21 14:53:44 +03:00
enhanced for enabling build in a different directory. Added (optional)
* Makefile.am, gentest.py: enhanced for enabling build in a different directory. Added (optional) param to gentest.py to specify the source directory (bug #155468) * doc/Makefile.am: changed destination of NEWS from (top_srcdir) to (top_builddir) (bug #155468) * python/Makefile.am, python/generator.py: enhanced for enabling build in a different directory(bug #155468). Added (optional) param to generator.py to specify the source directory. Added a new table of functions which have possible "foreign" encodings (e.g. UTF16), and code to use python 't' format instead of 'z' format (mostly solving bug #152286, but still need to populate the table).
This commit is contained in:
@@ -6,7 +6,8 @@ SUBDIRS= . tests
|
||||
INCLUDES = \
|
||||
-I$(PYTHON_INCLUDES) \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_builddir)/include
|
||||
-I$(top_builddir)/include \
|
||||
-I$(top_builddir)/$(subdir)
|
||||
|
||||
DOCS_DIR = $(datadir)/doc/libxml2-python-$(LIBXML_VERSION)
|
||||
# libxml2class.txt is generated
|
||||
@@ -37,8 +38,8 @@ python_LTLIBRARIES = libxml2mod.la
|
||||
libxml2mod_la_SOURCES = libxml.c types.c libxml2-py.c
|
||||
libxml2mod_la_LIBADD = $(mylibs) @CYGWIN_EXTRA_PYTHON_LIBADD@
|
||||
|
||||
libxml2.py: $(srcdir)/libxml.py $(srcdir)/libxml2class.py
|
||||
cat $(srcdir)/libxml.py $(srcdir)/libxml2class.py > libxml2.py
|
||||
libxml2.py: $(srcdir)/libxml.py libxml2class.py
|
||||
cat $(srcdir)/libxml.py libxml2class.py > libxml2.py
|
||||
|
||||
install-data-local:
|
||||
$(mkinstalldirs) $(DESTDIR)$(pythondir)
|
||||
@@ -50,18 +51,18 @@ install-data-local:
|
||||
|
||||
GENERATE = generator.py
|
||||
API_DESC = $(top_srcdir)/doc/libxml2-api.xml $(srcdir)/libxml2-python-api.xml
|
||||
GENERATED= $(srcdir)/libxml2class.py \
|
||||
$(srcdir)/libxml2-export.c \
|
||||
$(srcdir)/libxml2class.txt \
|
||||
$(srcdir)/libxml2-py.c \
|
||||
$(srcdir)/libxml2-py.h
|
||||
GENERATED= libxml2class.py \
|
||||
libxml2-export.c \
|
||||
libxml2class.txt \
|
||||
libxml2-py.c \
|
||||
libxml2-py.h
|
||||
|
||||
CLEANFILES= $(GENERATED) gen_prog libxml2.py
|
||||
|
||||
$(GENERATED): gen_prog
|
||||
|
||||
gen_prog: $(srcdir)/$(GENERATE) $(API_DESC)
|
||||
cd $(srcdir) && $(PYTHON) $(GENERATE)
|
||||
$(PYTHON) $(srcdir)/$(GENERATE) $(srcdir)
|
||||
touch gen_prog
|
||||
|
||||
$(libxml2mod_la_OBJECTS): $(GENERATED)
|
||||
|
@@ -9,6 +9,11 @@ enums = {} # { enumType: { enumConstant: enumValue } }
|
||||
import sys
|
||||
import string
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
srcPref = sys.argv[1] + '/'
|
||||
else:
|
||||
srcPref = ''
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# That part if purely the API acquisition phase from the
|
||||
@@ -294,6 +299,10 @@ py_return_types = {
|
||||
|
||||
unknown_types = {}
|
||||
|
||||
foreign_encoding_args = (
|
||||
'xmlCreateMemoryParserCtxt',
|
||||
)
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# This part writes the C <-> Python stubs libxml2-py.[ch] and
|
||||
@@ -382,6 +391,7 @@ def print_function_wrapper(name, output, export, include):
|
||||
c_args=""
|
||||
c_return=""
|
||||
c_convert=""
|
||||
num_bufs=0
|
||||
for arg in args:
|
||||
# This should be correct
|
||||
if arg[1][0:6] == "const ":
|
||||
@@ -389,6 +399,11 @@ def print_function_wrapper(name, output, export, include):
|
||||
c_args = c_args + " %s %s;\n" % (arg[1], arg[0])
|
||||
if py_types.has_key(arg[1]):
|
||||
(f, t, n, c) = py_types[arg[1]]
|
||||
if name == 'xmlCreateMemoryParserCtxt':
|
||||
print "processing special case"
|
||||
if (f == 'z') and (name in foreign_encoding_args):
|
||||
f = 't#'
|
||||
print "changed 'f'"
|
||||
if f != None:
|
||||
format = format + f
|
||||
if t != None:
|
||||
@@ -399,6 +414,10 @@ def print_function_wrapper(name, output, export, include):
|
||||
arg[1], t, arg[0]);
|
||||
else:
|
||||
format_args = format_args + ", &%s" % (arg[0])
|
||||
if f == 't#':
|
||||
format_args = format_args + ", &py_buffsize%d" % num_bufs
|
||||
c_args = c_args + " int py_buffsize%d;\n" % num_bufs
|
||||
num_bufs = num_bufs + 1
|
||||
if c_call != "":
|
||||
c_call = c_call + ", ";
|
||||
c_call = c_call + "%s" % (arg[0])
|
||||
@@ -570,14 +589,14 @@ def buildStubs():
|
||||
global unknown_types
|
||||
|
||||
try:
|
||||
f = open("libxml2-api.xml")
|
||||
f = open(srcPref + "libxml2-api.xml")
|
||||
data = f.read()
|
||||
(parser, target) = getparser()
|
||||
parser.feed(data)
|
||||
parser.close()
|
||||
except IOError, msg:
|
||||
try:
|
||||
f = open("../doc/libxml2-api.xml")
|
||||
f = open(srcPref + "../doc/libxml2-api.xml")
|
||||
data = f.read()
|
||||
(parser, target) = getparser()
|
||||
parser.feed(data)
|
||||
@@ -591,7 +610,7 @@ def buildStubs():
|
||||
|
||||
py_types['pythonObject'] = ('O', "pythonObject", "pythonObject", "pythonObject")
|
||||
try:
|
||||
f = open("libxml2-python-api.xml")
|
||||
f = open(srcPref + "libxml2-python-api.xml")
|
||||
data = f.read()
|
||||
(parser, target) = getparser()
|
||||
parser.feed(data)
|
||||
|
Reference in New Issue
Block a user