pmed / v8pp

Bind C++ functions and classes into V8 JavaScript engine
http://pmed.github.io/v8pp/
Other
898 stars 120 forks source link

context.cpp does not compile with ambiguous template instantiation errors #20

Closed whoozle closed 8 years ago

whoozle commented 8 years ago
In file included from v8pp/v8pp/context.hpp:17:0,
                 from v8pp/v8pp/context.cpp:9:
v8pp/v8pp/convert.hpp: In substitution of ‘template<class T> typename v8pp::convert<T>::to_type v8pp::to_v8(v8::Isolate*, const T&) [with T = v8::Handle<v8::Value>]’:
v8pp/v8pp/context.cpp:136:50:   required from here
v8pp/v8pp/convert.hpp:627:30: error: ambiguous template instantiation for ‘struct v8pp::convert<v8::Handle<v8::Value>, void>’
 typename convert<T>::to_type to_v8(v8::Isolate* isolate, T const& value)
                              ^
v8pp/v8pp/convert.hpp:432:8: note: candidates are: template<class T> struct v8pp::convert<v8::Handle<T>, typename std::enable_if<(! std::is_same<v8::Handle<T>, v8::Local<T> >::value)>::type> [with T = v8::Value]
 struct convert<v8::Handle<T>, typename std::enable_if<
        ^
v8pp/v8pp/convert.hpp:555:8: note:                 template<class T> struct v8pp::convert<T, typename std::enable_if<v8pp::is_wrapped_class<T>::value>::type> [with T = v8::Handle<v8::Value>]
 struct convert<T, typename std::enable_if<is_wrapped_class<T>::value>::type>
        ^
v8pp/v8pp/context.cpp: In static member function ‘static void v8pp::context::run_file(const v8::FunctionCallbackInfo<v8::Value>&)’:
v8pp/v8pp/context.cpp:136:50: error: no matching function for call to ‘to_v8(v8::Isolate*&, v8::Handle<v8::Value>)’
   result = to_v8(isolate, ctx->run_file(filename));
                                                  ^
In file included from v8pp/v8pp/context.hpp:17:0,
                 from v8pp/v8pp/context.cpp:9:
v8pp/v8pp/convert.hpp:602:31: note: candidate: v8::Handle<v8::String> v8pp::to_v8(v8::Isolate*, const char*, size_t)
 inline v8::Handle<v8::String> to_v8(v8::Isolate* isolate, char const* str, size_t len)
                               ^
v8pp/v8pp/convert.hpp:602:31: note:   candidate expects 3 arguments, 2 provided
v8pp/v8pp/convert.hpp:608:24: note: candidate: template<long unsigned int N> v8::Handle<v8::String> v8pp::to_v8(v8::Isolate*, const char (&)[N], size_t)
 v8::Handle<v8::String> to_v8(v8::Isolate* isolate, char const (&str)[N], size_t len = N - 1)
                        ^
v8pp/v8pp/convert.hpp:608:24: note:   template argument deduction/substitution failed:
v8pp/v8pp/context.cpp:136:50: note:   mismatched types ‘const char [N]’ and ‘v8::Handle<v8::Value>’
   result = to_v8(isolate, ctx->run_file(filename));
                                                  ^
In file included from v8pp/v8pp/context.hpp:17:0,
                 from v8pp/v8pp/context.cpp:9:
v8pp/v8pp/convert.hpp:627:30: note: candidate: template<class T> typename v8pp::convert<T>::to_type v8pp::to_v8(v8::Isolate*, const T&)
 typename convert<T>::to_type to_v8(v8::Isolate* isolate, T const& value)
                              ^
v8pp/v8pp/convert.hpp:627:30: note:   substitution of deduced template arguments resulted in errors seen above
v8pp/v8pp/convert.hpp:633:23: note: candidate: template<class Iterator> v8::Handle<v8::Array> v8pp::to_v8(v8::Isolate*, Iterator, Iterator)
 v8::Handle<v8::Array> to_v8(v8::Isolate* isolate, Iterator begin, Iterator end)
                       ^
v8pp/v8pp/convert.hpp:633:23: note:   template argument deduction/substitution failed:
v8pp/v8pp/context.cpp:136:50: note:   candidate expects 3 arguments, 2 provided
   result = to_v8(isolate, ctx->run_file(filename));
                                                  ^
In file included from v8pp/v8pp/context.hpp:17:0,
                 from v8pp/v8pp/context.cpp:9:
v8pp/v8pp/convert.hpp:646:23: note: candidate: template<class T> v8::Handle<v8::Array> v8pp::to_v8(v8::Isolate*, const std::initializer_list<_Tp>&)
 v8::Handle<v8::Array> to_v8(v8::Isolate* isolate, std::initializer_list<T> const& init)
                       ^
v8pp/v8pp/convert.hpp:646:23: note:   template argument deduction/substitution failed:
v8pp/v8pp/context.cpp:136:50: note:   ‘v8::Handle<v8::Value>’ is not derived from ‘const std::initializer_list<_Tp>’
   result = to_v8(isolate, ctx->run_file(filename));
                                                  ^
v8pp/v8pp/context.cpp: In constructor ‘v8pp::context::context(v8::Isolate*)’:
v8pp/v8pp/context.cpp:168:17: error: ‘struct v8::Isolate::CreateParams’ has no member named ‘array_buffer_allocator’
   create_params.array_buffer_allocator = &array_buffer_allocator_;
                 ^
pmed commented 8 years ago

Hi,

Which V8 version do you use? I have built and run successfully tests with V8 version 5.0.71.33 on OS X

pmed commented 8 years ago

I also replaced obsoleted v8::Handle to v8::Local and pushed this as a new https://github.com/pmed/v8pp/tree/local-handles branch. Please, try it.

whoozle commented 8 years ago

v8 version: 3.32.7 I have to use old one, I have armv4 to support and it's impossible since 4.0+

whoozle commented 8 years ago
In file included from v8pp/v8pp/function.hpp:16:0,
                 from v8pp/v8pp/module.hpp:15,
                 from src/pure/ui/Console.h:4,
                 from src/pure/ui/Isolate.cpp:2:
v8pp/v8pp/throw_ex.hpp:24:86: error: invalid conversion from ‘v8::Local<v8::Value> (*)(v8::Handle<v8::String>)’ to ‘v8::Local<v8::Value> (*)(v8::Local<v8::String>)’ [-fpermissive]
  v8::Local<v8::Value> (*exception_ctor)(v8::Local<v8::String>) = v8::Exception::Error)
                                                                                      ^
v8pp/v8pp/throw_ex.hpp:45:86: error: invalid conversion from ‘v8::Local<v8::Value> (*)(v8::Handle<v8::String>)’ to ‘v8::Local<v8::Value> (*)(v8::Local<v8::String>)’ [-fpermissive]
  v8::Local<v8::Value> (*exception_ctor)(v8::Local<v8::String>) = v8::Exception::Error)
                                                                                      ^
pmed commented 8 years ago

Hmm, support of such old version would be quite hard. At the current time I can't realize how to manage this.

Probably it maybe easier to change code on your site in the master branch in file v8pp/convert.hpp

template<typename T>
struct is_wrapped_class<v8::Handle<T>, typename std::enable_if<
    !std::is_same<v8::Handle<T>, v8::Local<T>>::value, int>::type> : std::false_type{};

to

template<typename T>
struct is_wrapped_class<v8::Handle<T>> : std::false_type {};
pmed commented 8 years ago

Fixed