Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 2019 22:42
    rhuanjl synchronize #5885
  • Jan 31 2019 22:39
    MikeHolman synchronize #5923
  • Jan 31 2019 22:28
    MikeHolman synchronize #5923
  • Jan 31 2019 19:48
    MikeHolman synchronize #5923
  • Jan 31 2019 19:03
    penzn synchronize #5903
  • Jan 31 2019 17:15
    penzn synchronize #5903
  • Jan 30 2019 22:33
    wyrichte opened #5927
  • Jan 30 2019 22:33

    wyrichte on ADO_test

    Update ChakraCoreStatic.cpp (compare)

  • Jan 30 2019 22:32
    wyrichte closed #5916
  • Jan 30 2019 20:20
    MikeHolman synchronize #5923
  • Jan 30 2019 19:56
    MikeHolman synchronize #5923
  • Jan 30 2019 19:53
    MikeHolman synchronize #5923
  • Jan 30 2019 19:35

    wyrichte on Test-PR-webhook---don't-merge

    Update ChakraCoreStatic.cpp (compare)

  • Jan 30 2019 19:35
    wyrichte synchronize #5916
  • Jan 30 2019 19:07
    wyrichte synchronize #5925
  • Jan 30 2019 18:54

    wyrichte on Test-PR-webhook---don't-merge

    Update ChakraCoreStatic.cpp (compare)

  • Jan 30 2019 18:54
    wyrichte synchronize #5916
  • Jan 30 2019 18:12
    wyrichte closed #5926
  • Jan 30 2019 18:12
    wyrichte opened #5926
  • Jan 30 2019 01:43
    wyrichte synchronize #5925
Grahame Grieve
@grahamegrieve
is there anyway I can mark an object as immutable? so that you can't assign to properties on it?
this applies to both to objects I pass into the javascript engine, and some objects created by the javascript code
Grahame Grieve
@grahamegrieve
a related question: I expose an object of mine to javascript, so that myObj.prop refers through to "prop" on my internal object, and myObj.prop = "test" sets the value of the prop on my object. But if the user accidentally does myObj.propx = "test", chakra creates a new js prop "propx" on the js wrapper object. I haven't found a way to either prevent this or get notified about it, so the property gets lost and it's effectively a silent bug. What are my options here?
Ondrej Kelle
@tondrej
@grahamegrieve to mark an object as immutable, I think you could use Object.freeze(), for hooking property setters/getters perhaps you could use a Proxy or, if you only want to prevent adding new properties, Object.preventExtensions()
Grahame Grieve
@grahamegrieve
well, I didn't think of freeze() because of this: "Accessor properties (getters and setters) work the same (and still give the illusion that you are changing the value)" - unless I misunderstand what that means?
Bruce Pascoe
@fatcerberus
Well I mean if there’s a setter then you can’t magically make the setter not be called on assignment
Grahame Grieve
@grahamegrieve
hmm I'm having trouble calling freeze() on an object. The sequence seems like:
  • use JsCreatePropertyId to get the propertyId for 'freeze'
  • use JsGetProperty to get the function for the propertyId
  • use JsCallFunction passing the func with one parameter which is the object to freeze
