Re: [v8-users] question on the sample file process.cc

2017-06-30 Thread wxz
Thanks for the explanation, but it's still blur to me.  I'm trying to wrap 
those two maps into an interceptor class.  Please see the attached.  It 
works for lines such as:  
if (option.verbose)

but it fails on lines:
output[request.host] = 1;

The script runs, but the final output is:
google.com:
google.net:
google.org:
yahoo.com:

Instead, the correct result should be:
google.com: 1
google.net: 1
google.org: 1
yahoo.com: 3

On Friday, June 30, 2017 at 11:21:11 AM UTC-4, Jakob Kummerow wrote:
>
> There are no conversions happening. In the script, "output" is a regular 
> JavaScript object, with all the behavior you would expect.
>
> On the C++ side, "output" is a map, but "output_obj" is a 
> JavaScript object created from that map (via the WrapMap(output) call), 
> and that's what's exposed to the script.
>
>
> On Fri, Jun 30, 2017 at 3:31 PM, wxz  
> wrote:
>
>> a follow up question, in the script, the 'output' map is used as 
>> map:
>>
>> output[request.host] = 1;
>> output[request.host]++
>>
>> however, it's a map in c++ side, which part of the c++ 
>> code handles such conversion?
>>
>>
>> On Thursday, June 29, 2017 at 5:07:20 PM UTC-4, Jakob Kummerow wrote:
>>
>>> The equivalent of options.verbose is options["verbose"] (note the 
>>> quotes). Does that help?
>>>
>>> On Thu, Jun 29, 2017 at 10:07 PM, wxz  wrote:
>>>
 hi all,

 there are two maps used in this example, one for 'options', one for 
 'output'. My question is, why is that in the script, the brackets [] works 
 for 'output', but not for 'options'?

 For example, if change the line:
 options.verbose  ===> options[verbose]
 it returns error: verbose is not defined

 However, 'output[request.host]' is perfectly fine.

 The two maps are installed with the same code, the wrap/unwrap are the 
 same, what's the difference?

 I guess my confusion is what exactly does bracket mean here? Does it 
 invoke the named property interceptor?

 -- 
 -- 
 v8-users mailing list
 v8-u...@googlegroups.com
 http://groups.google.com/group/v8-users
 --- 
 You received this message because you are subscribed to the Google 
 Groups "v8-users" group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to v8-users+u...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>>
>>> -- 
>> -- 
>> v8-users mailing list
>> v8-u...@googlegroups.com 
>> http://groups.google.com/group/v8-users
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "v8-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to v8-users+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
#include "map_interceptor.h"

Local MapInterceptor::GetNamedProperty(v8::Isolate* isolate,
const std::string& property)
{
if (internal_map.count(property)) {
return gin::ConvertToV8(isolate, internal_map[property]);
}
else {
return Local();
}
}

bool MapInterceptor::SetNamedProperty(v8::Isolate* isolate,
const std::string& property, v8::Local value)
{
internal_map[property] = gin::V8ToString(value);
return true;
}

std::vector MapInterceptor::EnumerateNamedProperties(
v8::Isolate* isolate)
{
std::vector result;
for (auto it = internal_map.begin(); it != internal_map.end(); ++it) {
result.push_back(it->first);
}
return result;
}
#pragma once

#include "gin/arguments.h"
#include "gin/handle.h"
#include "gin/interceptor.h"
#include "gin/object_template_builder.h"

#include "gin/wrappable.h"
#include "gin/public/wrapper_info.h"

#include "v8.h"

#include 
#include 
#include 
#include 

using gin::Wrappable;
using gin::NamedPropertyInterceptor;
using gin::WrapperInfo;

using v8::Isolate;
using v8::Local;

