@@ -412,14 +412,14 @@ def __init__(self):
412412 self ._applications = list ()
413413
414414 @staticmethod
415- def _ReleaseImpl (pUnk :"IUnknown" ):
415+ def _release_impl (pUnk :"IUnknown" ):
416416 """Call Release in STK."""
417- _CreateAgObjectLifetimeManager ._Release (pUnk ._getVtblEntry (_CreateAgObjectLifetimeManager ._ReleaseIndex ))(pUnk .p )
417+ _CreateAgObjectLifetimeManager ._Release (pUnk ._get_vtbl_entry (_CreateAgObjectLifetimeManager ._ReleaseIndex ))(pUnk .p )
418418
419419 @staticmethod
420- def _AddRefImpl (pUnk :"IUnknown" ):
420+ def _add_ref_impl (pUnk :"IUnknown" ):
421421 """Call AddRef in STK."""
422- _CreateAgObjectLifetimeManager ._AddRef (pUnk ._getVtblEntry (_CreateAgObjectLifetimeManager ._AddRefIndex ))(pUnk .p )
422+ _CreateAgObjectLifetimeManager ._AddRef (pUnk ._get_vtbl_entry (_CreateAgObjectLifetimeManager ._AddRefIndex ))(pUnk .p )
423423
424424 def create_ownership (self , pUnk :"IUnknown" ):
425425 """
@@ -429,7 +429,7 @@ def create_ownership(self, pUnk:"IUnknown"):
429429 """
430430 ptraddress = pUnk .p .value
431431 if ptraddress is not None :
432- _CreateAgObjectLifetimeManager ._AddRefImpl (pUnk )
432+ _CreateAgObjectLifetimeManager ._add_ref_impl (pUnk )
433433 self .take_ownership (pUnk , False )
434434
435435 def take_ownership (self , pUnk :"IUnknown" , isApplication = False ):
@@ -444,19 +444,19 @@ def take_ownership(self, pUnk:"IUnknown", isApplication=False):
444444 if isApplication :
445445 self ._applications .append (ptraddress )
446446 if ptraddress in self ._ref_counts :
447- _CreateAgObjectLifetimeManager ._ReleaseImpl (pUnk )
448- self .InternalAddRef (pUnk )
447+ _CreateAgObjectLifetimeManager ._release_impl (pUnk )
448+ self .internal_add_ref (pUnk )
449449 else :
450450 self ._ref_counts [ptraddress ] = 1
451451
452- def InternalAddRef (self , pUnk :"IUnknown" ):
452+ def internal_add_ref (self , pUnk :"IUnknown" ):
453453 """Increment the internal reference count of pUnk."""
454454 ptraddress = pUnk .p .value
455455 with _GCDisabler () as gc_lock :
456456 if ptraddress in self ._ref_counts :
457457 self ._ref_counts [ptraddress ] = self ._ref_counts [ptraddress ] + 1
458458
459- def Release (self , pUnk :"IUnknown" ):
459+ def release (self , pUnk :"IUnknown" ):
460460 """
461461 Decrements the internal reference count of pUnk.
462462
@@ -467,12 +467,12 @@ def Release(self, pUnk:"IUnknown"):
467467 with _GCDisabler () as gc_lock :
468468 if ptraddress in self ._ref_counts :
469469 if self ._ref_counts [ptraddress ] == 1 :
470- _CreateAgObjectLifetimeManager ._ReleaseImpl (pUnk )
470+ _CreateAgObjectLifetimeManager ._release_impl (pUnk )
471471 del (self ._ref_counts [ptraddress ])
472472 else :
473473 self ._ref_counts [ptraddress ] = self ._ref_counts [ptraddress ] - 1
474474
475- def ReleaseAll (self , releaseApplication = True ):
475+ def release_all (self , releaseApplication = True ):
476476 with _GCDisabler () as gc_lock :
477477 preserved_app_ref_counts = dict ()
478478 while len (self ._ref_counts ) > 0 :
@@ -483,7 +483,7 @@ def ReleaseAll(self, releaseApplication=True):
483483 continue
484484 pUnk = IUnknown ()
485485 pUnk .p = c_void_p (ptraddress )
486- _CreateAgObjectLifetimeManager ._ReleaseImpl (pUnk )
486+ _CreateAgObjectLifetimeManager ._release_impl (pUnk )
487487 pUnk .p = c_void_p (0 )
488488 self ._ref_counts = preserved_app_ref_counts
489489
@@ -528,26 +528,26 @@ class IUnknown(object):
528528 def __init__ (self , pUnk = None ):
529529 if pUnk is not None :
530530 self .p = pUnk .p
531- self .AddRef ()
531+ self .add_ref ()
532532 else :
533533 self .p = c_void_p ()
534534 def __del__ (self ):
535535 if self :
536- self .Release ()
536+ self .release ()
537537 def __eq__ (self , other ):
538538 return self .p .value == other .p .value
539539 def __hash__ (self ):
540540 return self .p .value
541541 def __bool__ (self ):
542542 return self .p .value is not None and self .p .value > 0
543- def _getVtblEntry (self , index ):
543+ def _get_vtbl_entry (self , index ):
544544 vptr = cast (self .p , POINTER (c_void_p ))
545545 vtbl = cast (vptr .contents , POINTER (c_void_p ))
546546 return vtbl [index ]
547547 def query_interface (self , iid :GUID | str ) -> "IUnknown" :
548548 pIntf = IUnknown ()
549549 if isinstance (iid , str ): iid = GUID (iid )
550- hr = IUnknown ._QueryInterface (self ._getVtblEntry (IUnknown ._QIIndex ))(self .p , byref (iid ), byref (pIntf .p ))
550+ hr = IUnknown ._QueryInterface (self ._get_vtbl_entry (IUnknown ._QIIndex ))(self .p , byref (iid ), byref (pIntf .p ))
551551 if not Succeeded (hr ):
552552 return None
553553 pIntf .take_ownership ()
@@ -558,18 +558,18 @@ def create_ownership(self):
558558 def take_ownership (self , isApplication = False ):
559559 """Register the pointer to be Released when the ref count goes to zero but does not call AddRef."""
560560 ObjectLifetimeManager .take_ownership (self , isApplication )
561- def AddRef (self ):
561+ def add_ref (self ):
562562 """Increment the ref count if the pointer was registered.
563563
564564 Pointer registration must be done by create_ownership or take_ownership.
565565 """
566- ObjectLifetimeManager .InternalAddRef (self )
567- def Release (self ):
566+ ObjectLifetimeManager .internal_add_ref (self )
567+ def release (self ):
568568 """Decrement the ref count if the pointer was registered. Calls Release if the ref count goes to zero.
569569
570570 Pointer registration must be done by create_ownership or take_ownership.
571571 """
572- ObjectLifetimeManager .Release (self )
572+ ObjectLifetimeManager .release (self )
573573
574574 def invoke (self , intf_metatdata :dict , method_metadata :dict , * args ):
575575 method_offset = intf_metatdata ["method_offsets" ][method_metadata ["name" ]]
@@ -601,9 +601,9 @@ def _invoke_impl(self, intf_metatdata:dict, method_metadata:dict, method_offset:
601601 call_args = []
602602 for marshaller , arg_type in zip (marshallers , arg_types ):
603603 if type (arg_type ) == type (POINTER (PVOID )): # type(POINTER(X)) == type(POINTER(Y)) for all X,Y. the choice of PVOID was arbitrary
604- call_args .append (byref (marshaller .COM_val ))
604+ call_args .append (byref (marshaller .com_val ))
605605 else :
606- call_args .append (marshaller .COM_val )
606+ call_args .append (marshaller .com_val )
607607 evaluate_hresult (method (* call_args ))
608608 return_vals = []
609609 for arg , marshaller in zip (args , marshallers ):
@@ -659,7 +659,7 @@ def __init__(self, pUnk, iid, method_index, *argtypes):
659659 self .index = method_index
660660 self .method = WINFUNCTYPE (HRESULT , LPVOID , * argtypes )
661661 def __call__ (self , * args ):
662- pIntf = self .pUnk .query_interface (self .iid )
663- ret = self .method (pIntf ._getVtblEntry (self .index ))(pIntf .p , * args )
662+ pIntf : IUnknown = self .pUnk .query_interface (self .iid )
663+ ret = self .method (pIntf ._get_vtbl_entry (self .index ))(pIntf .p , * args )
664664 del (pIntf )
665665 return ret
0 commit comments