.. and I get an ErrorInvalidArgument so I'm doing something wrong?
Jimmy Thomson
@MSLaguana
If you want to invoke the javascript equivalent of Object.freeze(foo), then you need to get a JsValueRef objectObject referencing the global Object, and make sure that you pass that as the this parameter of the freeze function, since the C api is somewhat like calling freeze.call(Object, yourObject)
Grahame Grieve
@grahamegrieve
hmm thanks. that seems obvious... but when I call JsGetProperty for the propertyId for 'freeze' in the return value from JsGetGlobalObject I get a JsUndefined?
Jimmy Thomson
@MSLaguana
JsGetGlobalObject is getting the global object, not the global Object object. E.g. JsGetGlobalObject is the window / "this" object at global scope, and that has an "Object" property which is the Object of Object.freeze that you need to get the property off
Ondrej Kelle
@tondrej
@grahamegrieve In a chakracore-delphi example (using ChakraCoreUtils unit), it would look like this: JsCallFunction('freeze', [], JsGetProperty(JsGlobal, 'Object'));
Ondrej Kelle
@tondrej
An example of a similar usage is here, calling Object.create(prototype)
Grahame Grieve
@grahamegrieve
k thanks all. Really appreciate the help
Bruce Pascoe
@fatcerberus
Is it necessary to pass Object as this? Most JS builtins don’t require this because their spec doesn’t need them to access this at all
For example you can safely call JSON.stringify without JSON being passed as ‘this’
Richard
@rhuanjl
You have to get Object in order to then get at its property freeze but you can then call freeze with an undefined this value
Bruce Pascoe
@fatcerberus
Yeah that’s what I thought thanks @rhuanjl
Also look into JsObjectGetProperty to avoid the need for the PropertyId rigamorole
Michael Holman
@MikeHolman
Does anyone use the JsSetObjectBeforeCollectCallback API?
Jimmy Thomson
@MSLaguana
@fatcerberus Sorry yes you're right; the important thing is that the yourObject can't be the first parameter, since that is the "this" parameter
Ondrej Kelle
@tondrej
@fatcerberus Thanks for the JsObjectGetProperty tip!
Grahame Grieve
@grahamegrieve
is there a way to get the engine to run in strict mode?
Bruce Pascoe
@fatcerberus
You could prepend "use strict"; to all the scripts you run
As long as you don’t add a newline the line numbers should be preserved
Grahame Grieve
@grahamegrieve
so this function: function func(obj) { Object.freeze(obj); obj.prop = "23"; console.log(obj.prop); } logs undefined.
shouldn't this: use strict; function func(obj) { Object.freeze(obj); obj.prop = "23"; console.log(obj.prop); } throw an exception?
Bruce Pascoe
@fatcerberus
Put use strict in quotes. It’s a string followed by a semicolon
Note that strict mode doesn’t catch nonexisting property reads. Those still come back as undefined
It only catches nonexisting variables
Attempting to write to the frozen object will through an error in strict mode though
Grahame Grieve
@grahamegrieve
ok thanks.
Ondrej Kelle
@tondrej
Apparently upcoming 1.12 brings JsParseScriptAttributeStrictMode which can be passed to JsParse/JsRun (instead of augmenting your scripts with "use strict";) - nice :-) thanks!
Viktor Elofsson
@vktr
Hi! Is there any way I can return a native object from an importstatement? I'm embedding ChakraCore in a desktop application for scripting support and would like users to import { App } from 'some-native-module'; where some-native-module is an object I create in native code. Any pointers?
Richard
@rhuanjl
@vktr only way I can think of (without hacking/adding a feature to CC) would be to create a shim module in JS over the top of your native methods, you'd then intercept the 'some-native-module' specifier and load your shim module - question would be how to make your native methods available whilst executing that shim without leaving them on the global object
Bruce Pascoe
@fatcerberus
Trying to compile the latest master of ChakraCore with MSVC 2017 but getting this error on one of my machines (it built fine on my laptop):
29>d:\src\chakracore\lib\common\core\globalsecuritypolicy.h(17): error C2061: syntax error: identifier 'PCFG_CALL_TARGET_INFO'
Anyone have an idea what's wrong?
Louis Lafreniere
@LouisLaf
PCFG_CALL_TARGET_INFO is defined in winnt.h, but you need to have a recent enough SDK. I'm using 10.0.16299.0.
Bruce Pascoe
@fatcerberus
Pretty sure I have 10.0.17763(?). Whatever the latest is
Louis Lafreniere
@LouisLaf
That version of winnt.h does also contain the define. It turns out that's what I'm actually using... You can verify within VS by looking at the VC++ directories in the build properties, and seeing what they evaluate to.
Sasha Syrotenko
@Fly-Style
@rhuanjl
I don't think they've said anything about open sourcing EdgeHtml
@Fly-Style I think I'm the only regular external contributor to chakracore it would be cool to have another one around
@rhuanjl I am sorry for a big delay.
Agree with you :)
Rami
@icnocop
Hi! :)
Rami
@icnocop
Microsoft update KB4507460 released on July 9, 2019 causes an exception in jscript9.dll in Windows Server 2016 when using MFC's CDHtmlDialog. It basically causes the desktop application to crash. I'm wondering if I should report the issue in https://github.com/microsoft/ChakraCore or https://social.msdn.microsoft.com/Forums/Windowsdesktop/en-us/home? Thanks!
jscript9.dll v11.0.14393.3085
:smile:
Rami
@icnocop
Great, someone posted a solution so at least the app doesn't crash. :)
Michael Holman
@MikeHolman
does the app still work as intended? In general I don't think there should be behavioral changes from these updates
Michael Holman
@MikeHolman
from your call stack it looks like a DOM error is being thrown, so probably not related to JavaScript, but i'll forward your report on to the appropriate team
Rami
@icnocop
Hi Michael. Unfortunately, the app still crashes when running in Release mode without the debugger attached. :(