@@ -619,40 +619,34 @@ def virtual_function(
619619 if return_type not in DataType .values :
620620 return_type = self .create_converter (return_type )
621621
622+ # Store the function cache
622623 funcs = {}
623624
624- class fget (object ):
625- def __set_name__ (fget_self , owner , name ):
626- fget_self .name = name
627-
628- def __get__ (fget_self , obj , cls = None ):
629- """Return the virtual function."""
630- if obj is None :
631- return fget_self
632-
633- # Get the vtable address
634- address = obj ._ptr ().get_pointer ().address
635- # Search function cache by vtable address
636- func = funcs .get (address , None )
637-
638- if func is None :
639- # Create the virtual function cache it
640- func = obj .make_virtual_function (
641- index ,
642- convention ,
643- args ,
644- return_type
645- )
646- funcs [address ] = func
625+ def fget (ptr ):
626+ """Return the virtual function."""
627+ # Get the vtable address
628+ address = ptr ._ptr ().get_pointer ().address
629+ # Search function cache by vtable address
630+ func = funcs .get (address , None )
631+
632+ if func is None :
633+ # Create the virtual function cache it
634+ func = ptr .make_virtual_function (
635+ index ,
636+ convention ,
637+ args ,
638+ return_type
639+ )
640+ funcs [address ] = func
647641
648- # Wrap it using MemberFunction, so we don't have to pass the this
649- # pointer anymore
650- func = MemberFunction (self , return_type , func , obj )
651- func .__doc__ = doc
642+ # Wrap it using MemberFunction, so we don't have to pass the this
643+ # pointer anymore
644+ m_func = MemberFunction (self , return_type , func , ptr )
645+ m_func .__doc__ = doc
652646
653- return func
647+ return m_func
654648
655- return fget ( )
649+ return property ( fget , None , None , doc )
656650
657651 def function (
658652 self , identifier , args = (), return_type = DataType .VOID ,
@@ -669,9 +663,6 @@ def function(
669663 func = None
670664
671665 class fget (object ):
672- def __set_name__ (fget_self , owner , name ):
673- fget_self .name = name
674-
675666 def __get__ (fget_self , obj , cls = None ):
676667 nonlocal func
677668 if cls is None :
@@ -697,8 +688,8 @@ def __get__(fget_self, obj, cls=None):
697688
698689 # Called with a this pointer?
699690 if obj is not None :
700- # Wrap the function using MemberFunction,
701- # so we don't have to pass the this pointer anymore
691+ # Wrap the function using MemberFunction, so we don't have
692+ # to pass the this pointer anymore
702693 m_func = MemberFunction (self , return_type , func , obj )
703694 m_func .__doc__ = doc
704695
0 commit comments