From 375ef406e608c44827b06e39da8ebdff4a9a58f5 Mon Sep 17 00:00:00 2001 From: Armin Rigo Date: Tue, 12 May 2015 16:01:45 +0200 Subject: in-progress --- cffi/cffi_opcode.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'cffi/cffi_opcode.py') diff --git a/cffi/cffi_opcode.py b/cffi/cffi_opcode.py index 7b727d5..0afe495 100644 --- a/cffi/cffi_opcode.py +++ b/cffi/cffi_opcode.py @@ -1,4 +1,3 @@ -import struct class CffiOp(object): def __init__(self, op, arg): @@ -14,12 +13,19 @@ class CffiOp(object): def as_bytes(self): assert self.op is not None - return struct.pack(">i", (self.arg << 8) | self.op) + return format_four_bytes((self.arg << 8) | self.op) def __str__(self): classname = CLASS_NAME.get(self.op, self.op) return '(%s %s)' % (classname, self.arg) +def format_four_bytes(num): + return '\\x%02X\\x%02X\\x%02X\\x%02X' % ( + (num >> 24) & 0xFF, + (num >> 16) & 0xFF, + (num >> 8) & 0xFF, + (num ) & 0xFF) + OP_PRIMITIVE = 1 OP_POINTER = 3 OP_ARRAY = 5 -- cgit v1.2.1