this repo has no description
at trunk 35 lines 1.0 kB view raw
1// Copyright (c) Facebook, Inc. and its affiliates. (http://www.facebook.com) 2#include "builtins.h" 3#include "frame.h" 4#include "globals.h" 5#include "modules.h" 6#include "objects.h" 7#include "runtime.h" 8 9namespace py { 10 11RawObject FUNC(_weakref, _proxy_check)(Thread* thread, Arguments args) { 12 HandleScope scope(thread); 13 Object obj(&scope, args.get(0)); 14 return Bool::fromBool(obj.isWeakProxy() || obj.isWeakCallableProxy()); 15} 16 17RawObject FUNC(_weakref, _weakref_hash)(Thread* thread, Arguments args) { 18 HandleScope scope(thread); 19 Object self_obj(&scope, args.get(0)); 20 Runtime* runtime = thread->runtime(); 21 if (!runtime->isInstanceOfWeakRef(*self_obj)) { 22 return thread->raiseRequiresType(self_obj, ID(weakref)); 23 } 24 WeakRef self(&scope, args.get(0)); 25 return self.hash(); 26} 27 28RawObject FUNC(_weakref, _weakref_set_hash)(Thread* thread, Arguments args) { 29 HandleScope scope(thread); 30 WeakRef self(&scope, args.get(0)); 31 self.setHash(args.get(1)); 32 return NoneType::object(); 33} 34 35} // namespace py