class MapInterceptor : public Wrappable,
   public NamedPropertyInterceptor
{
public:
static WrapperInfo kWrapperInfo;

static gin::Handle Create(v8::Isolate* isolate) {
return gin::CreateHandle(isolate, new MapInterceptor(isolate));
}

// gin::NamedPropertyInterceptor
Local GetNamedProperty(v8::Isolate* isolate,
const std::string& property);

bool SetNamedProperty(v8::Isolate* isolate,
  const std::string& property,
  v8::Local value);

std::vector EnumerateNamedProperties(
 

Re: [v8-users] question on the sample file process.cc

2017-06-30 Thread Jakob Kummerow
There are no conversions happening. In the script, "output" is a regular
JavaScript object, with all the behavior you would expect.

On the C++ side, "output" is a map, but "output_obj" is a
JavaScript object created from that map (via the WrapMap(output) call), and
that's what's exposed to the script.


On Fri, Jun 30, 2017 at 3:31 PM, wxz  wrote:

> a follow up question, in the script, the 'output' map is used as
> map:
>
> output[request.host] = 1;
> output[request.host]++
>
> however, it's a map in c++ side, which part of the c++
> code handles such conversion?
>
>
> On Thursday, June 29, 2017 at 5:07:20 PM UTC-4, Jakob Kummerow wrote:
>
>> The equivalent of options.verbose is options["verbose"] (note the
>> quotes). Does that help?
>>
>> On Thu, Jun 29, 2017 at 10:07 PM, wxz  wrote:
>>
>>> hi all,
>>>
>>> there are two maps used in this example, one for 'options', one for
>>> 'output'. My question is, why is that in the script, the brackets [] works
>>> for 'output', but not for 'options'?
>>>
>>> For example, if change the line:
>>> options.verbose  ===> options[verbose]
>>> it returns error: verbose is not defined
>>>
>>> However, 'output[request.host]' is perfectly fine.
>>>
>>> The two maps are installed with the same code, the wrap/unwrap are the
>>> same, what's the difference?
>>>
>>> I guess my confusion is what exactly does bracket mean here? Does it
>>> invoke the named property interceptor?
>>>
>>> --
>>> --
>>> v8-users mailing list
>>> v8-u...@googlegroups.com
>>> http://groups.google.com/group/v8-users
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "v8-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to v8-users+u...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> --
> v8-users mailing list
> v8-users@googlegroups.com
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to v8-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [v8-users] question on the sample file process.cc

2017-06-30 Thread wxz
a follow up question, in the script, the 'output' map is used as 
map:

output[request.host] = 1;
output[request.host]++

however, it's a map in c++ side, which part of the c++ code 
handles such conversion?


On Thursday, June 29, 2017 at 5:07:20 PM UTC-4, Jakob Kummerow wrote:

> The equivalent of options.verbose is options["verbose"] (note the 
> quotes). Does that help?
>
> On Thu, Jun 29, 2017 at 10:07 PM, wxz  
> wrote:
>
>> hi all,
>>
>> there are two maps used in this example, one for 'options', one for 
>> 'output'. My question is, why is that in the script, the brackets [] works 
>> for 'output', but not for 'options'?
>>
>> For example, if change the line:
>> options.verbose  ===> options[verbose]
>> it returns error: verbose is not defined
>>
>> However, 'output[request.host]' is perfectly fine.
>>
>> The two maps are installed with the same code, the wrap/unwrap are the 
>> same, what's the difference?
>>
>> I guess my confusion is what exactly does bracket mean here? Does it 
>> invoke the named property interceptor?
>>
>> -- 
>> -- 
>> v8-users mailing list
>> v8-u...@googlegroups.com 
>> http://groups.google.com/group/v8-users
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "v8-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to v8-users+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] Announcement: V8's x87 port is going away

2017-06-30 Thread Jakob Kummerow
Ever since V8's "ia32" port (for 32-bit x86 platforms) has started
requiring SSE2 instruction support in 2014, there has been an "x87" port to
allow V8 to continue to run on x86 hardware that does not support SSE2
instructions.

Due to a lack of stakeholders in the "x87" port, and the ongoing
maintenance burden it creates for the team, we are planning to drop it from
the V8 repository. (Note that the "ia32" port is unaffected and will
continue to be actively developed.)

If you have any concerns about this deprecation, please speak up now.
Otherwise the removal will happen in two weeks.

--Jakob

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.