summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Finlay <finlay@src.gnome.org>2008-11-01 01:06:49 +0000
committerJohn Finlay <finlay@src.gnome.org>2008-11-01 01:06:49 +0000
commitb4d11afc0138699cefa0a7cfcc99039853fc4fae (patch)
treed083b13f328f1bde1bfd2a0d431742092214f152
parent21024fb23f1ef97746aa72ae4918cce96f28b2bc (diff)
downloadpygobject-b4d11afc0138699cefa0a7cfcc99039853fc4fae.tar.gz
pygobject-b4d11afc0138699cefa0a7cfcc99039853fc4fae.tar.xz
pygobject-b4d11afc0138699cefa0a7cfcc99039853fc4fae.zip
Add defsgen to __all__ list. Strip out # directives from enum defintions.
* codegen/__init__.py (__all__): Add defsgen to __all__ list. * codegen/h2def.py (find_enum_defs): Strip out # directives from enum defintions. (clean_func): Change ' * G_CONST_RETURN * ' to '** ' svn path=/trunk/; revision=974
-rw-r--r--ChangeLog6
-rw-r--r--codegen/__init__.py1
-rwxr-xr-xcodegen/h2def.py5
3 files changed, 12 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index dfd9ceb..26a4be0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2008-10-31 John Finlay <finlay@moeraki.com>
+ * codegen/__init__.py (__all__): Add defsgen to __all__ list.
+
+ * codegen/h2def.py (find_enum_defs): Strip out # directives from
+ enum defintions.
+ (clean_func): Change ' * G_CONST_RETURN * ' to '** '
+
* codegen/Makefile.am (codegen_PYTHON): Add defsgen.py
* codegen/defsgen.py (typecode): Use the passed in prefix as a
diff --git a/codegen/__init__.py b/codegen/__init__.py
index cfa896e..86188f9 100644
--- a/codegen/__init__.py
+++ b/codegen/__init__.py
@@ -8,6 +8,7 @@ __all__ = [
'docextract',
'docgen',
'h2def',
+ 'defsgen'
'mergedefs',
'mkskel',
'override',
diff --git a/codegen/h2def.py b/codegen/h2def.py
index 0af30f5..7669fd4 100755
--- a/codegen/h2def.py
+++ b/codegen/h2def.py
@@ -174,6 +174,10 @@ def find_enum_defs(buf, enums=[]):
# bulk comments
buf = strip_comments(buf)
+ # strip # directives
+ pat = re.compile(r"""^[#].*?$""", re.MULTILINE)
+ buf = pat.sub('', buf)
+
buf = re.sub('\n', ' ', buf)
enum_pat = re.compile(r'enum\s*{([^}]*)}\s*([A-Z][A-Za-z]*)(\s|;)')
@@ -244,6 +248,7 @@ def clean_func(buf):
buf = pat.sub(r'[] \1', buf)
# make return types that are const work.
+ buf = re.sub(r'\s*\*\s*G_CONST_RETURN\s*\*\s*', '** ', buf)
buf = string.replace(buf, 'G_CONST_RETURN ', 'const-')
buf = string.replace(buf, 'const ', 'const-')