On Tue, Oct 14, 2014 at 7:20 AM, Jane Chen jxche...@gmail.com wrote:
If I don't set return value, and only operate on This, how do I associate a
different C++ object to the newly constructed JS object?
You store the pointer to the C++ object in an InternalField slot on
the .This() object.
Make
Yes, that works. But every time the callback function is called, This()
object is the same one.
On Tuesday, October 14, 2014 6:03:30 AM UTC-7, Ben Noordhuis wrote:
On Tue, Oct 14, 2014 at 7:20 AM, Jane Chen jxch...@gmail.com
javascript: wrote:
If I don't set return value, and only
Please ignore my last post. Things are working for me now.
Thanks a lot for your support Ben!
Jane
On Tuesday, October 14, 2014 6:03:30 AM UTC-7, Ben Noordhuis wrote:
On Tue, Oct 14, 2014 at 7:20 AM, Jane Chen jxch...@gmail.com
javascript: wrote:
If I don't set return value, and
If I don't set return value, and only operate on This, how do I associate a
different C++ object to the newly constructed JS object?
The reason that I kept trying to return something other than This was
because I need to dynamically create objects backed by different C++
objects each time the
On Fri, Oct 10, 2014 at 11:14 PM, Jane Chen jxche...@gmail.com wrote:
One more try:
In my constructor function foo:
static void
foo(const v8::FunctionCallbackInfov8::Value args)
{
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope handleScope(isolate);
On Wed, Oct 8, 2014 at 12:59 AM, Jane Chen jxche...@gmail.com wrote:
Picking up this thread again:
I have no problem exposing the class to the global context uisng the pattern
shown above. My problem is that the returned value of the class constructor
is not an instanceof that class if I
Ben,
I was able to get instanceof returning true following your tips. Thanks.
But it seems to me this design assumes that there is only a singleton
Function we are operating on as I'm always interacting with This, which is
the function returned from FunctionTemplate.GetFunction().
If I
Ben,
How am I supposed to expose the class to the global object?
I have this:
// create and bind XMLBuilder function
v8::Localv8::FunctionTemplate bldrTemp =
v8::FunctionTemplate::New(isolate,createBuilder);
v8::Localv8::String bldrLabel =
v8::String::NewFromUtf8(isolate, XMLBuilder);
On Wed, Jul 9, 2014 at 9:01 PM, Jane Chen jxche...@gmail.com wrote:
Ben,
How am I supposed to expose the class to the global object?
I have this:
// create and bind XMLBuilder function
v8::Localv8::FunctionTemplate bldrTemp =
v8::FunctionTemplate::New(isolate,createBuilder);
On 26 June 2014 18:48, Jane Chen jxche...@gmail.com wrote:
I have an object instantiated from a template, which has a class name set.
When I do instanceof on it in JavaScript, it only shows it's an object, but
not of my class. My class seems unknown. Does v8 provide a callback API
for
Ben,
Say if my class is called ValueIterator, and it is an instance of it, if
I do:
Object.prototype.toString.call(it);
[object ValueIterator]
it instanceof ValueIterator;
(shell):1: ReferenceError: ValueIterator is not defined
it instanceof ValueIterator;
^
ReferenceError:
On Fri, Jun 27, 2014 at 9:29 PM, Jane Chen jxche...@gmail.com wrote:
Ben,
Say if my class is called ValueIterator, and it is an instance of it, if I
do:
Object.prototype.toString.call(it);
[object ValueIterator]
it instanceof ValueIterator;
(shell):1: ReferenceError: ValueIterator is not
On Thu, Jun 26, 2014 at 6:48 PM, Jane Chen jxche...@gmail.com wrote:
I have an object instantiated from a template, which has a class name set.
When I do instanceof on it in JavaScript, it only shows it's an object, but
not of my class. My class seems unknown. Does v8 provide a callback API
On 28 June 2012 00:45, Vyacheslav Egorov vego...@chromium.org wrote:
Unfortunately no. Normal JavaScript objects do not work with
ReattachGlobal. It expects JSGlobalProxy (which cannot be created
through an API separately from a Context). Quoting v8.h:
/**
* Reattaches a global object to
How can I re-use the same built-ins each time?
There is no way. New context means new built-in objects. Also
reattaching global does not change anything because built-ins are not
on the global object itself.
If you want to reuse the same builtins you don't ultimately need a new
context. Just
There is no way. New context means new built-in objects. Also
reattaching global does not change anything because built-ins are not
on the global object itself.
Holy Javascript Batman! That explains a lot!
So where are they kept (the built-ins)? Are the hooked in via prototype
chain to the
So where are they kept (the built-ins)? Are the hooked in via prototype chain
to the global object?
Yes, they are. Quoting comments in v8.h:
/**
* Returns the global proxy object or global object itself for
* detached contexts.
*
* Global proxy object is a thin wrapper whose
Array function in one context is different from Array function in
another context as each context is a separate world with it's own
built-in objects.
You can use Array.isArray which should work cross-context.
--
Vyacheslav Egorov
On Mon, Jun 25, 2012 at 9:08 PM, MikeM mi...@reteksolutions.com
On Tue, Jun 26, 2012 at 5:34 PM, MikeM mi...@reteksolutions.com wrote:
I suppose I could keep using the same Context over and over, but I would
need a way to wipe out any local var declarations between executions and
only keep the built-ins.
On a similar note, you probably couldn't protect
Seems to me that what you're trying to do won't work.
You may be able to create a global object template and call
ReattachGlobalObject(globalTemplate-NewInstance()), but I haven't tried that.
On Jun 26, 2012, at 8:34 AM, MikeM wrote:
Array function in one context is different from Array
On a similar note, you probably couldn't protect against:
Array.foo = whatever;
i suspect that the only safe way to do it is recreate the whole sandbox
on each run. Not doing so will eventually lead to weird behaviours, i
think (via sneaky modifications like custom properties on built-ins).
Seems to me that what you're trying to do won't work.
Why?
You may be able to create a global object template and call
ReattachGlobalObject(globalTemplate-NewInstance()), but I haven't tried
that.
V8 is still a bit foreign to me. I'm trying to break that barrier. How do
I create a global
On Tue, Jun 26, 2012 at 6:27 PM, MikeM mi...@reteksolutions.com wrote:
V8 is still a bit foreign to me. I'm trying to break that barrier.
Welcome aboard - i hope we can help you get over the initial humps. It can
be a bumpy ride.
How do I create a global template with a complete set of
On Tue, Jun 26, 2012 at 6:53 PM, Stephan Beal sgb...@googlemail.com wrote:
Welcome aboard - i hope we can help you get over the initial humps. It can
be a bumpy ride.
Tip #0, in case you haven't come across this already: always develop
against a debug build of libv8. Not doing so is basically
Tip #0, in case you haven't come across this already: always develop
against a debug build of libv8. Not doing so is basically futile because v8
_will_ crash when you mis-use it (and you _will_ mis-use it at times) and
the debug builds dump a surprising amount of detail about the crash to
From my understanding you've already done that, but you're trying to take
it a step further and transport the object from its initial context to
another one.
Can that work? i don't know for certain, but i _suspect_ the answer is
something along the line of it can, with some notable caveats
On Tue, Jun 26, 2012 at 7:21 PM, MikeM mi...@reteksolutions.com wrote:
I'm open to any method of making this happen.
Thanks for the help!
i unfortunately cannot say much on the topic of multiple contexts and
de/serialization of v8 state across requests, but i suspect that Michael
Schwartz
I don't think you're going to be able to have a persistent/static global object
that can quickly be reset between requests like MikeM is trying to do.
From my research, the v8 examples (lineprocessor, etc.) instantiate a global
object and context frequently, but do not do anything like trying
On Tue, Jun 26, 2012 at 7:47 PM, Michael Schwartz myk...@gmail.com wrote:
Something else I discovered early on in SilkJS development is that you can
call from JS, a C++ function that calls fork() and returns. After the
return, you have a parent and child process resuming in JS context. The
From the OSX man page for fork:
Fork() causes creation of a new process. The new process (child process)
is an exact copy of the calling process (parent process) except for the
following:
o The child process has a unique process ID.
o The child process
On Tue, Jun 26, 2012 at 8:13 PM, Michael Schwartz myk...@gmail.com wrote:
o The child process has its own copy of the parent's
descriptors.
These descriptors reference the same underlying objects, so
that, for instance, file pointers in file objects
Sharing the bound (see bind() ) socket with the child processes is pretty
awesome for pre-fork servers.
The SilkJS HTTP server provides a hook, HttpChild.onStart. If you point that
at a function, it will be called when a child is forked. That's where you'd
open a MySQL connection, a
Tue, Jun 26, 2012 at 8:26 PM, Michael Schwartz myk...@gmail.com wrote:
You can also encounter this error with applications that fork child
processes, all of which try to use the same connection to the MySQL server.
This can be avoided by using a separate connection for each child process.
You wouldn't have a problem with SilkJS. Something like this works:
(function() {
var handle = null;
...
function connect() {
if (!handle) {
handle = mysql.connect();
}
}
...
exports.connect
34 matches
Mail list logo