[Xcb] _Problems_ in GSoC, 2011
vikash agrawal
vikashagrawal1990 at gmail.com
Wed Jul 6 08:33:49 PDT 2011
Hello Everyone,
Thank You Jamey for the reply,
I am facing few problems,
- I am unable to compile xtypes.py with python interpretor. I reciev an
error -> Traceback (most recent call last):
File "workspace/xcb/proto/xcbgen/xtypes.py", line 80, in <module>
class SimpleType(Type):
File "workspace/xcb/proto/xcbgen/xtypes.py", line 106, in SimpleType
out = __main__.output['simple']
*AttributeError: 'module' object has no attribute 'output' *and as a
result for every change that I try to bring I need to start from make clean
all over again for both ptroto
- module.resolve keep troubling me whenever I try to introduce something
in the xtypes so how can I resolve those
So far what I have understood/interpreted from your reply I have tried to do
something, ( and its compiling :-) ) and here it is, please review it [ I
have tried to have follow the coding style and tried not not to make any
typo error, still if any prob occur please notify ]
[vikash at localhost proto]$ git diff
diff --git a/xcbgen/xtypes.py b/xcbgen/xtypes.py
index 14c318a..98c6811 100644
--- a/xcbgen/xtypes.py
+++ b/xcbgen/xtypes.py
@@ -34,6 +34,7 @@ class Type(object):
self.is_pad = False
self.is_switch = False
self.is_bitcase = False
+ self.is_align = False
def resolve(self, module):
'''
@@ -89,13 +90,19 @@ class SimpleType(Type):
self.is_simple = True
self.size = size
self.nmemb = 1
+
+ # align should be either equal to self.size or 4
+ self.align = min(self.size, 4)
+ self.is_align = True if self.align else False
+# print self.is_align
+
def resolve(self, module):
self.resolved = True
def fixed_size(self):
return True
-
+
out = __main__.output['simple']
@@ -169,6 +176,15 @@ class ListType(Type):
self.size = member.size if member.fixed_size() else None
self.nmemb = self.expr.nmemb if self.expr.fixed_size() else None
+
+ # Please look over here
+ # align should be between size and 4
+ # What should I take instead of None ?
+ self.align = min (member.size, 4) if member.fixed_size() else None
+ self.is_align = True if self.align else False
+# print self.is_align
+# Also many a time I am recieving self.align = 0
+
def make_member_of(self, module, complex_type, field_type, field_name,
v
if not self.fixed_size():
@@ -231,6 +247,13 @@ class ExprType(Type):
self.size = member.size
self.nmemb = 1
+
+ # align should be either equal to size or 4
+ self.align = min(self.size, 4)
+ self.is_align = True if self.align else False
+ print self.align
+# print self.is_align
+
def resolve(self, module):
if self.resolved:
@@ -273,6 +296,8 @@ class ComplexType(Type):
self.nmemb = 1
self.size = 0
self.lenfield_parent = [self]
+ self.align = []
+
def resolve(self, module):
if self.resolved:
@@ -329,7 +354,8 @@ class ComplexType(Type):
self.calc_size() # Figure out how big we are
self.resolved = True
-
+ self.align_size()
+
def calc_size(self):
self.size = 0
for m in self.fields:
@@ -337,7 +363,6 @@ class ComplexType(Type):
continue
if m.type.fixed_size():
self.size = self.size + (m.type.size * m.type.nmemb)
- else:
self.size = None
break
@@ -346,6 +371,29 @@ class ComplexType(Type):
if not m.type.fixed_size():
return False
return True
+
+ def align_size(self):
+ '''
+ I think this func should work for both StructTypes and UnionTypes
+ '''
+ self.size = 0
+ arr=[]
+ for m in self.fields:
+ if not m.wire:
+ continue
+ if m.type.fixed_size():
+ self.size = self.size + (m.type.size * m.type.nmemb)
+# print 'calc_size',self.size
+ arr.append(self.size)
+# print 'arr', arr
+# print 'max of arr', max(arr)
+ self.align=min(max(arr), 4)
+ print 'align', self.align
+ self.is_align = True
+# return self.size
+
+
+
class SwitchType(ComplexType):
'''
@@ -455,6 +503,7 @@ class Struct(ComplexType):
'''
Derived class representing a struct data type.
'''
+
out = __main__.output['struct']
@@ -518,6 +567,12 @@ class Reply(ComplexType):
def __init__(self, name, elt):
ComplexType.__init__(self, name, elt)
self.is_reply = True
+
+ # align should be equal to 4
+ self.align = 4
+ self.is_align = True if self.is_align else False
+# print self.is_align
+
def resolve(self, module):
if self.resolved:
@@ -542,6 +597,12 @@ class Request(ComplexType):
ComplexType.__init__(self, name, elt)
self.reply = None
self.opcode = elt.get('opcode')
+
+ # align should be equal to 4
+ self.align = 4
+ self.is_align = True if self.align else False
+# print self.is_align
+
for child in list(elt):
if child.tag == 'reply':
@@ -578,6 +639,11 @@ class Event(ComplexType):
def __init__(self, name, elt):
ComplexType.__init__(self, name, elt)
self.opcodes = {}
+
+ # align should be equal to 4
+ self.align = 4
+ self.is_align = True if self.align else False
+# print self.is_align
tmp = elt.get('no-sequence-number')
self.has_seq = (tmp == None or tmp.lower() == 'false' or tmp ==
'0')
@@ -611,7 +677,12 @@ class Error(ComplexType):
def __init__(self, name, elt):
ComplexType.__init__(self, name, elt)
self.opcodes = {}
-
+
+ # align should be equal to 4
+ self.align = 4
+ self.is_align = True if self.align else False
+# print self.is_align
+
def add_opcode(self, opcode, name, main):
self.opcodes[name] = opcode
if main:
Love
Vikash
and waiting for review :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/xcb/attachments/20110706/a2ef21d0/attachment.html>
More information about the Xcb
mailing list