aarhin / dwscript Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/dwscript
Automatically exported from code.google.com/p/dwscript
Code:
var arr := [1, 2, '3', 3.14, Now(), 'end'];
var ndx : Integer;
for ndx := Low(arr) To High(arr) do
println(arr[ndx]);
Out:
6
1
2
3
3,14
40472,6723455671
First item contains a array size
Original issue reported on code.google.com by [email protected]
on 21 Oct 2010 at 11:10
var server : ComVariant := XmlRpcServer('http://api.example.com'); // some
initialization
server.namespace.method(1); // passed as Int64. dwsComConnector cannot convert
its
// (Runtime Error: Invalid data type (20) for DWSII Com-Wrapper! [line: 3,
column: 24])
server.namespace.method(Now);// passed as Double. must be varDate
Original issue reported on code.google.com by [email protected]
on 26 Oct 2010 at 6:08
Consider this script:
// begin of script
procedure Process(List: TStringList);
var i: Integer;
begin
for i := 0 to List.Count-1 do
println(Format('%d. %s', [i, List[i]]));
end;
type
TMyStringList = class(TStringList)
end;
var MyList = TMyStringList.Create;
var i: Integer;
begin
for i := 1 to 100 do
MyList.Add(IntToStr(i));
Process(MyList);
end;
// end of script
It does not compile, but it should: Process should accept MyList for it is a
TStringList descendant.
Original issue reported on code.google.com by [email protected]
on 27 Oct 2010 at 8:35
What steps will reproduce the problem?
1. Use TWebDelphiScript with default settings
2. Compile code:
//
Function Percent(AMax, AValue : Integer) : Integer;
Begin
Result := Round(100 / Max * AValue);
End;
//
What is the expected output?
Syntax Error: Unknown name "Max" [line: 5, column: 24]
What do you see instead?
Syntax Error: Access violation at address 0053A7FC in module 'realfire.exe'.
Read of address 00000000
What version of the product are you using?
Delphi 2010.
Original issue reported on code.google.com by [email protected]
on 24 Sep 2010 at 1:37
Code:
Procedure Log(AStr : string);
Begin
End;
Log(Float(now));
Out:
Syntax Error: Integer expected [line: 5, column: 5]
Syntax Error: Argument 0 expects type "String" instead of "Float" [line: 5,
column: 1]
Syntax Error: Integer expected [line: 5, column: 5]
Syntax Error: Argument 0 expects type "String" instead of "Float" [line: 5,
column: 1]
Original issue reported on code.google.com by [email protected]
on 23 Oct 2010 at 7:13
Add support for Odd() function
Original issue reported on code.google.com by [email protected]
on 20 Oct 2010 at 12:32
I can not understand purposes of Config.ScriptPaths and
RestrictedFileSystem.ScriptPaths and their combination from current realization.
Original issue reported on code.google.com by [email protected]
on 14 Oct 2010 at 2:42
Code:
//
Function Percent(Const AMax, AValue : Integer) : Integer;
Begin
Result := Round(100 / AMax * AValue);
End;
//
Var
x, y : Integer;
x := 216;
y := 108;
Percent(x - y, x - y);
Out:
Runtime Error: Could not convert variant of type (Int64) into type (Unknown)
[line: 5, column: 12]
Workaround: to declare parameters without "Const"
Original issue reported on code.google.com by [email protected]
on 19 Oct 2010 at 5:25
What steps will reproduce the problem?
uses dwsHtmlFilter & following HTML:
<?pas
var s: string;
s := '?>';
Send(s);
?>
What is the expected output?
?>
What do you see instead?
Syntax Error: Invalid character ("S") [line: 3, column: 24]
Original issue reported on code.google.com by [email protected]
on 30 Sep 2010 at 8:28
Code:
var arr := [];
PrintLn(arr[0]);
Out:
Syntax Error: Argument 0 expects type "Variant" instead of "nil" [line: 2,
column: 1]
Original issue reported on code.google.com by [email protected]
on 21 Oct 2010 at 12:06
VarType() returns Integer instead of TVarType
Original issue reported on code.google.com by [email protected]
on 5 Oct 2010 at 9:05
What steps will reproduce the problem?
1. Add new array type (TStringArray : Array [0 .. 10] Of String) in TdwsUnit
component
2. Add new variable (arr : TStringArray) in TdwsUnit component
3. Try to compile script: "arr[0] := 'test';"
What is the expected output?
Syntax Error: ":=" expected [line: 1, column: 4]
Original issue reported on code.google.com by [email protected]
on 26 Sep 2010 at 12:32
dwsCompiler use dwsMagicExprs, but unit dwsMagicExprs not found.
Original issue reported on code.google.com by [email protected]
on 28 Oct 2010 at 4:51
Objects, which have a cross-reference not will be destroyed even after
destruction of TdwsProgram.
Code:
Type
TObj = Class
FOwner : TObj;
Constructor Create(AOwner : TObj);
End;
Constructor TObj.Create(AOwner : TObj);
Begin
Inherited Create;
FOwner := AOwner;
If AOwner <> NIL Then
AOwner.FOwner := Self;
End;
Var i := 0;
While i < 1000000 Do
Begin
TObj.Create(TObj.Create(NIL));
Inc(i);
End;
Original issue reported on code.google.com by [email protected]
on 3 Nov 2010 at 12:15
What steps will reproduce the problem?
When value of constant must be calculated with functions using, we has problem.
Code:
Const X = 1024;
Const Y = Round(X / 5);
What do you see instead?
Syntax Error: Constant expression expected [line: 2, column: 23]
Original issue reported on code.google.com by [email protected]
on 30 Sep 2010 at 9:55
From Wilbert van Leijen
The declaration would be as follows
function InSet(n : Integer; values: array of Integer): boolean
so you can write in script
if InSet(n, [2, 5, 9, 11]) then ...
rather than
if (n = 2) or (n = 5) or (n = 9) or (n = 11) then ...
and the implementation thereof is
TInSetFunc = class(TInternalMagicBoolFunction)
function DoEvalAsBoolean(args : TExprBaseList) : Boolean; override;
end;
{ ... }
function TInSetFunc.DoEvalAsBoolean;
var
expr : TExprBase;
varRecs : TVarRecArrayContainer;
value, i : Integer;
begin
expr := args.ExprBase[1];
if not (expr is TArrayConstantExpr) then
raise EScriptException.Create(CPE_ConstantExpressionExpected);
varRecs := TArrayConstantExpr(expr).EvalAsVarRecArray;
value := args.AsInteger[0];
Result := False;
try
for i := 0 to High(varRecs.VarRecArray) do
with varRecs.VarRecArray[i] do
if VType = vtInt64 then
if value = VInt64^ then
begin
Result := True;
Break;
end;
finally
varRecs.Free;
end;
end;
{ ... }
RegisterInternalBoolFunction(TInSetFunc, 'InSet', ['n', cInteger, 'values', 'array of Variant'], True); // should be array of Integer
Original issue reported on code.google.com by [email protected]
on 28 Oct 2010 at 10:25
Add support bitwise operations shr, shl
Original issue reported on code.google.com by [email protected]
on 1 Oct 2010 at 12:35
Actual for OnEval event handlers.
Original issue reported on code.google.com by [email protected]
on 3 Oct 2010 at 2:19
I offer to add the directive {$IFDECL 'TObject'} (or with other name) similar
{$IF Declared (TObject)}, but with an opportunity to check presence of members
at classes (also variables, types, procedures, functions).
Example:
{$IFDECL 'Exception.ToString'}s := Excep.ToString{$ELSE}s :=
Excep.Message{$ENDIF}
{$IFDECL 'WriteLn'}WriteLn(s){$ELSE}PrintLn(s){$ENDIF}
{$IFNDECL 'GlobalVar'}{$ERROR 'GlobalVar must be declared'}{$ENDIF}
Original issue reported on code.google.com by [email protected]
on 11 Nov 2010 at 11:04
type
TEnum = (enOne, enTwo, enThree);
var e : TEnum;
var i : Integer;
Inc(e); // supported
Dec(e); // supported
i := Ord(e); // unsupported
e := High(e); // unsupported
e := Low(e); // unsupported
succ(e); // unsupported
pred(e); // unsupported
for e := enOne to enThree do; // unsupported
Original issue reported on code.google.com by [email protected]
on 29 Oct 2010 at 4:45
Code:
Var B : Boolean;
B := B Not B;
Out:
Syntax Error: ";" expected. [line: 3, column: 8]
Original issue reported on code.google.com by [email protected]
on 20 Oct 2010 at 12:23
Code:
Procedure SetXY(Const AX, AY, AValue : Integer);
Begin
Print(Format('X = %d, Y = %d, Value = %d', [AX, AY, AValue]));
End;
SetXY(100, 100, RandomInt(High(Integer)));
Out:
Runtime Error: Assertion failure (C:\DWS\Source\dwsExprs.pas, line 2777) [line:
8, column: 1]
Original issue reported on code.google.com by [email protected]
on 16 Oct 2010 at 2:19
What steps will reproduce the problem?
1. Add new record type (TRec = Record Member : String; End) in TdwsUnit
component
2. Add new variable (rec : TRec) in TdwsUnit component
3. Try to compile script: "rec."
What is the expected output?
Syntax Error: "." expected ("<CRLF>") [line: 1, column: 5]
4. Try to compile script: "rec.member := 'test'"
What is the expected output?
Syntax Error: ":=" expected [line: 1, column: 4]
Original issue reported on code.google.com by [email protected]
on 27 Sep 2010 at 8:15
dwsFunctions.RegisterInternalInitProc does not use dwsInternalUnit instead of
vInternalUnit
Original issue reported on code.google.com by [email protected]
on 25 Sep 2010 at 6:16
To allow restricting access to the actual filesystem or using a virtual file
system.
Adapt dwsClasses lib module accordingly (TStrings)
Original issue reported on code.google.com by [email protected]
on 1 Oct 2010 at 7:10
What steps will reproduce the problem?
Compile code:
Var Ndx : Integer;
Procedure Test;
Begin
For Ndx := 0 To 10 Do
PrintLn(IntToStr(Ndx));
End;
What is the expected output?
For loop control variable must be simple local variable (Delphi variant), or
normal compilation if it is possible.
What do you see instead?
Syntax Error: Integer expected [line: 6, column: 10]
Original issue reported on code.google.com by [email protected]
on 30 Sep 2010 at 9:19
Code:
PrintLn(FloatToStr(3.14 Shr 2));
PrintLn(FloatToStr(3.14 And 5));
What is the expected output?
Operator not applicable to this operand type.
What do you see instead?
Normal compilation;
Original issue reported on code.google.com by [email protected]
on 1 Oct 2010 at 4:51
What steps will reproduce the problem?
In unit dwsClasses use TString.SaveToFile() is lost data:
procedure TdwsStrings.SaveToStream(Stream: TStream);
var
S: string;
begin
S := GetTextStr;
Stream.WriteBuffer(Pointer(S)^, Length(S));
end;
Request change to:
procedure TdwsStrings.SaveToStream(Stream: TStream);
var
S: string;
begin
S := GetTextStr;
Stream.WriteBuffer(Pointer(S)^, Length(S) * SizeOf(WideChar));
end;
Original issue reported on code.google.com by [email protected]
on 30 Sep 2010 at 8:56
What steps will reproduce the problem?
1. use TDelphiWebScript, TdwsHTMLFilter, TdwsHTMLUnit in my program.
2. Input HTML code below:
<html>
<body>
<table>
<?pas Send('test 中文'); ?>
中文測試:戊
</table>
</body>
</html>
What is the expected output?
test 中文中文測試:戊
What do you see instead?
Syntax Error: End of string constant not found (end of line) ("戊") [line: 4,
column: 40]
What version of the product are you using? On what operating system?
Delphi 2010
Please provide any additional information below.
Thank you!
Original issue reported on code.google.com by [email protected]
on 23 Sep 2010 at 11:19
Code:
var arr := [1, 2, '3', 3.14];
var ndx : Integer;
for ndx := Low(arr) To High(arr) do
Out:
Syntax Error: Access violation at address 00519C59 in module 'test.exe'. Read
of address 00000000
Original issue reported on code.google.com by [email protected]
on 21 Oct 2010 at 10:18
From Wilbert van Leijen mail.
Is it possible to give TInternalFunction default parameters?
"Inc" and "Dec" both ought to have those: an increment or decrement of 1. Just
like it is in the Delphi RTL.
It is not a biggie - I mean, I can implement those easily in a dwsUnit - it is
just that I have to comment out
// RegisterInternalIntFunction(TIncFunc, 'Inc', ['@a', cInteger, 'b',
cInteger], True);
// RegisterInternalIntFunction(TDecFunc, 'Dec', ['@a', cInteger, 'b',
cInteger], True);
each time you update unit dwsMathFunctions.
Original issue reported on code.google.com by [email protected]
on 27 Oct 2010 at 7:20
Add support for Assigned()
Original issue reported on code.google.com by [email protected]
on 2 Nov 2010 at 2:17
So far as in DWS all integer meanings are stored in Int64, it would be
desirable to have the mechanism of type differentiation in ComConnector. If the
meaning of variable is in a range of Integer type, that she was passed as VT_I4
instead of VT_I8, but if was used explicit type cast ( Int64 (5) ), then to use
VT_I8. It can appear necessary at interaction with external objects since they
can expect only VT_I4, and VT_I8 in some cases.
Original issue reported on code.google.com by [email protected]
on 27 Oct 2010 at 11:40
Instead of "script not found" message
Original issue reported on code.google.com by [email protected]
on 15 Oct 2010 at 11:25
Code:
//
Procedure test(Const arr : Array Of Variant);
Begin
Var ndx : integer;
For ndx := Low(arr) To High(arr) Do
PrintLn(arr[ndx]);
End;
//
test([4,5,6]);
test([]);
Out:
Syntax Error: Argument 0 expects type "array of Variant" instead of "array
[0..2] of Variant" [line: 12, column: 1]
Syntax Error: Argument 0 expects type "array of Variant" instead of "array
[0..-1] of Variant" [line: 13, column: 1]
Original issue reported on code.google.com by [email protected]
on 21 Oct 2010 at 5:07
Function TdwsCompiler.GetScriptSource(...) : String;
Var
sFile : TFileStream;
...
SetLength(Result, sFile.Size);
sFile.Read(Result[1], sFile.Size);
Original issue reported on code.google.com by [email protected]
on 1 Oct 2010 at 11:38
Code:
Type
TMyObj = Class;
TMyObj = Class
Procedure Add(AObject : TMyObj);
End;
Procedure TMyObj.Add(AObject : TMyObj);
Begin
End;
Out:
Syntax Error: Invalid Instruction - function or assignment expected [line: 5,
column: 9]
Workaround:
Add "Type" before declaration of TMyObj;
Original issue reported on code.google.com by [email protected]
on 2 Nov 2010 at 2:07
This code silently kill my application.
var server : ComVariant := XmlRpcServer('http://api.example.com/'); // some
initialization
server.namespace.method(
// '1', '2', '3', '4', '5', '6', '7', '8', // uncomment
for effect
'1', '2', '3', '4', '5', '6', '7', '8',
'1', '2', '3', '4', '5', '6', '7', '8',
'1', '2', '3', '4', '5', '6', '7', '8',
'1', '2', '3', '4', '5', '6', '7', '8',
'1', '2', '3', '4', '5', '6', '7', '8',
'1', '2', '3', '4', '5', '6', '7', '8',
'1', '2', '3', '4', '5', '6', '7', '8',
'1', '2', '3', '4', '5', '6', '7', '8'
); // 72 params. maxDispArgs = 64.
Original issue reported on code.google.com by [email protected]
on 26 Oct 2010 at 9:00
Can add support Format('...',[...]); function?
Original issue reported on code.google.com by [email protected]
on 5 Oct 2010 at 12:20
Wilbert van Leijen
I have still an issue with constant parameters in DWS:
// begin script
function f(a : string; b : array of string) : Boolean;
begin
Result := SameText(a, b[0]);
end;
begin
if f('a text', ['compare against', 'compare against too']) then
PrintLn('Odd')
else
PrintLn('Expected');
end;
// end script
results in "Argument 1 expects type " " instead or " "
Original issue reported on code.google.com by [email protected]
on 10 Nov 2010 at 10:26
Add support define, undef, ifdef, ifndef
Original issue reported on code.google.com by [email protected]
on 1 Oct 2010 at 10:09
What steps will reproduce the problem?
1. Place unit dwsFunctions before dwsComp unit
2. Compile and run application
What is the expected output?
Normal work
What do you see instead?
---------------------------
Debugger Exception Notification
---------------------------
Project script.exe raised exception class EAccessViolation with message 'Access
violation at address 0047CE2C in module 'script.exe'. Read of address 0000000C'.
---------------------------
Break Continue Help
---------------------------
What version of the product are you using?
Delphi 2009, 2010
Original issue reported on code.google.com by [email protected]
on 24 Sep 2010 at 5:38
Code:
var x := 0;
x := x + print('');
Output:
Syntax Error: Access violation at address 0053B136 in module 'test.exe'. Read
of address 00000008
Original issue reported on code.google.com by [email protected]
on 3 Oct 2010 at 8:45
Code:
Type
TMyObj = Class
Procedure Add(AObject : TMyObj);
End;
Out:
Syntax Error: Type "TMyObj" not found [line: 5, column: 27]
Original issue reported on code.google.com by [email protected]
on 2 Nov 2010 at 12:20
Needs an afficient way to concatenate strings.
Original issue reported on code.google.com by [email protected]
on 3 Oct 2010 at 1:15
Some low-level data buffer ala Java ByteBuffer
Original issue reported on code.google.com by [email protected]
on 3 Oct 2010 at 1:16
In TightList.Assign, the case Count=0 is put through ReallocMem and
System.Move, while a simple "0: Exit;" would have sufficed.
Also, Move is quite expensive, with the Delete and Insert moving on average
half the items aroung TWICE! Better to remember the source, Move the items
in-between 1 step aside, so you can put the item back in the slot that came
free. (Just for fun: Trace what happens if you Move(0,1) when Count=2!)
Original issue reported on code.google.com by [email protected]
on 1 Nov 2010 at 1:25
Or drop TdwsStrings entirely if feasible.
Take the opportunity to implement a better TdwsStringList than TStringList.
Original issue reported on code.google.com by [email protected]
on 1 Oct 2010 at 7:12
What steps will reproduce the problem?
1.Just compile under BDS2006 under Win32 mode
What version of the product are you using? On what operating system?
- preview 3
I have changes a small portion of the source code and it works now under Win32,
so it is a very minor change:
- All "exit(ResultVal)" should be replaced by "Result:=ResultVal;Exit;"
- System.MonitorEnter(var) / System.MonitorExit(var) doestn't work
- RawByteString isn't supported (I defined RawByteString as normal string)
- UString is not supported, changed this to normal string
Original issue reported on code.google.com by [email protected]
on 25 Oct 2010 at 12:18
TdwsRecord and TdwsMember (from TdwsUnit) not have events for read/write
Original issue reported on code.google.com by [email protected]
on 24 Sep 2010 at 5:18
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.