加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

delphi – 如何发布RTL单元的私有类函数?

发布时间:2020-12-15 04:10:38 所属栏目:大数据 来源:网络整理
导读:Delphi XE3,System.Rtti.pas 我需要访问两个私有类函数,但我已经读过如果我修改RTL单元的接口部分,那么我需要重新编译所有的RTL.不适合胆小的心! 两个私有类函数在System.Rtti.pas中: class function GetNameT{: enum}(AValue: T): string; reintroduce; s
Delphi XE3,System.Rtti.pas

我需要访问两个私有类函数,但我已经读过如果我修改RTL单元的接口部分,那么我需要重新编译所有的RTL.不适合胆小的心!

两个私有类函数在System.Rtti.pas中:

class function GetName<T{: enum}>(AValue: T): string; reintroduce; static;
    class function GetValue<T{: enum}>(const AName: string): T; static;

System.Rtti.pas

TRttiEnumerationType = class(TRttiOrdinalType)
  private
    function GetMaxValue: Longint; override;
    function GetMinValue: Longint; override;
    function GetUnderlyingType: TRttiType;
    constructor Create(APackage: TRttiPackage; AParent: TRttiObject; var P: PByte); override;
    {$HINTS OFF}
    function GetNames: TArray<string>;
    class function GetName<T{: enum}>(AValue: T): string; reintroduce; static;
    class function GetValue<T{: enum}>(const AName: string): T; static;
    {$HINTS ON}
  public
    property UnderlyingType: TRttiType read GetUnderlyingType;
  end;

解决方法

您的选择包括:

>重新编译整个RTL.
>使用RTTI访问私有方法.
>向暴露函数的RTTI单元添加新类.我记得,在接口部分添加类型或函数不会强制完全重新编译RTL.
>在RTTI单元外部自己实现功能.例如,请参阅此处的答案:Generic functions for converting an enumeration to string and back.>使用类帮助程序破解私有化,如LURD的回答所述.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读