Commit 459b6b36 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Print GSER representation of SDL internal variables

parent 3947f0f7
......@@ -2,7 +2,7 @@
# Resource object code
#
# Created: Fri Dec 19 22:34:24 2014
# Created: Sat Dec 20 14:16:24 2014
# by: The Resource Compiler for PySide (Qt v4.8.6)
#
# WARNING! All changes made in this file will be lost!
......
......@@ -96,15 +96,25 @@ class sdlHandler(object):
print 'Event!'
for var, (sort, _) in self.proc.variables.viewitems():
# get internal variables, translate them to swig, and print them
print 'Reading variable "{}" of type "{}"'.format(var,
sort.ReferencedTypeName)
typename = sort.ReferencedTypeName.replace('-', '_')
print 'Reading variable "{}" of type "{}"'.format(var, typename)
get_size = getattr(self.dll, "{}_size".format(var))
get_size.restype = ctypes.c_long
get_value = getattr(self.dll, "{}_value".format(var))
get_value.restype = ctypes.c_char_p
size = get_size()
print "size= ", size
#value = get_value()
#as_bytes = ctypes.cast(value,
# ctypes.POINTER((ctypes.c_byte * size)))
value = get_value()
# From the pointer to the value, copy the content in a byte array
# (this is needed to convert the value to SWIG)
as_bytes = ctypes.cast(value,
ctypes.POINTER((ctypes.c_ubyte * size)))
swig_ptr = ASN1.DV.new_byte_SWIG_PTR(size)
for idx in xrange(size):
ASN1.DV.byte_SWIG_PTR_setitem(swig_ptr,
idx,
as_bytes.contents[idx])
asn1_instance = getattr(ASN1, typename)()
setter = getattr(ASN1.DV, "SetDataFor_{}".format(typename))
setter(asn1_instance._ptr, swig_ptr)
gser = asn1_instance.GSER()
print "GSER= '{}'".format(gser)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment