mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-13 05:40:20 +02:00
webidl: nicer error messages, fixed function returning Object
This commit is contained in:
parent
f0eccda1ab
commit
9b1d5ef92a
@ -278,6 +278,8 @@ end;
|
|||||||
|
|
||||||
function TBaseWebIDLToPas.GetPasClassName(const aName: string): string;
|
function TBaseWebIDLToPas.GetPasClassName(const aName: string): string;
|
||||||
begin
|
begin
|
||||||
|
if aName='' then
|
||||||
|
raise EConvertError.Create('[20220725184209] empty name');
|
||||||
Result:=ClassPrefix+aName+ClassSuffix;
|
Result:=ClassPrefix+aName+ClassSuffix;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1499,6 +1501,8 @@ begin
|
|||||||
CN:=D.Name;
|
CN:=D.Name;
|
||||||
if D Is TIDLInterfaceDefinition then
|
if D Is TIDLInterfaceDefinition then
|
||||||
begin
|
begin
|
||||||
|
if CN='' then
|
||||||
|
raise EConvertError.Create('[20220725184324] at '+GetDefPos(D));
|
||||||
if not TIDLInterfaceDefinition(D).IsPartial then
|
if not TIDLInterfaceDefinition(D).IsPartial then
|
||||||
AddJSIdentifier(D);
|
AddJSIdentifier(D);
|
||||||
CN:=ClassPrefix+CN+ClassSuffix;
|
CN:=ClassPrefix+CN+ClassSuffix;
|
||||||
@ -1508,6 +1512,8 @@ begin
|
|||||||
end
|
end
|
||||||
else if D Is TIDLDictionaryDefinition then
|
else if D Is TIDLDictionaryDefinition then
|
||||||
begin
|
begin
|
||||||
|
if CN='' then
|
||||||
|
raise EConvertError.Create('[20220725184410] at '+GetDefPos(D));
|
||||||
if not TIDLDictionaryDefinition(D).IsPartial then
|
if not TIDLDictionaryDefinition(D).IsPartial then
|
||||||
AddJSIdentifier(D);
|
AddJSIdentifier(D);
|
||||||
if coDictionaryAsClass in BaseOptions then
|
if coDictionaryAsClass in BaseOptions then
|
||||||
|
@ -143,6 +143,8 @@ begin
|
|||||||
and (RightStr(Result,length(ClassSuffix))=ClassSuffix)
|
and (RightStr(Result,length(ClassSuffix))=ClassSuffix)
|
||||||
then
|
then
|
||||||
Result:=copy(Result,length(ClassPrefix)+1,length(Result)-length(ClassPrefix)-length(ClassSuffix));
|
Result:=copy(Result,length(ClassPrefix)+1,length(Result)-length(ClassPrefix)-length(ClassSuffix));
|
||||||
|
if Result='' then
|
||||||
|
raise EConvertError.Create('[20220725184518]');
|
||||||
Result:=PasInterfacePrefix+Result+PasInterfaceSuffix;
|
Result:=PasInterfacePrefix+Result+PasInterfaceSuffix;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -153,6 +155,8 @@ begin
|
|||||||
and (RightStr(Result,length(PasInterfaceSuffix))=PasInterfaceSuffix)
|
and (RightStr(Result,length(PasInterfaceSuffix))=PasInterfaceSuffix)
|
||||||
then
|
then
|
||||||
Result:=copy(Result,length(PasInterfacePrefix)+1,length(Result)-length(PasInterfacePrefix)-length(PasInterfaceSuffix));
|
Result:=copy(Result,length(PasInterfacePrefix)+1,length(Result)-length(PasInterfacePrefix)-length(PasInterfaceSuffix));
|
||||||
|
if Result='' then
|
||||||
|
raise EConvertError.Create('[20220725184440]');
|
||||||
Result:=ClassPrefix+Result+ClassSuffix;
|
Result:=ClassPrefix+Result+ClassSuffix;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -244,13 +248,20 @@ begin
|
|||||||
and (LeftStr(Result,length(PasInterfacePrefix))<>PasInterfacePrefix)
|
and (LeftStr(Result,length(PasInterfacePrefix))<>PasInterfacePrefix)
|
||||||
and (RightStr(Result,length(PasInterfaceSuffix))<>PasInterfaceSuffix)
|
and (RightStr(Result,length(PasInterfaceSuffix))<>PasInterfaceSuffix)
|
||||||
then
|
then
|
||||||
|
begin
|
||||||
|
if Result='' then
|
||||||
|
raise EConvertError.Create('[20220725184536]');
|
||||||
Result:=PasInterfacePrefix+Result+PasInterfaceSuffix;
|
Result:=PasInterfacePrefix+Result+PasInterfaceSuffix;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TWebIDLToPasWasmJob.GetPasIntfName(Intf: TIDLDefinition): string;
|
function TWebIDLToPasWasmJob.GetPasIntfName(Intf: TIDLDefinition): string;
|
||||||
begin
|
begin
|
||||||
Result:=GetPasClassName(GetName(Intf));
|
Result:=GetName(Intf);
|
||||||
|
if Result='' then
|
||||||
|
raise EConvertError.Create('[20220725184653] missing name at '+GetDefPos(Intf));
|
||||||
|
Result:=GetPasClassName(Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TWebIDLToPasWasmJob.GetInterfaceDefHead(Intf: TIDLInterfaceDefinition
|
function TWebIDLToPasWasmJob.GetInterfaceDefHead(Intf: TIDLInterfaceDefinition
|
||||||
@ -456,6 +467,7 @@ begin
|
|||||||
'QWord': InvokeName:='InvokeJSMaxIntResult';
|
'QWord': InvokeName:='InvokeJSMaxIntResult';
|
||||||
'Single',
|
'Single',
|
||||||
'Double': InvokeName:='InvokeJSDoubleResult';
|
'Double': InvokeName:='InvokeJSDoubleResult';
|
||||||
|
'UTF8String',
|
||||||
'UnicodeString': InvokeName:='InvokeJSUnicodeStringResult';
|
'UnicodeString': InvokeName:='InvokeJSUnicodeStringResult';
|
||||||
'TJOB_JSValue': InvokeName:='InvokeJSValueResult';
|
'TJOB_JSValue': InvokeName:='InvokeJSValueResult';
|
||||||
'void','undefined':
|
'void','undefined':
|
||||||
@ -473,6 +485,10 @@ begin
|
|||||||
InvokeClassName:=ReturnTypeName;
|
InvokeClassName:=ReturnTypeName;
|
||||||
ReturnTypeName:=GetPasIntfName(ReturnDef);
|
ReturnTypeName:=GetPasIntfName(ReturnDef);
|
||||||
end
|
end
|
||||||
|
else if ResolvedReturnTypeName=PasInterfacePrefix+'Object'+PasInterfaceSuffix then
|
||||||
|
begin
|
||||||
|
InvokeClassName:=ClassPrefix+'Object'+ClassSuffix;
|
||||||
|
end
|
||||||
else
|
else
|
||||||
raise EConvertError.Create('[20220725172242] not yet supported: function return type '+ResolvedReturnTypeName+' '+ReturnDef.ClassName+' at '+GetDefPos(aDef));
|
raise EConvertError.Create('[20220725172242] not yet supported: function return type '+ResolvedReturnTypeName+' '+ReturnDef.ClassName+' at '+GetDefPos(aDef));
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user