`stdCallback` refactor

オープン
#74 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
リファクタリング
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
visualbasic
領域
tooling

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
VBA
スター
412
フォーク
70
平均マージ
20時間 38分
マージ済み PR(30日)
18

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

sancarn/stdVBA のほかの issue

sancarn/stdVBA の issue をすべて見る

似ている issue

DevTools の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。