When compiling this code (part of SpiderMonkey):
template<IsAcceptableThis Test, NativeImpl Impl>
JS_ALWAYS_INLINE bool
CallNonGenericMethod(JSContext *cx, CallArgs args)
{
const Value &thisv = args.thisv();
if (Test(thisv))
return Impl(cx, args);
return detail::CallMethodIfWrapped(cx, Test, Impl, args);
}
template<Value ValueGetter(JSObject *obj)>
static JSBool
Getter(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
return CallNonGenericMethod<ThisTypeArray::IsThisClass,
ThisTypeArray::GetterImpl<ValueGetter> >(cx, args);
}
I get this error, related to the invocation of CallNonGenericMethod
.
error : template parameter 'ValueGetter' of type 'JS::Value ()(JSObject*)' is not allowed in an integral constant expression because it is not of integral or enumeration type*
where ValueGetter
is
inline Value
TypedArray::lengthValue(JSObject *obj)
{
JS_ASSERT(obj->isTypedArray());
return obj->getFixedSlot(LENGTH_SLOT);
}
and
template<Value ValueGetter(JSObject *obj)>
static bool
GetterImpl(JSContext *cx, CallArgs args)
{
JS_ASSERT(IsThisClass(args.thisv()));
args.rval().set(ValueGetter(&args.thisv().toObject()));
return true;
}
I couldn't find any helpful information online, and I'm struggling to find what the problem is. Can anyone please clarify?
Many thanks.