gpt4 book ai didi

delphi - 什么是内部错误E5912

转载 作者:行者123 更新时间:2023-12-03 19:11:17 25 4
gpt4 key购买 nike

我在这里问一个问题,我从加文·沃特金森那里得到了答案。

我创建了单位:

interface

uses
OmniXML, OmniXMLProperties;

type
TRow = class(TGpXMLData)
public
constructor Create(Node: IXMLNode); override;

property Id: integer index 0 read GetXMLPropInt write SetXMLPropInt;
property Name: WideString index 1 read GetXMLPropWide write SetXMLPropWide;
property Surname: WideString index 2 read GetXMLPropWide write SetXMLPropWide;
property Time: WideString index 3 read GetXMLPropWide write SetXMLPropWide;
property Old: WideString index 4 read GetXMLPropWide write SetXMLPropWide;
property Subject: WideString index 5 read GetXMLPropWide write SetXMLPropWide;
end;

TRows = class(TGpXMLList)
protected
function GetRow(Value: integer): TRow;
public
constructor Create(ParentNode: IXMLNode); reintroduce;

function Add: TRow; reintroduce;

property Rows[Value: integer]: TRow read GetRow; default;
end;

TRootsXml = class(TGpXmlDocList)
private
fRows: TRows;
public
constructor Create; reintroduce;
destructor Destroy; override;

property Ver: WideString index 0 read GetXMLAttrPropWide write SetXMLAttrPropWide;
property RootFile: WideString index 1 read GetXMLAttrPropWide write SetXMLAttrPropWide;

property Rows: TRows read fRows;
end;

implementation

constructor TRow.Create(Node: IXMLNode);
begin
inherited;

InitChildNodes(['id', 'name', 'surname', 'time', 'old', 'subjects'],
['', '', '', '', '', '']);
end;

constructor TRows.Create(parentNode: IXMLNode);
begin
inherited Create(parentNode, '', 'row', TRow);
end;

function TRows.Add: TRow;
begin
Result := TRow(inherited Add);
end;

function TRows.GetRow(Value: Integer): TRow;
begin
Result := TRow(inherited Items[Value]);
end;

constructor TRootsXml.Create;
var
xmlPI: IXMLProcessingInstruction;
begin
inherited Create('Root', '', '', nil);

xmlPI := XMLDoc.CreateProcessingInstruction('xml', 'version="1.0" encoding="utf-8"');
XMLDoc.InsertBefore(xmlPI, node);

InitChildNodes(['ver', 'file'], ['', '']);

fRows := TRows.Create(node);
end;

destructor TRootsXml.Destroy;
begin
fRows.free;

inherited;
end;


当我尝试 TRootsXml.ver = 'sat123';并尝试编译时,出现此错误。 '内部错误E5912'并且未编译...
但是我可以毫无问题地构建并运行它。

那么什么是错误,什么是内部错误E5912?

最佳答案

内部错误是编译器或链接器中的内部错误。这次,它看起来像编译器。该数字仅表示实际编写编译器的人员。它的含义尚未记录,实际上是永远都不会发生的,换句话说,这是编译器中的错误。如果发生这种情况,您只能猜测发生的位置或原因,并尝试修改您的代码,直到代码消失。这并不容易,并且可能令人沮丧,但这是您唯一可以做的。

我认为这与以下事实有关:代码将索引属性与祖先类中定义的getter和setter一起使用。我猜您可以编写自己的getter和setter并使用给定的索引调用继承的getter。试试这个:

  TRootsXml = class(TGpXmlDocList)
private
fRows: TRows;
function GetVer: WideString;
procedure SetVer(const Value: WideString);
function GetRootFile ... etc..
public
constructor Create; reintroduce;
destructor Destroy; override;

property Ver: WideString read GetVer write SetVer;
property RootFile: WideString read GetRootFile write SetRootFile;
property Rows: TRows read fRows;
end;

function TRootsXml.GetVer: WideString;
begin
Result := GetXMLAttrPropWide(0);
end;

procedure TRootsXml.SetVer(const Value: WideString);
begin
SetXMLAttrPropWide(0, Value);
end;

// etc... similar code for GetRootFile and SetRootFile, but with index 1.


不确定是否可行,因为我不再安装Delphi 7,但是请尝试并报告发生的情况。

我猜原来的代码应该在更高版本中使用。但这并不能解释内部错误(如我所说,这些是编译器中的错误),但是它解释了为什么它没有按预期进行编译,因为我假设代码已经过测试,但显然不是在Delphi 7中进行的。

关于delphi - 什么是内部错误E5912,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7302391/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com