Anthony Asterisk
unread,Mar 5, 2013, 10:07:20 PM3/5/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to const...@googlegroups.com
In all of my testing I have never seen the alleged _ in the context. I need access to the parent container to make this code work but _ just isn't there. Whats wrong ?
I'm using Construct 2.5
Here is my example code:
#PrintContext taken from the Construct documentation
from construct import *
class PrintContext(Construct):
def _parse(self, stream, context):
print contex
event_opcode = Enum(Byte('event_opcode'),
Event1=0x3e,
Event2 = 0xff
)
param_len = OneOf(Byte("param_len"), range(256))
test_end = Struct("LE_Test_End_Command",
Embed(event_status_struct),
ULInt16("pkt_count"),
)
hci_event = Struct("hci_event",
event_opcode,
param_len,
Switch("event_params", lambda ctx: ctx["event_opcode"],
{
"Event1": Struct("event1",
PrintContext("abc"),
Byte("flow_control"),
cmd_opcode,
Switch("cmd_response", lambda ctx: ctx["cmd_opcode"],
{
"test_end": test_end,
},
default = Struct("generic_event",
Embed(event_status_struct),
Bytes("resp_params", do_this),
)
),
),
"vendor_specific": vendor_event_struct,
}
),
)