Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation Improvements: How to do basic things with ChakraCore #5

Open
6 of 13 tasks
dilijev opened this issue Aug 8, 2016 · 9 comments
Open
6 of 13 tasks
Assignees

Comments

@dilijev
Copy link
Contributor

dilijev commented Aug 8, 2016

Adapted from internal feedback:

It would have been helpful if there had been a more descriptive documentation explaining about doing basic things using ChakraCore, like how to expose classes to js, how to receive objects from js with the current state, namespaces, how to get/set attributes, how to invoke a js function, and how to export a C++ function to js. We had to dig into the sample projects hosted in the github page to understand how to do things in ChakraCore. A better documentation could have helped and saved time for us.

If this information is already available in a form other than the example projects, we should try to improve the discoverability of that info.


Adding @liminzhu's list of topics to the main post so we get the handy progress meter:

@liminzhu
Copy link
Member

liminzhu commented Aug 9, 2016

NOTE: new edits to the list will be added to the main post instead of to this comment.

Good input. I think I've done all of those in this sample, but some documentation with small code snippets would've been more helpful. I'll look into it when I'm free.

Creating a list of topics,

  • Expose native functions / external objects to JavaScript
  • Handle object lifetime
  • Implement a simple event-loop and task queue + using promises in JSRT
  • Script serialization with lazy source loading
  • Resource throttling
  • Define non-writable property from C/C++(a.k.a. using descriptor)
  • Define C/C++ Getter and Setter
  • TypedArray handling in C/C++

Edited:
Add some stuff per microsoft/Chakra-Samples#51 @kphillisjr

@kphillisjr
Copy link

Might want to add "Embed JavaScript functions in C/C++"... This may not be used very often, but there is cases where the implementation of a function is a lot easier to use JavaScript than it is C/C++.

// This is the toString function defined using JavaScript, 
// but is embedded in C/C++ code.
function toString() {
  return `Point (${this.x}, ${this.y}, ${this.z})`
}

@jaredwy
Copy link

jaredwy commented Feb 28, 2017

Something that would provide a lot of value. Something quiet common is how to wrap a c++ object so it is accessible from js.

Something similar to https://chromium.googlesource.com/v8/v8/+/master/samples/process.cc would be good.

@liminzhu
Copy link
Member

Yeah. I think this one (I added "external objects" just now) on my list would help,

Expose native functions / external objects to JavaScript

@jaredwy
Copy link

jaredwy commented Feb 28, 2017

Great :)

@dilijev
Copy link
Contributor Author

dilijev commented Feb 28, 2017

Updated list in the main post so we get the progress meter from the issues page as we complete these items.

@jaredwy
Copy link

jaredwy commented Mar 1, 2017

@dilijev It would be good to call out that the samples should be accessible cross platform as well as just windows. The opengl sample is great, but uses some windows only features.

@dilijev
Copy link
Contributor Author

dilijev commented Mar 1, 2017

@jaredwy -- Makes sense. For the APIs that are xplat-compatible, the samples should be xplat-compatible. But because they are example snippets, they might not compile on their own without setting up a project like the samples do. Short samples in documentation will not be perfect and super easy, but may be possible to copy-paste into an existing project.

For the Windows-only APIs, they'll obviously only work on Windows. There are a few of these.

@jaredwy
Copy link

jaredwy commented Mar 1, 2017

@dilijev Yup. It would be good just to avoid things like JSPointerToString and JsGetPropertyNameFromId even in projects that are windows only and c++. That is what threw me the most. I was using the opengl sample as a guide and ended up being thrown when attempting to compile copy and pasted code :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants