gobject-introspection r266 - in trunk: . giscanner
- From: johan svn gnome org
- To: svn-commits-list gnome org
- Subject: gobject-introspection r266 - in trunk: . giscanner
- Date: Tue, 6 May 2008 00:41:40 +0100 (BST)
Author: johan
Date: Mon May 5 23:41:40 2008
New Revision: 266
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=266&view=rev
Log:
2008-05-05 Johan Dahlin <johan gnome org>
* giscanner/__init__.py:
* giscanner/sourcescanner.py:
* giscanner/transformer.py:
Move sourcescanner symbols to the sourcescanner module, instead
of in the global __init__ namespace.
Modified:
trunk/ChangeLog
trunk/giscanner/__init__.py
trunk/giscanner/sourcescanner.py
trunk/giscanner/transformer.py
Modified: trunk/giscanner/__init__.py
==============================================================================
--- trunk/giscanner/__init__.py (original)
+++ trunk/giscanner/__init__.py Mon May 5 23:41:40 2008
@@ -18,57 +18,3 @@
# 02110-1301, USA.
#
-(CSYMBOL_TYPE_INVALID,
- CSYMBOL_TYPE_CONST,
- CSYMBOL_TYPE_OBJECT,
- CSYMBOL_TYPE_FUNCTION,
- CSYMBOL_TYPE_STRUCT,
- CSYMBOL_TYPE_UNION,
- CSYMBOL_TYPE_ENUM,
- CSYMBOL_TYPE_TYPEDEF) = range(8)
-
-(CTYPE_INVALID,
- CTYPE_VOID,
- CTYPE_BASIC_TYPE,
- CTYPE_TYPEDEF,
- CTYPE_STRUCT,
- CTYPE_UNION,
- CTYPE_ENUM,
- CTYPE_POINTER,
- CTYPE_ARRAY,
- CTYPE_FUNCTION) = range(10)
-
-STORAGE_CLASS_NONE = 0
-STORAGE_CLASS_TYPEDEF = 1 << 1
-STORAGE_CLASS_EXTERN = 1 << 2
-STORAGE_CLASS_STATIC = 1 << 3
-STORAGE_CLASS_AUTO = 1 << 4
-STORAGE_CLASS_REGISTER = 1 << 5
-
-TYPE_QUALIFIER_NONE = 0
-TYPE_QUALIFIER_CONST = 1 << 1
-TYPE_QUALIFIER_RESTRICT = 1 << 2
-TYPE_QUALIFIER_VOLATILE = 1 << 3
-
-FUNCTION_NONE = 0
-FUNCTION_INLINE = 1 << 1
-
-(UNARY_ADDRESS_OF,
- UNARY_POINTER_INDIRECTION,
- UNARY_PLUS,
- UNARY_MINUS,
- UNARY_BITWISE_COMPLEMENT,
- UNARY_LOGICAL_NEGATION) = range(6)
-
-def symbol_type_name(symbol_type):
- return {
- CSYMBOL_TYPE_INVALID: 'invalid',
- CSYMBOL_TYPE_CONST: 'const',
- CSYMBOL_TYPE_OBJECT: 'object',
- CSYMBOL_TYPE_FUNCTION: 'function',
- CSYMBOL_TYPE_STRUCT: 'struct',
- CSYMBOL_TYPE_UNION: 'union',
- CSYMBOL_TYPE_ENUM: 'enum',
- CSYMBOL_TYPE_TYPEDEF: 'typedef'
- }.get(symbol_type)
-
Modified: trunk/giscanner/sourcescanner.py
==============================================================================
--- trunk/giscanner/sourcescanner.py (original)
+++ trunk/giscanner/sourcescanner.py Mon May 5 23:41:40 2008
@@ -23,6 +23,60 @@
from . import _giscanner
+(CSYMBOL_TYPE_INVALID,
+ CSYMBOL_TYPE_CONST,
+ CSYMBOL_TYPE_OBJECT,
+ CSYMBOL_TYPE_FUNCTION,
+ CSYMBOL_TYPE_STRUCT,
+ CSYMBOL_TYPE_UNION,
+ CSYMBOL_TYPE_ENUM,
+ CSYMBOL_TYPE_TYPEDEF) = range(8)
+
+(CTYPE_INVALID,
+ CTYPE_VOID,
+ CTYPE_BASIC_TYPE,
+ CTYPE_TYPEDEF,
+ CTYPE_STRUCT,
+ CTYPE_UNION,
+ CTYPE_ENUM,
+ CTYPE_POINTER,
+ CTYPE_ARRAY,
+ CTYPE_FUNCTION) = range(10)
+
+STORAGE_CLASS_NONE = 0
+STORAGE_CLASS_TYPEDEF = 1 << 1
+STORAGE_CLASS_EXTERN = 1 << 2
+STORAGE_CLASS_STATIC = 1 << 3
+STORAGE_CLASS_AUTO = 1 << 4
+STORAGE_CLASS_REGISTER = 1 << 5
+
+TYPE_QUALIFIER_NONE = 0
+TYPE_QUALIFIER_CONST = 1 << 1
+TYPE_QUALIFIER_RESTRICT = 1 << 2
+TYPE_QUALIFIER_VOLATILE = 1 << 3
+
+FUNCTION_NONE = 0
+FUNCTION_INLINE = 1 << 1
+
+(UNARY_ADDRESS_OF,
+ UNARY_POINTER_INDIRECTION,
+ UNARY_PLUS,
+ UNARY_MINUS,
+ UNARY_BITWISE_COMPLEMENT,
+ UNARY_LOGICAL_NEGATION) = range(6)
+
+def symbol_type_name(symbol_type):
+ return {
+ CSYMBOL_TYPE_INVALID: 'invalid',
+ CSYMBOL_TYPE_CONST: 'const',
+ CSYMBOL_TYPE_OBJECT: 'object',
+ CSYMBOL_TYPE_FUNCTION: 'function',
+ CSYMBOL_TYPE_STRUCT: 'struct',
+ CSYMBOL_TYPE_UNION: 'union',
+ CSYMBOL_TYPE_ENUM: 'enum',
+ CSYMBOL_TYPE_TYPEDEF: 'typedef'
+ }.get(symbol_type)
+
class SourceType(object):
def __init__(self, scanner, stype):
Modified: trunk/giscanner/transformer.py
==============================================================================
--- trunk/giscanner/transformer.py (original)
+++ trunk/giscanner/transformer.py Mon May 5 23:41:40 2008
@@ -18,11 +18,13 @@
# 02110-1301, USA.
#
-import giscanner
-
from giscanner.ast import (Callback, Enum, Function, Member, Parameter,
Return, Sequence, Struct, Type)
-from giscanner.sourcescanner import SourceSymbol
+from giscanner.sourcescanner import (
+ SourceSymbol, symbol_type_name, CTYPE_POINTER, CTYPE_TYPEDEF, CTYPE_VOID,
+ CTYPE_BASIC_TYPE, CTYPE_FUNCTION, CTYPE_STRUCT, CSYMBOL_TYPE_FUNCTION,
+ CSYMBOL_TYPE_TYPEDEF, CSYMBOL_TYPE_STRUCT, CSYMBOL_TYPE_ENUM,
+ CSYMBOL_TYPE_UNION, CSYMBOL_TYPE_OBJECT)
class Transformer(object):
@@ -66,34 +68,34 @@
if stype is None:
stype = symbol.type
- if stype == giscanner.CSYMBOL_TYPE_FUNCTION:
+ if stype == CSYMBOL_TYPE_FUNCTION:
return self._create_function(symbol)
- elif stype == giscanner.CSYMBOL_TYPE_TYPEDEF:
- if (symbol.base_type.type == giscanner.CTYPE_POINTER and
- symbol.base_type.base_type.type == giscanner.CTYPE_FUNCTION):
+ elif stype == CSYMBOL_TYPE_TYPEDEF:
+ if (symbol.base_type.type == CTYPE_POINTER and
+ symbol.base_type.base_type.type == CTYPE_FUNCTION):
node = self._create_callback(symbol)
- elif symbol.base_type.type == giscanner.CTYPE_STRUCT:
+ elif symbol.base_type.type == CTYPE_STRUCT:
node = self._create_typedef_struct(symbol)
# This prevents an infinite recursion when scanning structures with
# private types not exposed in headers.
- elif symbol.base_type.type == giscanner.CSYMBOL_TYPE_TYPEDEF:
+ elif symbol.base_type.type == CSYMBOL_TYPE_TYPEDEF:
return
else:
node = self._traverse_one(symbol, symbol.base_type.type)
return node
- elif stype == giscanner.CSYMBOL_TYPE_STRUCT:
+ elif stype == CSYMBOL_TYPE_STRUCT:
return self._create_struct(symbol)
- elif stype == giscanner.CSYMBOL_TYPE_ENUM:
+ elif stype == CSYMBOL_TYPE_ENUM:
return self._create_enum(symbol)
- elif stype == giscanner.CSYMBOL_TYPE_OBJECT:
+ elif stype == CSYMBOL_TYPE_OBJECT:
return self._create_object(symbol)
- elif stype == giscanner.CSYMBOL_TYPE_UNION:
+ elif stype == CSYMBOL_TYPE_UNION:
# Unions are not supported
pass
else:
raise NotImplementedError(
'Transformer: unhandled symbol: %r of type %r'
- % (symbol.ident, giscanner.symbol_type_name(stype)))
+ % (symbol.ident, symbol_type_name(stype)))
def _create_enum(self, symbol):
members = []
@@ -117,13 +119,13 @@
def _create_source_type(self, source_type):
if source_type is None:
return 'None'
- if source_type.type == giscanner.CTYPE_VOID:
+ if source_type.type == CTYPE_VOID:
value = 'void'
- elif source_type.type == giscanner.CTYPE_BASIC_TYPE:
+ elif source_type.type == CTYPE_BASIC_TYPE:
value = source_type.name
- elif source_type.type == giscanner.CTYPE_TYPEDEF:
+ elif source_type.type == CTYPE_TYPEDEF:
value = source_type.name
- elif source_type.type == giscanner.CTYPE_POINTER:
+ elif source_type.type == CTYPE_POINTER:
value = self._create_source_type(source_type.base_type) + '*'
else:
print 'BUILDER: Unhandled source type: %d' % (source_type.type,)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]