mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
...
This commit is contained in:
parent
61f837ac2c
commit
49f70318d9
@ -259,4 +259,13 @@ def help(obj):
|
|||||||
|
|
||||||
class Exception: pass
|
class Exception: pass
|
||||||
|
|
||||||
|
|
||||||
|
class classmethod:
|
||||||
|
def __init__(self, f):
|
||||||
|
self.f = f
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def staticmethod(f):
|
||||||
|
return f
|
||||||
|
|
||||||
from _long import long
|
from _long import long
|
@ -192,10 +192,6 @@ void init_builtins(VM* _vm) {
|
|||||||
return VAR(PK_BITS(obj));
|
return VAR(PK_BITS(obj));
|
||||||
});
|
});
|
||||||
|
|
||||||
_vm->bind_builtin_func<1>("staticmethod", [](VM* vm, ArgsView args) {
|
|
||||||
return args[0];
|
|
||||||
});
|
|
||||||
|
|
||||||
_vm->bind_builtin_func<1>("callable", [](VM* vm, ArgsView args) {
|
_vm->bind_builtin_func<1>("callable", [](VM* vm, ArgsView args) {
|
||||||
PyObject* cls = vm->_t(args[0]);
|
PyObject* cls = vm->_t(args[0]);
|
||||||
Type t = PK_OBJ_GET(Type, cls);
|
Type t = PK_OBJ_GET(Type, cls);
|
||||||
|
@ -118,20 +118,20 @@ except:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------
|
|
||||||
# 114: 188: _vm->bind_builtin_func<1>("staticmethod", [](VM* vm, ArgsView args) {
|
|
||||||
# #####: 189: return args[0];
|
|
||||||
# -: 190: });
|
|
||||||
# test staticmethod:
|
|
||||||
class A():
|
class A():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.a = 1
|
self.a = 1
|
||||||
|
|
||||||
@ staticmethod
|
@staticmethod
|
||||||
def static_method(txt):
|
def static_method(txt):
|
||||||
return txt
|
return txt
|
||||||
|
|
||||||
|
# @classmethod
|
||||||
|
# def class_method(cls, txt):
|
||||||
|
# return cls.__name__ + txt
|
||||||
|
|
||||||
assert A.static_method(123) == 123
|
assert A.static_method(123) == 123
|
||||||
|
# assert A.class_method(123) == 'A123'
|
||||||
|
|
||||||
# 无法测试 -----------------------------------------------
|
# 无法测试 -----------------------------------------------
|
||||||
# 248: 192: _vm->bind_builtin_func<1>("__import__", [](VM* vm, ArgsView args) {
|
# 248: 192: _vm->bind_builtin_func<1>("__import__", [](VM* vm, ArgsView args) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user