summaryrefslogtreecommitdiffstats
path: root/bindings
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2008-08-05 14:52:52 +0000
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2008-08-05 14:52:52 +0000
commit1fae093527f69de086934f5df750cf374eaa2f48 (patch)
treec182d67081132607753c96da70f7ce0995909ff4 /bindings
parent0930e6046f5c6e30b9d16fef5bb7a543e8750281 (diff)
downloadlasso-1fae093527f69de086934f5df750cf374eaa2f48.tar.gz
lasso-1fae093527f69de086934f5df750cf374eaa2f48.tar.xz
lasso-1fae093527f69de086934f5df750cf374eaa2f48.zip
Move all python binding related files inside the python subdirectory
Diffstat (limited to 'bindings')
-rw-r--r--bindings/bindings.py33
-rw-r--r--bindings/python/Makefile.am2
-rw-r--r--bindings/python/lang.py (renamed from bindings/lang_python.py)20
-rw-r--r--bindings/python/wrapper_bottom.c (renamed from bindings/lang_python_wrapper_bottom.c)0
-rw-r--r--bindings/python/wrapper_top.c (renamed from bindings/lang_python_wrapper_top.c)0
5 files changed, 32 insertions, 23 deletions
diff --git a/bindings/bindings.py b/bindings/bindings.py
index 5a6dc1c0..10cdfa0f 100644
--- a/bindings/bindings.py
+++ b/bindings/bindings.py
@@ -387,15 +387,22 @@ def parse_header(header_file):
i += 1
line = line[:-1] + lines[i].lstrip()
- m = re.match(r'LASSO_EXPORT\s+((?:const |)[\w]+\*?)\s+(\*?\w+)\s*\((.*?)\)', line)
- if m and not m.group(2).endswith('_get_type'):
+ m = re.match(r'LASSO_EXPORT\s+((?:const |)[\w]+\s*\*?)\s+(OFTYPE\(.*?\)\s+)?(\*?\w+)\s*\((.*?)\)', line)
+ if m and not m.group(3).endswith('_get_type'):
+ return_type, oftype, function_name, args = m.groups()
+ return_type = return_type.strip()
f = Function()
- return_type, function_name, args = m.groups()
if function_name[0] == '*':
return_type += '*'
function_name = function_name[1:]
if return_type != 'void':
f.return_type = return_type
+ if return_type.startswith('const'):
+ f.return_owner = False
+ if oftype:
+ oftype_parse = re.match(r'OFTYPE\((.*)\)', oftype)
+ if oftype_parse:
+ f.return_type_qualifier = oftype_parse.group(1)
if function_name.endswith('_destroy'):
# skip the _destroy functions, they are just wrapper over
# g_object_unref
@@ -467,9 +474,9 @@ def main():
binding.attach_methods()
if options.language == 'python':
- import lang_python
+ from python import lang
- python_binding = lang_python.PythonBinding(binding)
+ python_binding = lang.Binding(binding)
python_binding.generate()
elif options.language == 'php4':
from php4 import lang
@@ -477,20 +484,20 @@ def main():
php4_binding = lang.Binding(binding)
php4_binding.generate()
elif options.language == 'php5':
- import lang_php5
+ from php5 import lang
- php5_binding = lang_php5.Php5Binding(binding)
+ php5_binding = lang.Binding(binding)
php5_binding.generate()
elif options.language == 'java':
- import lang_java
+ from java import lang
- java_binding = lang_java.JavaBinding(binding)
- java_binding.generate();
+ java_binding = lang.Binding(binding)
+ java_binding.generate();
elif options.language == 'java-list':
- import lang_java
+ from java import lang
- java_binding = lang_java.JavaBinding(binding)
- java_binding.print_list_of_files();
+ java_binding = lang.Binding(binding)
+ java_binding.print_list_of_files();
if __name__ == '__main__':
diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am
index 3da0e08a..51709628 100644
--- a/bindings/python/Makefile.am
+++ b/bindings/python/Makefile.am
@@ -30,7 +30,7 @@ if WSF_ENABLED
EXTRA_ARGS = --enable-id-wsf
endif
-lasso.py _lasso.c:
+lasso.py _lasso.c: lang.py wrapper_top.c wrapper_bottom.c ../bindings.py
$(PYTHON) $(top_srcdir)/bindings/bindings.py -l python --src-dir=$(top_srcdir)/lasso/ $(EXTRA_ARGS)
clean-local:
diff --git a/bindings/lang_python.py b/bindings/python/lang.py
index 25a4f90e..483e7614 100644
--- a/bindings/lang_python.py
+++ b/bindings/python/lang.py
@@ -23,17 +23,21 @@ import os
import sys
import re
import textwrap
-
import utils
-class PythonBinding:
+class Binding:
def __init__(self, binding_data):
self.binding_data = binding_data
def is_pygobject(self, t):
- return t not in ['char*', 'const char*', 'gchar*', 'const gchar*',
- 'const GList*', 'GList*', 'GHashTable*',
- 'int', 'gint', 'gboolean', 'const gboolean', 'xmlNode*'] + self.binding_data.enums
+ if t:
+ m = re.match(r'(?:const\s*)?(.*)',t) # Remove const modifier
+ t = m.group(1)
+ return t not in ['char*', 'gchar*',
+ 'GList*', 'GHashTable*',
+ 'int', 'gint', 'gboolean', 'xmlNode*'] + self.binding_data.enums
+ else:
+ return False
def generate(self):
fd = open('lasso.py', 'w')
@@ -576,8 +580,7 @@ if WSF_SUPPORT:
def generate_wrapper(self, fd):
- print >> fd, open(os.path.join(self.binding_data.src_dir,
- 'lang_python_wrapper_top.c')).read()
+ print >> fd, open('wrapper_top.c').read()
for h in self.binding_data.headers:
print >> fd, '#include <%s>' % h
print >> fd, ''
@@ -592,8 +595,7 @@ if WSF_SUPPORT:
for m in c.methods:
self.generate_function_wrapper(m, fd)
self.generate_wrapper_list(fd)
- print >> fd, open(os.path.join(self.binding_data.src_dir,
- 'lang_python_wrapper_bottom.c')).read()
+ print >> fd, open('wrapper_bottom.c').read()
def generate_constants_wrapper(self, fd):
print >> fd, '''static void
diff --git a/bindings/lang_python_wrapper_bottom.c b/bindings/python/wrapper_bottom.c
index 51de44b0..51de44b0 100644
--- a/bindings/lang_python_wrapper_bottom.c
+++ b/bindings/python/wrapper_bottom.c
diff --git a/bindings/lang_python_wrapper_top.c b/bindings/python/wrapper_top.c
index 11d83efd..11d83efd 100644
--- a/bindings/lang_python_wrapper_top.c
+++ b/bindings/python/wrapper_top.c