コード例 #1
0
ファイル: model.py プロジェクト: xx312022850/pypy
#  \  \                     -5   _____/                      /
#   \  \________________________/              3.1416       /
#    \_____________________________________________________/
#

from types import BuiltinFunctionType, MethodType, FunctionType
import pypy
from pypy.tool import descriptor
from pypy.tool.pairtype import pair, extendabletype
from pypy.tool.tls import tlsobject
from pypy.rlib.rarithmetic import r_uint, r_ulonglong, base_int
from pypy.rlib.rarithmetic import r_singlefloat
import inspect, weakref

DEBUG = False  # set to False to disable recording of debugging information
TLS = tlsobject()


class SomeObject:
    """The set of all objects.  Each instance stands
    for an arbitrary object about which nothing is known."""
    __metaclass__ = extendabletype
    knowntype = object
    immutable = False

    def __eq__(self, other):
        return (self.__class__ is other.__class__
                and self.__dict__ == other.__dict__)

    def __ne__(self, other):
        return not (self == other)
コード例 #2
0
ファイル: ll2ctypes.py プロジェクト: antoine1fr/pygirl
    def specialize_call(self, hop):
        hop.exception_cannot_occur()
        v_ptr, v_n = hop.inputargs(hop.args_r[0], lltype.Signed)
        return hop.genop('direct_ptradd', [v_ptr, v_n],
                         resulttype = v_ptr.concretetype)

# ____________________________________________________________
# errno

# this saves in a thread-local way the "current" value that errno
# should have in C.  We have to save it away from one external C function
# call to the next.  Otherwise a non-zero value left behind will confuse
# CPython itself a bit later, and/or CPython will stamp on it before we
# try to inspect it via rposix.get_errno().
TLS = tlsobject()

# helpers to save/restore the C-level errno -- platform-specific because
# ctypes doesn't just do the right thing and expose it directly :-(
def _where_is_errno():
    raise NotImplementedError("don't know how to get the C-level errno!")

def _save_c_errno():
    errno_p = _where_is_errno()
    TLS.errno = errno_p.contents.value
    errno_p.contents.value = 0

def _restore_c_errno():
    if hasattr(TLS, 'errno'):
        _where_is_errno().contents.value = TLS.errno