BREAKING: Change the toValue in JSCExecutor to ValueEncoder<T>::toValue

Summary:
The C++ standard requires that when a function is used in a template it's prototype needs to be defined not only before the template specialization, but also before the template itself.

Because of that one needs to (in certain compilers) be aware of the proper order of includes so that the function prototype is defined before the JSCExecutor.h is included.

As a workaround the toValue might be written as a template (ValueEncoder<T>::toValue) defined in JSCExecutor.h instead of being an non-existing symbol.
Thanks to that the JSCExecutor.h does not have to be included before the specialization of the ValueEncoder template.

Reviewed By: mhorowitz

Differential Revision: D4182724

fbshipit-source-id: 9bdf239ae66ef7a7d2c82daf7db5926472687bde
This commit is contained in:
Lukas Piatkowski 2016-11-24 09:25:06 -08:00 committed by Facebook Github Bot
parent 5e008c932c
commit bd524bd6e8
1 changed files with 6 additions and 2 deletions

View File

@ -48,6 +48,9 @@ public:
Object jsObj;
};
template <typename T>
struct ValueEncoder;
class RN_JSC_EXECUTOR_EXPORT JSCExecutor : public JSExecutor {
public:
/**
@ -91,8 +94,9 @@ public:
template <typename T>
Value callFunctionSync(
const std::string& module, const std::string& method, T&& args) {
return callFunctionSyncWithValue(module, method,
toValue(m_context, std::forward<T>(args)));
return callFunctionSyncWithValue(
module, method, ValueEncoder<typename std::decay<T>::type>::toValue(
m_context, std::forward<T>(args)));
}
virtual void setGlobalVariable(