![]() |
Delphi-Version: XE7
Helfer funktioniert nicht bei statischen Record-Methoden
Wie komme ich mit einem Record-Helfer an private statische Methoden des Records?
Delphi-Quellcode:
type
TSomeRecord = record strict private procedure instanceMethod(); strict private class procedure StaticMethod(); static; end; TSomeRecordHelper = record helper for TSomeRecord public procedure _instanceMethod(); public class procedure _StaticMethod(); static; end; TMyObject = class(TObject) strict private class procedure StaticMethod(); virtual; abstract; end; { TSomeRecord } procedure TSomeRecord.instanceMethod(); begin // end; class procedure TSomeRecord.StaticMethod(); begin // end; { TSomeRecordHelper } procedure TSomeRecordHelper._instanceMethod(); begin self.instanceMethod(); // Das klappt schonmal... end; class procedure TSomeRecordHelper._StaticMethod(); begin //self.StaticMethod(); // E2003: Undeklarierter Bezeichner "self" //StaticMethod(); // E2003: Undeklarierter Bezeichner "StaticMethod" //TSomeRecord.StaticMethod(); // E2361 Auf private-Symbol TSomeRecord.StaticMethod kann nicht zugegriffen werden //inherited StaticMethod(); // E2075 Diese Form des Methodenaufrufs ist nur in Methoden von abgeleiteten Typen erlaubt raise EProgrammerNotFound.Create('Delphi-Praxis, zu Hilfe!'); end; |
AW: Helfer funktioniert nicht bei statischen Record-Methoden
Delphi-Quellcode:
type
TSomeRecord = record strict private class procedure StaticMethod(); static; end; TSomeRecordHelper = record helper for TSomeRecord private procedure __StaticMethod(); inline; public class procedure _StaticMethod(); static; inline; end; { TSomeRecord } class procedure TSomeRecord.StaticMethod(); begin // end; { TSomeRecordHelper } class procedure TSomeRecordHelper._StaticMethod(); var Self: TSomeRecord; begin Self.__StaticMethod; end; procedure TSomeRecordHelper.__StaticMethod; begin TSomeRecord.StaticMethod; end; |
AW: Helfer funktioniert nicht bei statischen Record-Methoden
Ok, tatsächlich nur so. Danke.
PS: Warum das explizite inlining? |
AW: Helfer funktioniert nicht bei statischen Record-Methoden
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:03 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz