GetPointerFromInternalField deprecated?

292 views
Skip to first unread message

Flying Jester

unread,
Feb 22, 2013, 5:26:16 PM2/22/13
to v8-u...@googlegroups.com
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

I've seen the 'aligned' version of this function, GetAlignedPointerInInternalField. 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<v8::Object> color = v8::Local<v8::Object>::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.

Stephan Beal

unread,
Feb 22, 2013, 5:43:26 PM2/22/13
to v8-u...@googlegroups.com
On Fri, Feb 22, 2013 at 11:26 PM, Flying Jester <foolki...@gmail.com> 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:

--
----- stephan beal
http://wanderinghorse.net/home/stephan/

Sven Panne

unread,
Feb 25, 2013, 2:41:27 AM2/25/13
to v8-u...@googlegroups.com
On Fri, Feb 22, 2013 at 11:26 PM, Flying Jester <foolki...@gmail.com> 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, GetAlignedPointerInInternalField. 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<v8::Object> color = v8::Local<v8::Object>::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.
Reply all
Reply to author
Forward
0 new messages