summaryrefslogtreecommitdiffstats
path: root/bindings
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2010-01-29 00:43:51 +0000
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2010-01-29 00:43:51 +0000
commitb2f07a064046d6dfbf47d39ea5c6eb130df595cf (patch)
treec5c5171a971274cdcf69d97c0cf955014ac3bc3e /bindings
parent92efc271a4cdb4e3180207447bd9a65f150427d4 (diff)
downloadlasso-b2f07a064046d6dfbf47d39ea5c6eb130df595cf.tar.gz
lasso-b2f07a064046d6dfbf47d39ea5c6eb130df595cf.tar.xz
lasso-b2f07a064046d6dfbf47d39ea5c6eb130df595cf.zip
Bindings: in bindings.py, fix regexp and annotation parsing for optional arguments and their default values
Diffstat (limited to 'bindings')
-rw-r--r--bindings/bindings.py32
1 files changed, 16 insertions, 16 deletions
diff --git a/bindings/bindings.py b/bindings/bindings.py
index 12840231..bb14742c 100644
--- a/bindings/bindings.py
+++ b/bindings/bindings.py
@@ -328,22 +328,22 @@ class DocString:
if 'allow-none' in annotation:
arg[2]['optional'] = True
- if re.search('\(\s*out\s*\)', annotation):
+ if re.search(r'\(\s*out\s*\)', annotation):
arg[2]['out'] = True
- if re.search('\(\s*in\s*\)', annotation):
+ if re.search(r'\(\s*in\s*\)', annotation):
arg[2]['in'] = True
- if arg[2].get('optional'):
- m = re.search('\(\s*default\s*(.*)\s*\)', annotation)
- if m:
- prefix = ''
- if is_boolean(arg):
- prefix = 'b:'
- elif is_int(arg, self.binding_data):
- prefix = 'c:'
- else:
- raise Exception('should not happen: could not found type for default: ' + annotation)
- arg[2]['default'] = prefix + m.group(1)
- m = re.search('\(\s*element-type\s+(\w+)(?:\s+(\w+))?', annotation)
+ m = re.search(r'\(\s*default\s*([^ )]*)\s*\)', annotation)
+ if m:
+ prefix = ''
+ if is_boolean(arg):
+ prefix = 'b:'
+ elif is_int(arg, self.binding_data):
+ prefix = 'c:'
+ else:
+ raise Exception('should not happen: could not found type for default: ' + annotation)
+ arg[2]['default'] = prefix + m.group(1)
+ arg[2]['optional'] = True
+ m = re.search(r'\(\s*element-type\s+(\w+)(?:\s+(\w+))?', annotation)
if m:
if len(m.groups()) > 2:
arg[2]['key-type'] = \
@@ -353,7 +353,7 @@ class DocString:
else:
arg[2]['element-type'] = \
convert_type_from_gobject_annotation(m.group(1))
- m = re.search('\(\s*transfer\s+(\w+)', annotation)
+ m = re.search(r'\(\s*transfer\s+(\w+)', annotation)
if m:
arg[2]['transfer'] = m.group(1)
@@ -475,7 +475,7 @@ def parse_header(header_file):
return_type += '*'
function_name = function_name[1:]
if binding.functions_toskip.get(function_name) != 1:
- if re.search('\<const\>', return_type):
+ if re.search(r'\<const\>', return_type):
f.return_owner = False
# clean the type
return_type = clean_type(return_type)