webidl: wasmjob: setter for primitive types

This commit is contained in:
mattias 2022-06-24 10:41:28 +02:00
parent e0baf898b1
commit a64f44e579

View File

@ -396,7 +396,6 @@ begin
aClassName:=GetName(Attr.Parent); aClassName:=GetName(Attr.Parent);
case TypeName of case TypeName of
'JSValue': ReadFuncName:='ReadJSPropertyUnicode?';
'Boolean': ReadFuncName:='ReadJSPropertyBoolean'; 'Boolean': ReadFuncName:='ReadJSPropertyBoolean';
'ShortInt', 'ShortInt',
'Byte', 'Byte',
@ -409,8 +408,9 @@ begin
'Single', 'Single',
'Double': ReadFuncName:='ReadJSPropertyDouble'; 'Double': ReadFuncName:='ReadJSPropertyDouble';
'UnicodeString': ReadFuncName:='ReadJSPropertyUnicodeString'; 'UnicodeString': ReadFuncName:='ReadJSPropertyUnicodeString';
//'JSValue':
else else
raise EConvertError.Create('not yet implemented: getter '+Typename); raise EConvertError.Create('not yet implemented: Getter '+Typename);
end; end;
Code:='Function '+aClassName+'.'+FuncName+': '+TypeName+';'+sLineBreak; Code:='Function '+aClassName+'.'+FuncName+': '+TypeName+';'+sLineBreak;
@ -424,16 +424,42 @@ end;
function TWebIDLToPasWasmJob.WritePrivateSetter(Attr: TIDLAttributeDefinition function TWebIDLToPasWasmJob.WritePrivateSetter(Attr: TIDLAttributeDefinition
): boolean; ): boolean;
var var
FuncName, TypeName: String; FuncName, TypeName, aClassName, WriteFuncName, Code: String;
begin begin
if aoReadOnly in Attr.Options then if aoReadOnly in Attr.Options then
exit(false); exit(false);
Result:=true; Result:=true;
FuncName:=GetterPrefix+GetName(Attr); FuncName:=SetterPrefix+GetName(Attr);
TypeName:=GetTypeName(Attr.AttributeType); TypeName:=GetTypeName(Attr.AttributeType);
AddLn('Procedure '+FuncName+'(const aValue: '+TypeName+');'); AddLn('Procedure '+FuncName+'(const aValue: '+TypeName+');');
aClassName:=GetName(Attr.Parent);
case TypeName of
'Boolean': WriteFuncName:='WriteJSPropertyBoolean';
'ShortInt',
'Byte',
'SmallInt',
'Word',
'Integer': WriteFuncName:='WriteJSPropertyLongInt';
'LongWord',
'Int64',
'QWord': WriteFuncName:='WriteJSPropertyDouble';
'Single',
'Double': WriteFuncName:='WriteJSPropertyDouble';
'UnicodeString': WriteFuncName:='WriteJSPropertyUnicodeString';
//'JSValue':
else
raise EConvertError.Create('not yet implemented: Setter '+Typename);
end;
Code:='Procedure '+aClassName+'.'+FuncName+'(const aValue: '+TypeName+');'+sLineBreak;
Code:=Code+'begin'+sLineBreak;
Code:=Code+' '+WriteFuncName+'('''+Attr.Name+''',aValue);'+sLineBreak;
Code:=Code+'end;'+sLineBreak;
FIncludeImplementationCode.Add(Code);
end; end;
function TWebIDLToPasWasmJob.WriteProperty(Attr: TIDLAttributeDefinition function TWebIDLToPasWasmJob.WriteProperty(Attr: TIDLAttributeDefinition
@ -1107,25 +1133,33 @@ Var
begin begin
Case aTypeName of Case aTypeName of
'union': TN:='JSValue'; 'boolean': TN:='Boolean';
'short': TN:='SmallInt';
'long': TN:='Integer'; 'byte': TN:='ShortInt';
'long long': TN:='Int64';
'unsigned short': TN:='Word';
'unrestricted float': TN:='Single';
'unrestricted double': TN:='Double';
'unsigned long': TN:='LongWord';
'unsigned long long': TN:='QWord';
'octet': TN:='Byte'; 'octet': TN:='Byte';
'short': TN:='SmallInt';
'unsigned short': TN:='Word';
'long': TN:='Integer';
'unsigned long': TN:='LongWord';
'long long': TN:='Int64';
'unsigned long long': TN:='QWord';
'float',
'unrestricted float': TN:='Single';
'double',
'unrestricted double': TN:='Double';
'union',
'any': TN:='JSValue'; 'any': TN:='JSValue';
'float': TN:='Single';
'double': TN:='Double';
'DOMString', 'DOMString',
'USVString', 'USVString',
'ByteString': TN:='UnicodeString'; 'ByteString': TN:='UnicodeString';
'object': TN:=GetClassName('Object'); 'object': TN:=GetClassName('Object');
'Error', 'Error',
'DOMException': TN:=GetClassName('Error'); 'DOMException': TN:=GetClassName('Error');
'ArrayBuffer', 'ArrayBuffer',
'DataView', 'DataView',
'Int8Array', 'Int8Array',