Quantcast
Channel: ClearScript
Viewing all 2297 articles
Browse latest View live

Edited Issue: Calling a function with a parameter in JScriptEngine [56]

$
0
0
I initialize my engine with the following lines:

```
Dim engine As JScriptEngine
engine = New JScriptEngine(WindowsScriptEngineFlags.EnableDebugging)
engine.AddHostType("Console", GetType(Console))

```

I add the following script to the engine:

```
function Test(param) {
Console.WriteLine("Called Test with param: " + param);
}
```

When I call

```
engine.Script.Test(20)
```

It prints: "Called Test with param: undefined"

Does JScriptEngine not support calling internal functions with parameters?

Commented Issue: Calling a function with a parameter in JScriptEngine [56]

$
0
0
I initialize my engine with the following lines:

```
Dim engine As JScriptEngine
engine = New JScriptEngine(WindowsScriptEngineFlags.EnableDebugging)
engine.AddHostType("Console", GetType(Console))

```

I add the following script to the engine:

```
function Test(param) {
Console.WriteLine("Called Test with param: " + param);
}
```

When I call

```
engine.Script.Test(20)
```

It prints: "Called Test with param: undefined"

Does JScriptEngine not support calling internal functions with parameters?
Comments: We cannot reproduce this issue in ClearScript 5.4, and there has been no response from ahmetuzun in 10 days. Marking as resolved.

New Post: redefining toString() - don't know what to expect

$
0
0
Hi Julien,

In the test code above, the initial toString() call does not involve ClearScript at all. The "[object Undefined]" result makes sense; the script engine finds the built-in function on the global object's prototype chain, and invokes it with an undefined this binding. Note that the result is different if you bind this to the global object via this.toString().

The result of the second call is also expected; V8 invokes the user-defined function that now hangs off the global object.

The result of the third call is due to a ClearScript bug. The GlobalMembers feature incorrectly exposes the proxy's built-in toString() method as a global member that overrides the user-defined function. We're testing a fix and will post it very soon.

Thanks bringing another ClearScript issue to our attention!

New Post: Crash when writing to a property without setter

$
0
0
Hello Julien,

We cannot reproduce the V8 crash with the test code above. The correct exception is delivered to the caller with or without a second GlobalMembers object added before the MissingSetter instance.

One difference is that we're not using NUnit. Could you try replacing the Assert.Throws() call with a try..catch statement?

Thanks!

Edited Issue: VBScript ByRef arguments cannot seem to get to work. [58]

$
0
0

Great Library, really helpful!

I ran into one situation where we have some existing VBScripts, the have subroutines and functions that take ByRef scalar types such as ints, double and the values are being changed in the function.


Here is the code I tested:

VBScriptEngine scriptEngine = new VBScriptEngine(WindowsScriptEngineFlags.EnableDebugging);
double byRefValue = 10.0;
scriptEngine.Execute(@"sub TestSub(ByRef MyParam) : MyParam=20.0 : end sub");
scriptEngine.Script.TestSub(ref byRefValue);


Basically what I was trying to accomplish , was the double values should end up being set to 20.0 , but it always remains at 10.0

I tried changing the double to an object and dynamic and it didn't make a difference.

Any thoughts on how to support this scenario.

Thanks!

Edited Issue: By-reference arguments to VBScript functions do not work [58]

$
0
0

Great Library, really helpful!

I ran into one situation where we have some existing VBScripts, the have subroutines and functions that take ByRef scalar types such as ints, double and the values are being changed in the function.


Here is the code I tested:

VBScriptEngine scriptEngine = new VBScriptEngine(WindowsScriptEngineFlags.EnableDebugging);
double byRefValue = 10.0;
scriptEngine.Execute(@"sub TestSub(ByRef MyParam) : MyParam=20.0 : end sub");
scriptEngine.Script.TestSub(ref byRefValue);


Basically what I was trying to accomplish , was the double values should end up being set to 20.0 , but it always remains at 10.0

I tried changing the double to an object and dynamic and it didn't make a difference.

