Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

`stdCallback` refactor

Aperta
#74 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Refactoring
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
visualbasic
Ambito
tooling

Direzione di ricerca

Start by locating stdCallback and comparing its current implementation with the proposed CallbackType, TThis, constructor, Clone, and Bind structure in the issue. Determine the intended refactor boundaries and confirm that the listed callback construction and binding paths remain covered when the reorganization is complete.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement lib-stdCallback

It's time for stdCallback to get a refactor. I feel some aspects are overcomplicated and this is in part because I didn't really know what I was doing when I originally made it.

Structure:

Private Enum CallbackType
  EApplicationRun
  ECallByName
  EDispCallFunc
End Enum
Private Type TThis
  iType as CallbackType
  args() as variant
  vBoundArgs as variant
End Type
Private This as TThis


'Core constructors
Public Function CreateFromRunCommand(ByVal sRunCommand as string) as stdCallback
  set CreateFromRunCommand = new stdCallback
  CreateFromRunCommand.protInit(CallbackType.EApplicationRun, Array(sRunCommand))
End Function
Public Function CreateFromObjectMember(Byval o as object, ByVal sMemberName as string, ByVal cType as vbCallType) as stdCallback
  set CreateFromObjectMember= new stdCallback
  CreateFromObjectMember.protInit(CallbackType.ECallByName, Array(o, sMemberName, cType))
End Function
Public Function CreateFromObjectOffset(ByVal oPtr as LongPtr, ByVal iVTableOffset as LongPtr, ByVal iRetType as vbVarType, ByRef vParamTypes() as vbVarType)
  set CreateFromObjectOffset = new stdCallback
  CreateFromObjectOffset.protInit(CallbackType.EDispCallFunc, Array(oPtr, iVTableOffset, iRetType, vParamTypes)) 
End Function
Public Function Clone() as stdCallback
  set Clone = new stdCallback
  Clone.protInit(This.iType, This.args)
End Function
Public Function Bind(ParamArray vParams()) as stdCallback
  set Bind = Clone()
  Bind.protBindParams(vParams)
End Function


'More specific constructors
Public Function CreateFromModule(sModuleName as string, sMethodName as string)
  set CreateFromModule = CreateFromRunCommand(sModuleName & "." & sMethodName)
End Function
Public Function CreateFromWorkbookModule(sWorkbookPath as string, sModuleName as string, sMethodName as string)
  set CreateFromWorkbookModule = CreateFromRunCommand("'" & sWorkbookPath & "'!" & sModuleName & "." & sMethodName)
End Function
Public Function CreateFromObjectMethod(ByVal o as object, ByVal sMethodName as string)
  set CreateFromObjectMethod = CreateFromObjectMember(o, sMethodName, vbMethod
End Function
Public Function CreateFromObjectProperty(ByVal o as object, ByVal sPropertyName as string, ByVal cType as vbCallType)
  set CreateFromObjectProperty = CreateFromObjectMember(o, sPropertyName, cType)
End Function
Public Function CreateFromFunctionPointer(ByVal iPtr as LongPtr, ByVal iRetType as vbVarType, ByRef vParamTypes() as vbVarType)
  set CreateFromFunctionPointer = CreateFromObjectOffset(NULL_PTR, iPtr, iRetType, vParamTypes)
End Function
Public Function CreateFromDLLFuncByName(ByVal dll as string, ByVal name as string, ...)
  set CreateFromFunctionPointer = CreateFromObjectOffset(NULL_PTR, iPtr, iRetType, vParamTypes)
End Function
Public Function CreateFromDLLFuncByIndex(ByVal dll as string, ByVal idx as Long, ...)
  set CreateFromFunctionPointer = CreateFromObjectOffset(NULL_PTR, iPtr, iRetType, vParamTypes)
End Function


'@protected
Friend Sub protInit(ByVal iType as Long, vArgs() as variant)
  This.iType = iType
  This.args = vArgs
  This.vBoundArgs  = Null
End Sub
Lingua principale
VBA
Stelle
412
Fork
70
Merge medio
16h 10m
PR unite (30g)
3

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di sancarn/stdVBA

Tutte le issue di sancarn/stdVBA

Issue simili

Altre issue su DevTools

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.