Did I find the right examples for you? yes no

All Samples(36)  |  Call(29)  |  Derive(0)  |  Import(7)

src/p/l/plexnet-HEAD/third_party/generic/pypy/pypy/jit/tl/spli/serializer.py   plexnet(Download)
from pypy.jit.tl.spli.objects import Int, Str, spli_None
from pypy.jit.tl.spli.pycode import Code
from pypy.rlib.rstruct.runpack import runpack
import struct
 
def unserialize_str(data, start):
    end_lgt = start + int_lgt
    lgt = runpack('i', data[start:end_lgt])
    assert lgt >= 0
    end_str = end_lgt + lgt
def unserialize_const(c, start):
    assert start >= 0
    if c[start] == 'd':
        end = start + int_lgt + 1
        intval = runpack('i', c[start + 1:end])
def unserialize_consts(constrepr):
    pos = int_lgt
    consts_w = []
    num = runpack('i', constrepr[:int_lgt])
    for i in range(num):
def unserialize_code(coderepr, start=0):
    coderepr = coderepr[start:]
    header = coderepr[:header_lgt]
    argcount, nlocals, stacksize, code_len = runpack(FMT, header)
    assert code_len >= 0

src/s/y/Sypy-HEAD/jit/tl/spli/serializer.py   Sypy(Download)
from pypy.jit.tl.spli.objects import Int, Str, spli_None
from pypy.jit.tl.spli.pycode import Code
from pypy.rlib.rstruct.runpack import runpack
import struct
 
def unserialize_str(data, start):
    end_lgt = start + int_lgt
    lgt = runpack('i', data[start:end_lgt])
    assert lgt >= 0
    end_str = end_lgt + lgt
def unserialize_const(c, start):
    assert start >= 0
    if c[start] == 'd':
        end = start + int_lgt + 1
        intval = runpack('i', c[start + 1:end])
def unserialize_consts(constrepr):
    pos = int_lgt
    consts_w = []
    num = runpack('i', constrepr[:int_lgt])
    for i in range(num):
def unserialize_code(coderepr, start=0):
    coderepr = coderepr[start:]
    header = coderepr[:header_lgt]
    argcount, nlocals, stacksize, code_len = runpack(FMT, header)
    assert code_len >= 0

src/s/y/Sypy-HEAD/module/cpyext/floatobject.py   Sypy(Download)
def _PyFloat_Unpack4(space, ptr, le):
    input = rffi.charpsize2str(ptr, 4)
    if rffi.cast(lltype.Signed, le):
        return runpack.runpack("<f", input)
    else:
        return runpack.runpack(">f", input)
def _PyFloat_Unpack8(space, ptr, le):
    input = rffi.charpsize2str(ptr, 8)
    if rffi.cast(lltype.Signed, le):
        return runpack.runpack("<d", input)
    else:
        return runpack.runpack(">d", input)

src/p/l/plexnet-HEAD/third_party/generic/pypy/pypy/rlib/rzipfile.py   plexnet(Download)
 
from zipfile import ZIP_STORED, ZIP_DEFLATED
from pypy.rlib.streamio import open_file_as_stream
from pypy.rlib.rstruct.runpack import runpack
from pypy.rlib.rarithmetic import r_uint, intmask
    assert start > 0
    if data[0:4] == stringEndArchive and data[start:] == "\000\000":
        endrec = runpack(structEndArchive, data)
        return EndRecStruct(endrec, "", filesize - 22)
    # Search the last END_BLOCK bytes of the file for the record signature.
    start = data.rfind(stringEndArchive)
    if start >= 0:     # Correct signature string was found
        endrec = runpack(structEndArchive, data[start:start+22])
        comment = data[start+22:]
        if endrec[7] == len(comment):     # Comment length checks out
            if centdir[0:4] != stringCentralDir:
                raise BadZipfile, "Bad magic number for central directory"
            centdir = runpack(structCentralDir, centdir)
            filename = fp.read(centdir[_CD_FILENAME_LENGTH])
            # Create ZipInfo instance to store file information
            if fheader[0:4] != stringFileHeader:
                raise BadZipfile, "Bad magic number for file header"
            fheader = runpack(structFileHeader, fheader)
            # file_offset is computed here, since the extra field for
            # the central directory and for the local file header

src/s/y/Sypy-HEAD/rlib/rzipfile.py   Sypy(Download)
 
from zipfile import ZIP_STORED, ZIP_DEFLATED
from pypy.rlib.streamio import open_file_as_stream
from pypy.rlib.rstruct.runpack import runpack
from pypy.rlib.rarithmetic import r_uint, intmask
    assert start > 0
    if data[0:4] == stringEndArchive and data[start:] == "\000\000":
        endrec = runpack(structEndArchive, data)
        return EndRecStruct(endrec, "", filesize - 22)
    # Search the last END_BLOCK bytes of the file for the record signature.
    start = data.rfind(stringEndArchive)
    if start >= 0:     # Correct signature string was found
        endrec = runpack(structEndArchive, data[start:start+22])
        comment = data[start+22:]
        if endrec[7] == len(comment):     # Comment length checks out
            if centdir[0:4] != stringCentralDir:
                raise BadZipfile, "Bad magic number for central directory"
            centdir = runpack(structCentralDir, centdir)
            filename = fp.read(centdir[_CD_FILENAME_LENGTH])
            # Create ZipInfo instance to store file information
            if fheader[0:4] != stringFileHeader:
                raise BadZipfile, "Bad magic number for file header"
            fheader = runpack(structFileHeader, fheader)
            # file_offset is computed here, since the extra field for
            # the central directory and for the local file header

src/s/y/Sypy-HEAD/module/micronumpy/types.py   Sypy(Download)
from pypy.rlib.rarithmetic import widen, byteswap
from pypy.rpython.lltypesystem import lltype, rffi
from pypy.rlib.rstruct.runpack import runpack
from pypy.tool.sourcetools import func_with_new_name
from pypy.rlib import jit
    def runpack_str(self, s):
        return self.box(runpack(self.format_code, s))
 
    def pack_str(self, box):
        return struct.pack(self.format_code, self.unbox(box))

src/p/l/plexnet-HEAD/third_party/generic/pypy/pypy/rlib/test/test_rstruct.py   plexnet(Download)
 
from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
from pypy.rlib.rstruct.runpack import runpack
import struct
 
class BaseTestRStruct(BaseRtypingTest):
    def test_unpack(self):
        def fn():
            return runpack('sll', 'a\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00')[1]
        def fn():
            a, b, c, d = runpack('iiii', data)
            return a * 1000 + b * 100 + c * 10 + d
 
        assert fn() == 124
        def fn():
            return runpack('i', data)
        assert fn() == 123
        assert self.interpret(fn, []) == 123
 

src/s/y/Sypy-HEAD/rlib/test/test_rstruct.py   Sypy(Download)
 
from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
from pypy.rlib.rstruct.runpack import runpack
from pypy.rlib.rstruct import ieee
from pypy.rlib.rarithmetic import LONG_BIT
        def fn():
            return runpack('sll', 'a'+pad+'\x03'+pad+'\x04'+pad)[1]
        assert fn() == 3
        assert self.interpret(fn, []) == 3
 
    def test_unpack_2(self):
        data = struct.pack('iiii', 0, 1, 2, 4)
 
        def fn():
            a, b, c, d = runpack('iiii', data)
        def fn():
            return runpack('i', data)
        assert fn() == 123
        assert self.interpret(fn, []) == 123