Re: [v8-users] GetPointerFromInternalField deprecated?

2013-02-24 Thread Sven Panne
On Fri, Feb 22, 2013 at 11:26 PM, Flying Jester wrote:

> I recently updated the version of V8 I build my project against, and I was
> greeted with a new warning:
>
> warning: ‘void* v8::Object::GetPointerFromInternalField(int)’ is deprecated
>

v8's external API is currently changing a bit, and will probably continue
to do so for several months. Our general approach is to deprecate an API
entry for 1 stable version, giving embedders time to adapt, and remove it
after that. In the case at hand, GetPointerFromInternalField was deprecated
in 3.15 and removed in 3.16. If there is a more or less mechanical way to
replace a deprecated API entry, this will be noted in v8.h, e.g.:
/**
* Gets a native pointer from an internal field. Deprecated. If the pointer
is
* always 2-byte-aligned, use GetAlignedPointerFromInternalField instead,
* otherwise use a combination of GetInternalField, External::Cast and
* External::Value.
*/
V8EXPORT V8_DEPRECATED(void* GetPointerFromInternalField(int index)); In
general, v8.h is the most up-to-date form of "API documentation". The web
pages/tutorials might be out of sync and will get an overhaul at some later
point in time.


> I've seen the 'aligned' version of this function,
> GetAlignedPointerInInternalFie**ld. How would I go about replacing my
> usage of GetPointerFromInternalField with this new function? I don't use
> the setter function, I'm using GetPointerFromInternalField to get a C++
> side object from JS functions, like this:
>
> v8::Local color = v8::Local::Cast(args[0]);
>
> TS_Color* c = (TS_Color*)color->GetPointerFromInternalField(0);
>
> This obviously doesn't work with a 1 to 1 replacement with the aligned
> version of the function.
>

It depends: If you are sure that your TS_Color* is aligned, the aligned
version is an easy and extremely efficient 1:1 replacement. If you are
unsure, use the slow route as described in the comment.

-- 
-- 
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/groups/opt_out.




Re: [v8-users] GetPointerFromInternalField deprecated?

2013-02-22 Thread Stephan Beal
On Fri, Feb 22, 2013 at 11:26 PM, Flying Jester wrote:

> This obviously doesn't work with a 1 to 1 replacement with the aligned
> version of the function.
>

Welcome to the club :). What i ended up doing (because the Aligned version
kept inexplicably asserting when given pointers allocated with (new T)),
was to use an explicit v8::External wrapper to hold my pointer and
replacing the PointerTo/FromInternalField calls with the "normal"
InternalFields calls.

Example usages:
set:
https://code.google.com/p/v8-juice/source/browse/convert/include/cvv8/ClassCreator.hpp#776
get:
https://code.google.com/p/v8-juice/source/browse/convert/include/cvv8/ClassCreator.hpp#603

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
-- 
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/groups/opt_out.