瀏覽代碼

Update pocketpy.h

blueloveTH 3 年之前
父節點
當前提交
cd6484a61a
共有 1 個文件被更改,包括 3 次插入8 次删除
  1. 3 8
      src/pocketpy.h

+ 3 - 8
src/pocketpy.h

@@ -520,20 +520,15 @@ void add_module_time(VM* vm){
 
 void add_module_sys(VM* vm){
     PyVar mod = vm->new_module("sys");
-    vm->bind_func<1>(mod, "getrefcount", [](VM* vm, const pkpy::Args& args) {
-        return vm->PyInt(args[0].use_count());
-    });
+    vm->setattr(mod, "version", vm->PyStr(PK_VERSION));
 
-    vm->bind_func<0>(mod, "getrecursionlimit", [](VM* vm, const pkpy::Args& args) {
-        return vm->PyInt(vm->maxRecursionDepth);
-    });
+    vm->bind_func<1>(mod, "getrefcount", CPP_LAMBDA(vm->PyInt(args[0].use_count())));
+    vm->bind_func<0>(mod, "getrecursionlimit", CPP_LAMBDA(vm->PyInt(vm->maxRecursionDepth)));
 
     vm->bind_func<1>(mod, "setrecursionlimit", [](VM* vm, const pkpy::Args& args) {
         vm->maxRecursionDepth = (int)vm->PyInt_AS_C(args[0]);
         return vm->None;
     });
-
-    vm->setattr(mod, "version", vm->PyStr(PK_VERSION));
 }
 
 void add_module_json(VM* vm){