Re: [v8-juice] r2169 committed - Removed the ClassCreator_TypeID class entirely due to compile issues i...

2 views
Skip to first unread message

Stephan Beal

unread,
Dec 7, 2011, 1:01:44 PM12/7/11
to v8-juic...@googlegroups.com
@Coen: FYI, as expected this broke the gcc build, but don't worry about it. i would be happy to get rid of the TypeID bits. i will work on fixing them this weekend.

On Sun, Dec 4, 2011 at 10:23 PM, <v8-j...@googlecode.com> wrote:
Revision: 2169
Author:   coen.c...@gmail.com
Date:     Sun Dec  4 13:22:34 2011
Log:      Removed the ClassCreator_TypeID class entirely due to compile issues in MSVC. (Note: Untested in GCC)
http://code.google.com/p/v8-juice/source/detail?r=2169

Modified:
 /convert/include/cvv8/ClassCreator.hpp
 /convert/include/cvv8/detail/convert_core.hpp

=======================================
--- /convert/include/cvv8/ClassCreator.hpp      Sun Aug 14 19:48:22 2011
+++ /convert/include/cvv8/ClassCreator.hpp      Sun Dec  4 13:22:34 2011
@@ -172,50 +172,6 @@
    struct ClassCreator_SearchPrototypeForThis : Opt_Bool<true>
    {};

-    /**
-        ClassCreator policy type which defines a "type ID" value
-        for a type wrapped using ClassCreator. This is used
-        together with JSToNative_ObjectWithInternalFieldsTypeSafe
-        (type THAT 10 times fast) to provide a lightweight
-        (but highly effective) type check when extracting
-        natives from v8 (as void pointers). The default
-        implementation is fine for all cases i can think of, but i can
-        concieve of one or two uses for specializations (e.g. storing the
-        JS-side name of the class as the type ID).
-
-        The type id must be unique per type except that subtypes may
-        (depending on various other binding options) may need use the same
-        value as the parent type. If multiple types share the same type ID,
-        the type-safety check can be bypassed, _potentially_ leading to an
-        illegal static_cast() and subsequent mis-use of the pointer. i
-        stress the word "potentially" because to get that condition one
-        would have to (A) abuse the object via the C++ API (which doesn't
-        happen via the binding process, and you're probably also not going
-        to do it) or (B) write some script code to confuse two bound native
-        types about who is really who when a particular member is called.
-
-        In the case of subclassed bound types, the
-        ClassCreator_TypeID<SubClass> impl should subclass
-        ClassCreator_TypeID<ParentClass>. Whether or not this is _required_
-        for proper functionality depends at least in part on whether
-        (ClassCreator_InternalFields<ParentType>::TypeIDIndex>=0). If it is
-        negative, subclasses do not need to explicitly define this policy
-        because the type ID won't be used for purposes of validating a JS-held
-        pointer's native type.
-
-        TODO: see if we can consolidate this type with TypeName<>. The problem
-        at the moment is that JSToNative_ObjectWithInternalFieldsTypeSafe
-        takes a (void const * &) and TypeName::Value is a (char const *), which
-        won't convert to (void const *) in the context of template parameters.
-    */
-    template <typename T>
-    struct ClassCreator_TypeID
-    {
-        static const void * Value;
-    };
-    template <typename T>
-    const void * ClassCreator_TypeID<T>::Value = TypeName<T>::Value;
-
    /**
       Convenience base type for ClassCreator_InternalFields
       implementations.
@@ -567,7 +523,7 @@
    private:
        typedef ClassCreator_InternalFields<T> InternalFields;
        typedef ClassCreator_WeakWrap<T> WeakWrap;
-        typedef ClassCreator_TypeID<T> TypeID;
+        typedef TypeName<T> TypeID;
        v8::Persistent<v8::FunctionTemplate> ctorTmpl;
        v8::Handle<v8::ObjectTemplate> protoTmpl;
        bool isSealed;
@@ -1089,7 +1045,7 @@
    struct JSToNative_ClassCreator :
        tmp::IfElse< TypeSafe,
            JSToNative_ObjectWithInternalFieldsTypeSafe<T,
-                                            ClassCreator_TypeID<T>::Value,
+                                            TypeName<T>::Value,
                                            ClassCreator_InternalFields<T>::Count,
                                            ClassCreator_InternalFields<T>::TypeIDIndex,
                                            ClassCreator_InternalFields<T>::NativeIndex,
=======================================
--- /convert/include/cvv8/detail/convert_core.hpp       Sun Aug 14 19:15:25 2011
+++ /convert/include/cvv8/detail/convert_core.hpp       Sun Dec  4 13:22:34 2011
@@ -942,7 +942,7 @@
        NULL instead of performing an illegal cast).
    */
    template <typename T,
-              void const * & TypeID,
+              char const * & TypeID,
              int InternalFieldCount = 2,
              int TypeIdFieldIndex = 0,
              int ObjectFieldIndex = 1,
@@ -989,7 +989,7 @@
                    tid = (obj->InternalFieldCount() != InternalFieldCount)
                        ? NULL
                        : obj->GetPointerFromInternalField( TypeIdFieldIndex );
-                    ext = (tid == TypeID)
+                    ext = (tid == (void*)TypeID)
                        ? obj->GetPointerFromInternalField( ObjectFieldIndex )
                        : NULL;
                    if( ! ext )



--
----- stephan beal
http://wanderinghorse.net/home/stephan/
Reply all
Reply to author
Forward
0 new messages