Ejemplo n.º 1
0
Archivo: types.py Proyecto: ahom/binr
 def closure(ctx, *args, **kwargs):
     return binr.call_struct(
         ctx, 
         lambda c: struct_def.unpack(c.read(struct_def.size))[0], 
         name, 
         *args, 
         **kwargs
     )
Ejemplo n.º 2
0
Archivo: types.py Proyecto: ahom/binr
def enumerate_array(ctx, child_struct, count, *args, **kwargs):
    def unroll(c, item_count, *unroll_args, **unroll_kwargs):
        return [child_struct(c, i, *unroll_args, **unroll_kwargs) for i in range(item_count)]
    return binr.call_struct(ctx, unroll, 'enumerate_array<{}>'.format(child_struct.__name__), count, *args, **kwargs)