[Xcb] _Problems_ in GSoC, 2011
vikash agrawal
vikashagrawal1990 at gmail.com
Wed Jul 6 08:35:38 PDT 2011
[ Sorry for the hindrance ]
On Tue, Jul 5, 2011 at 12:18 AM, Jamey Sharp <jamey at minilop.net> wrote:
> On Mon, Jul 04, 2011 at 03:42:24AM +0530, vikash agrawal wrote:
> > Also it has been long I am trying to patch a bug, I had several
> discussion
> > with pharris ( I apologise for pestering you so much ) over the same. I
> am
> > still studying c_client.py and a quick glance of it reveals
> > '_c_serialize_helper_insert_ function', with context being sizeof, is
> > responsible for xcb_str_sizeof in xproto.c. So I believe this might need
> > some hacks.
> > Also, if I am not wrong there is a problem with xcb_str_next with respect
> > master and 1.7, but for this I have a very n00b and basic idea like if
> > self.c_next_name == 'xcb_str_next': # and then necessary conditions of
> > _c('whatever'); might solve the purpose. If this feels a way then can we
> > specifically do the same for other buggy issues.
>
> I'm sorry to say, the problem is not specific to xcb_str_next or to
> strings at all. The good news is that it should be solvable in a general
> way, without hacks for specific types. I wrote some about this here:
>
> http://lists.freedesktop.org/archives/xcb/2011-March/006837.html
>
> Here is a sketch of an algorithm that I believe is correct for
> statically computing alignment padding for all X types. I'll use the
> terms from xcbgen/xtypes.py.
>
> First, compute the minimum alignment requirement for every type:
>
> - For every SimpleType and ExprType, including the standard types like
> CARD8, the alignment required equals the size of the type, but no more
> than 4 bytes. So CARD8 needs 1 byte, INT16 needs 2 bytes, FLOAT needs
> 4 bytes, and DOUBLE also needs 4 bytes.
>
> - For ListTypes, the alignment is the same as the member type's
> alignment.
>
> - Request, Reply, Event, and Error types always have 4-byte alignment.
>
> - For StructType and UnionType, the alignment is the maximum alignment
> needed by any field in the struct or union. So STR, which is a struct
> containing a CARD8 and a list of CARD8, only needs 1-byte alignment;
> but a struct containing an INT16 and a DOUBLE needs 4-byte alignment.
>
> I haven't thought about the rules for Switch or Bitcase yet.
>
> I think implementing the above in proto/xcbgen would be a good target
> for something to finish by the time of the mid-term review. The rest of
> the algorithm is below.
>
>
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/0af3fda4/attachment-0001.htm>
More information about the Xcb
mailing list