Any thoughts on how to support this scenario.

Thanks!

New Post: VBScript ByRef arguments cannot seem to get to work.

$
0
0
Greetings!

By-reference arguments to VBScript functions are not currently supported. We'll use the work item you created to track this issue. Thanks for reporting it!

In the meantime, you can create a wrapper in VBScript that calls the target function and returns its output to the host without by-reference parameters. For example:
publicclass Holder<T> {
    public T Value;
}
And then:
engine.Execute(@"
    sub TestSubWrapper(holder)
        dim value
        value = holder.Value
        call TestSub(value)
        holder.Value = value
    end sub
");

var holder = new Holder<double> { Value = 10.0 };
engine.Script.TestSubWrapper(holder);
Console.WriteLine(holder.Value);
Thanks again, and good luck!

New Post: Crash when writing to a property without setter

$
0
0
Same behaviour with the try/catch block. It crashes before the catch statement in my code.

it still crashes in the same place (api.cc, line 2905), just after the ScriptException was thrown in the V8ContextImpl::SetHostObjectProperty() method
and here is the call stack
Image

New Post: Crash when writing to a property without setter

$
0
0
Hi Julien,

We've now reproduced the issue, and we'll post a fix shortly.

You've helped us find some very tricky bugs. Thank you!

EDIT: We couldn't reproduce the crash earlier because it's the result of a failing debug-only assertion in V8. You're using a debug build of V8, right?

New Post: Crash when writing to a property without setter

$
0
0
Yes the assert/check is only produced in debug.
I mixed-up my first test somehow, I thought I was using release V8/ClearScript but it was the debug version.

New Post: Crash when writing to a property without setter

New Post: redefining toString() - don't know what to expect

Created Unassigned: Camel case for properties/methods [59]

$
0
0
Hi,

I am exposing existing .NET objects to my script now following .NET conventions I am using PascalCase for my names, is there any nice way that these can become camel cased once exposed to js?

I don't want to have to pollute my objects with methods of both cases or move to camel casing, it would be nice if there was an attribute I could put on methods or some sort of global flag to say treat eveyrthing as camel case.


Ideas?


Thanks
Stefan

Commented Unassigned: Camel case for properties/methods [59]

$
0
0
Hi,

I am exposing existing .NET objects to my script now following .NET conventions I am using PascalCase for my names, is there any nice way that these can become camel cased once exposed to js?

I don't want to have to pollute my objects with methods of both cases or move to camel casing, it would be nice if there was an attribute I could put on methods or some sort of global flag to say treat eveyrthing as camel case.


Ideas?


Thanks
Stefan
Comments: Sorry ignore this I see it is supported abd just not documented! Thanks

Commented Unassigned: Camel case for properties/methods [59]

$
0
0
Hi,

I am exposing existing .NET objects to my script now following .NET conventions I am using PascalCase for my names, is there any nice way that these can become camel cased once exposed to js?

I don't want to have to pollute my objects with methods of both cases or move to camel casing, it would be nice if there was an attribute I could put on methods or some sort of global flag to say treat eveyrthing as camel case.


Ideas?


Thanks
Stefan
Comments: Sorry I don't mean not documented just not in front of me.

Edited Unassigned: Camel case for properties/methods [59]

$
0
0
Hi,

I am exposing existing .NET objects to my script now following .NET conventions I am using PascalCase for my names, is there any nice way that these can become camel cased once exposed to js?

I don't want to have to pollute my objects with methods of both cases or move to camel casing, it would be nice if there was an attribute I could put on methods or some sort of global flag to say treat eveyrthing as camel case.

It would be nice if this could be conventional so I could support it on existing libraries that I cannot add the attribute to!


Ideas?


Thanks
Stefan

Edited Feature: Camel case for properties/methods [59]

$
0
0
Hi,

I am exposing existing .NET objects to my script now following .NET conventions I am using PascalCase for my names, is there any nice way that these can become camel cased once exposed to js?

I don't want to have to pollute my objects with methods of both cases or move to camel casing, it would be nice if there was an attribute I could put on methods or some sort of global flag to say treat eveyrthing as camel case.

It would be nice if this could be conventional so I could support it on existing libraries that I cannot add the attribute to!


Ideas?


Thanks
Stefan

Commented Feature: Camel case for properties/methods [59]

$
0
0
Hi,

I am exposing existing .NET objects to my script now following .NET conventions I am using PascalCase for my names, is there any nice way that these can become camel cased once exposed to js?

I don't want to have to pollute my objects with methods of both cases or move to camel casing, it would be nice if there was an attribute I could put on methods or some sort of global flag to say treat eveyrthing as camel case.

It would be nice if this could be conventional so I could support it on existing libraries that I cannot add the attribute to!


Ideas?


Thanks
Stefan
Comments: Hi Stefan, It looks like you found `ScriptMemberAttribute`. Unfortunately ClearScript doesn't provide global control over exposed member names. Good luck!

Edited Issue: Calling a function with a parameter in JScriptEngine [56]

$
0
0
I initialize my engine with the following lines:

```
Dim engine As JScriptEngine
engine = New JScriptEngine(WindowsScriptEngineFlags.EnableDebugging)
engine.AddHostType("Console", GetType(Console))

```

I add the following script to the engine:

```
function Test(param) {
Console.WriteLine("Called Test with param: " + param);
}
```

When I call

```
engine.Script.Test(20)
```

It prints: "Called Test with param: undefined"

Does JScriptEngine not support calling internal functions with parameters?

Edited Issue: GlobalMember property not found (regression) [57]

$
0
0
when upgrading from 5.3.10 to 5.4, my unit tests fail when trying to find a globalmember property, in a particular case. Some unit tests are better than a long speech so here are the tests (only the NOK fails, with error : __ReferenceError: A is not defined__) :

```
class host1
{
public string H { get; set; }
public PropertyBag A { get; set; }
public host1() { A = new PropertyBag(); A.Add("FOUR", 4); }
}

class host2
{
public string W { get; set; }
public PropertyBag B { get; set; }
public host2() { B = new PropertyBag(); B.Add("EIGHT", 8); }
}

[Test]
public void Test_engine_global_objects_NOK()
{
var engine = new V8ScriptEngine("xscript");

engine.AddHostObject("", HostItemFlags.GlobalMembers, new host1());
engine.AddHostObject("", HostItemFlags.GlobalMembers, new host2());

Assert.AreEqual(4, engine.Evaluate("A.FOUR"));
Assert.AreEqual(8, engine.Evaluate("B.EIGHT"));
}

[Test]
public void Test_engine_global_objects_A()
{
var engine = new V8ScriptEngine("xscript");
engine.AddHostObject("", HostItemFlags.GlobalMembers, new host1());
Assert.AreEqual(4, engine.Evaluate("A.FOUR"));
}
[Test]
public void Test_engine_global_objects_B()
{
var engine = new V8ScriptEngine("xscript");
engine.AddHostObject("", HostItemFlags.GlobalMembers, new host2());
Assert.AreEqual(8, engine.Evaluate("B.EIGHT"));
}

[Test]
public void Test_engine_normal_objects()
{
var engine = new V8ScriptEngine("xscript");

engine.AddHostObject("f", new host1().A);
engine.AddHostObject("e", new host2().B);
Assert.AreEqual(4, engine.Evaluate("f.FOUR"));
Assert.AreEqual(8, engine.Evaluate("e.EIGHT"));
}

[Test]
public void Test_engine_simple_global_objects()
{
var engine = new V8ScriptEngine("xscript");

engine.AddHostObject("", HostItemFlags.GlobalMembers, new host1());
engine.AddHostObject("", HostItemFlags.GlobalMembers, new host2());

engine.Execute("H = 'hello'");
engine.Execute("W = 'world'");
Assert.AreEqual("hello", engine.Evaluate("H"));
Assert.AreEqual("world", engine.Evaluate("W"));
}

```
Viewing all 2297 articles
Browse latest View live




Latest Images