@@ -619,40 +619,34 @@ def virtual_function(
619
619
if return_type not in DataType .values :
620
620
return_type = self .create_converter (return_type )
621
621
622
+ # Store the function cache
622
623
funcs = {}
623
624
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
647
641
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
652
646
653
- return func
647
+ return m_func
654
648
655
- return fget ( )
649
+ return property ( fget , None , None , doc )
656
650
657
651
def function (
658
652
self , identifier , args = (), return_type = DataType .VOID ,
@@ -669,9 +663,6 @@ def function(
669
663
func = None
670
664
671
665
class fget (object ):
672
- def __set_name__ (fget_self , owner , name ):
673
- fget_self .name = name
674
-
675
666
def __get__ (fget_self , obj , cls = None ):
676
667
nonlocal func
677
668
if cls is None :
@@ -697,8 +688,8 @@ def __get__(fget_self, obj, cls=None):
697
688
698
689
# Called with a this pointer?
699
690
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
702
693
m_func = MemberFunction (self , return_type , func , obj )
703
694
m_func .__doc__ = doc
704
695
0 commit comments