Skip to content

Commit

Permalink
BREAKING: Change the toValue in JSCExecutor to ValueEncoder<T>::toValue
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lukaspiatkowski authored and Facebook Github Bot committed Nov 24, 2016
1 parent 5e008c9 commit bd524bd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ReactCommon/cxxreact/JSCExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class WorkerRegistration : public noncopyable {
Object jsObj;
};

template <typename T>
struct ValueEncoder;

class RN_JSC_EXECUTOR_EXPORT JSCExecutor : public JSExecutor {
public:
/**
Expand Down Expand Up @@ -91,8 +94,9 @@ class RN_JSC_EXECUTOR_EXPORT JSCExecutor : public JSExecutor {
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(
Expand Down

0 comments on commit bd524bd

Please sign in to comment.