def buf_lookup_c_code(proto, defin, name, nd):
 if (nd == 1):
  proto.putln(('#define %s(type, buf, i0, s0) ((type)buf + i0)' % name))
 else:
  args = ', '.join([('i%d, s%d' % (i, i)) for i in range(nd)])
  offset = ' + '.join([('i%d * s%d' % (i, i)) for i in range((nd - 1))])
  proto.putln(('#define %s(type, buf, %s) ((type)((char*)buf + %s) + i%d)' % (name, args, offset, (nd - 1))))

def buf_lookup_c_code ( proto , defin , name , nd ) : if ( nd == 1 ) : proto . putln ( ( '#define %s(type, buf, i0, s0) ((type)buf + i0)' % name ) ) else : args = ', ' . join ( [ ( 'i%d, s%d' % ( i , i ) ) for i in range ( nd ) ] ) offset = ' + ' . join ( [ ( 'i%d * s%d' % ( i , i ) ) for i in range ( ( nd - 1 ) ) ] ) proto . putln ( ( '#define %s(type, buf, %s) ((type)((char*)buf + %s) + i%d)' % ( name , args , offset , ( nd - 1 ) ) ) )
similar to strided lookup .