Author: Ronan Lamy <[email protected]>
Branch: rtyper-stuff
Changeset: r73765:7486044bea6c
Date: 2014-10-04 00:50 +0100
http://bitbucket.org/pypy/pypy/changeset/7486044bea6c/
Log: kill rpython.tool.staticmethods
diff --git a/rpython/rlib/_stacklet_n_a.py b/rpython/rlib/_stacklet_n_a.py
--- a/rpython/rlib/_stacklet_n_a.py
+++ b/rpython/rlib/_stacklet_n_a.py
@@ -1,12 +1,10 @@
from rpython.rlib import _rffi_stacklet as _c
from rpython.rlib import objectmodel, debug
from rpython.rtyper.annlowlevel import llhelper
-from rpython.tool.staticmethods import StaticMethods
-class StackletGcRootFinder:
- __metaclass__ = StaticMethods
-
+class StackletGcRootFinder(object):
+ @staticmethod
def new(thrd, callback, arg):
h = _c.new(thrd._thrd, llhelper(_c.run_fn, callback), arg)
if not h:
@@ -14,20 +12,23 @@
return h
new._annspecialcase_ = 'specialize:arg(1)'
+ @staticmethod
def switch(h):
h = _c.switch(h)
if not h:
raise MemoryError
return h
+ @staticmethod
def destroy(thrd, h):
_c.destroy(thrd._thrd, h)
if objectmodel.we_are_translated():
debug.debug_print("not using a framework GC: "
"stacklet_destroy() may leak")
- is_empty_handle = _c.is_empty_handle
+ is_empty_handle = staticmethod(_c.is_empty_handle)
+ @staticmethod
def get_null_handle():
return _c.null_handle
diff --git a/rpython/rlib/_stacklet_shadowstack.py
b/rpython/rlib/_stacklet_shadowstack.py
--- a/rpython/rlib/_stacklet_shadowstack.py
+++ b/rpython/rlib/_stacklet_shadowstack.py
@@ -3,7 +3,6 @@
from rpython.rtyper.annlowlevel import llhelper
from rpython.rtyper.lltypesystem import lltype, llmemory
from rpython.rtyper.lltypesystem.lloperation import llop
-from rpython.tool.staticmethods import StaticMethods
NULL_SUSPSTACK = lltype.nullptr(llmemory.GCREF.TO)
@@ -68,9 +67,8 @@
return oldsuspstack
-class StackletGcRootFinder:
- __metaclass__ = StaticMethods
-
+class StackletGcRootFinder(object):
+ @staticmethod
def new(thrd, callback, arg):
gcrootfinder.callback = callback
thread_handle = thrd._thrd
@@ -79,6 +77,7 @@
return get_result_suspstack(h)
new._dont_inline_ = True
+ @staticmethod
def switch(suspstack):
# suspstack has a handle to target, i.e. where to switch to
ll_assert(suspstack != gcrootfinder.oldsuspstack,
@@ -91,9 +90,11 @@
return get_result_suspstack(h)
switch._dont_inline_ = True
+ @staticmethod
def is_empty_handle(suspstack):
return not suspstack
+ @staticmethod
def get_null_handle():
return NULL_SUSPSTACK
diff --git a/rpython/rtyper/rstr.py b/rpython/rtyper/rstr.py
--- a/rpython/rtyper/rstr.py
+++ b/rpython/rtyper/rstr.py
@@ -9,7 +9,6 @@
from rpython.rtyper.rfloat import FloatRepr
from rpython.tool.pairtype import pairtype, pair
from rpython.tool.sourcetools import func_with_new_name
-from rpython.tool.staticmethods import StaticMethods
from rpython.rlib.rstring import UnicodeBuilder
@@ -800,10 +799,8 @@
# get flowed and annotated, mostly with SomePtr.
#
-# this class contains low level helpers used both by lltypesystem
-class AbstractLLHelpers:
- __metaclass__ = StaticMethods
-
+class AbstractLLHelpers(object):
+ @staticmethod
def ll_isdigit(s):
from rpython.rtyper.annlowlevel import hlstr
@@ -815,6 +812,7 @@
return False
return True
+ @staticmethod
def ll_isalpha(s):
from rpython.rtyper.annlowlevel import hlstr
@@ -826,6 +824,7 @@
return False
return True
+ @staticmethod
def ll_isalnum(s):
from rpython.rtyper.annlowlevel import hlstr
@@ -837,14 +836,17 @@
return False
return True
+ @staticmethod
def ll_char_isspace(ch):
c = ord(ch)
return c == 32 or (9 <= c <= 13) # c in (9, 10, 11, 12, 13, 32)
+ @staticmethod
def ll_char_isdigit(ch):
c = ord(ch)
return c <= 57 and c >= 48
+ @staticmethod
def ll_char_isalpha(ch):
c = ord(ch)
if c >= 97:
@@ -852,6 +854,7 @@
else:
return 65 <= c <= 90
+ @staticmethod
def ll_char_isalnum(ch):
c = ord(ch)
if c >= 65:
@@ -862,47 +865,54 @@
else:
return 48 <= c <= 57
+ @staticmethod
def ll_char_isupper(ch):
c = ord(ch)
return 65 <= c <= 90
+ @staticmethod
def ll_char_islower(ch):
c = ord(ch)
return 97 <= c <= 122
+ @staticmethod
def ll_upper_char(ch):
if 'a' <= ch <= 'z':
ch = chr(ord(ch) - 32)
return ch
+ @staticmethod
def ll_lower_char(ch):
if 'A' <= ch <= 'Z':
ch = chr(ord(ch) + 32)
return ch
+ @staticmethod
def ll_char_hash(ch):
return ord(ch)
+ @staticmethod
def ll_unichar_hash(ch):
return ord(ch)
+ @classmethod
def ll_str_is_true(cls, s):
# check if a string is True, allowing for None
return bool(s) and cls.ll_strlen(s) != 0
- ll_str_is_true = classmethod(ll_str_is_true)
+ @classmethod
def ll_stritem_nonneg_checked(cls, s, i):
if i >= cls.ll_strlen(s):
raise IndexError
return cls.ll_stritem_nonneg(s, i)
- ll_stritem_nonneg_checked = classmethod(ll_stritem_nonneg_checked)
+ @classmethod
def ll_stritem(cls, s, i):
if i < 0:
i += cls.ll_strlen(s)
return cls.ll_stritem_nonneg(s, i)
- ll_stritem = classmethod(ll_stritem)
+ @classmethod
def ll_stritem_checked(cls, s, i):
length = cls.ll_strlen(s)
if i < 0:
@@ -910,8 +920,8 @@
if i >= length or i < 0:
raise IndexError
return cls.ll_stritem_nonneg(s, i)
- ll_stritem_checked = classmethod(ll_stritem_checked)
+ @staticmethod
def parse_fmt_string(fmt):
# we support x, d, s, f, [r]
it = iter(fmt)
@@ -937,6 +947,7 @@
r.append(curstr)
return r
+ @staticmethod
def ll_float(ll_str):
from rpython.rtyper.annlowlevel import hlstr
from rpython.rlib.rfloat import rstring_to_float
@@ -961,6 +972,7 @@
assert end >= 0
return rstring_to_float(s[beg:end + 1])
+ @classmethod
def ll_splitlines(cls, LIST, ll_str, keep_newlines):
from rpython.rtyper.annlowlevel import hlstr
s = hlstr(ll_str)
@@ -991,4 +1003,3 @@
item = cls.ll_stringslice_startstop(ll_str, j, strlen)
res.ll_setitem_fast(list_length, item)
return res
- ll_splitlines = classmethod(ll_splitlines)
diff --git a/rpython/tool/staticmethods.py b/rpython/tool/staticmethods.py
deleted file mode 100644
--- a/rpython/tool/staticmethods.py
+++ /dev/null
@@ -1,14 +0,0 @@
-import types
-class AbstractMethods(type):
- def __new__(cls, cls_name, bases, cls_dict):
- for key, value in cls_dict.iteritems():
- if isinstance(value, types.FunctionType):
- cls_dict[key] = cls.decorator(value)
- return type.__new__(cls, cls_name, bases, cls_dict)
-
-
-class StaticMethods(AbstractMethods):
- """
- Metaclass that turns plain methods into staticmethods.
- """
- decorator = staticmethod
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit