ddablib / envvars

Environment Variables Unit
1 stars 2 forks source link

Move enumerator callback types into TPJEnvironmentVars #7

Closed delphidabbler closed 2 years ago

delphidabbler commented 2 years ago

Once the component is removed (issue #1) the enumerator callback type definitions apply only to TPJEnvironmentVars. It would therefore make sense to move them inside the class. We could also take the opportunity to rename them. E.g.

type
  TPJEnvironmentVars = class(TObject)
  // ...
  public
    type
      TEnumNamesCallback = reference to procedure(const VarName: string; Data: Pointer);
      TEnumVarsCallback = reference to procedure(const EnvVar: TPJEnvironmentVar; Data: Pointer);
    // ...
    class procedure EnumNames(Callback: TEnumNamesCallback; Data: Pointer);
    class procedure EnumVars(Callback: TEnumVarsCallback; Data: Pointer);
  end;

The old TPJEnvVarsEnum and TPJEnvVarsEnumEx types could either be removed or be deprecated and redefined as follows (after TPJEnvironmentVars):

type
  TPJEnvVarsEnum = TPJEnvironmentVars.TEnumNamesCallback deprecated;
  TPJEnvVarsEnumEx = TPJEnvironmentVars.TEnumVarsCallback deprecated;
delphidabbler commented 2 years ago

Issue #6 affects the changes proposed here significantly. See the comments to issue #6 for details.