Skip to content

Commit

Permalink
JSI: flag fabric specific code
Browse files Browse the repository at this point in the history
And some small formatting
  • Loading branch information
ericlewis committed Mar 14, 2019
1 parent 4755115 commit 960ba6a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions RNTester/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ target 'RNTester' do
# Fabric Pods, uncomment these to enable in RNTester
# pod 'React-Fabric', :path => '../ReactCommon'
# pod 'React-graphics', :path => '../ReactCommon/fabric/graphics'
# pod 'React-jsi/Fabric', :path => '../ReactCommon/jsi'
# pod 'React-RCTFabric', :path => '../React'
# pod 'Folly/Fabric', :podspec => '../third-party-podspecs/Folly.podspec'

Expand Down
15 changes: 14 additions & 1 deletion ReactCommon/jsi/JSCRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,10 @@ class JSCRuntime : public jsi::Runtime {
static JSStringRef stringRef(const jsi::String& str);
static JSStringRef stringRef(const jsi::PropNameID& sym);
static JSObjectRef objectRef(const jsi::Object& obj);

#ifdef RN_FABRIC_ENABLED
static JSObjectRef objectRef(const jsi::WeakObject& obj);
#endif

// Factory methods for creating String/Object
jsi::String createString(JSStringRef stringRef) const;
Expand Down Expand Up @@ -822,15 +825,23 @@ jsi::Array JSCRuntime::getPropertyNames(const jsi::Object& obj) {
}

jsi::WeakObject JSCRuntime::createWeakObject(const jsi::Object& obj) {
#ifdef RN_FABRIC_ENABLED
// TODO: revisit this implementation
JSObjectRef objRef = objectRef(obj);
return make<jsi::WeakObject>(makeObjectValue(objRef));
#else
throw std::logic_error("Not implemented");
#endif
}

jsi::Value JSCRuntime::lockWeakObject(const jsi::WeakObject& obj) {
#ifdef RN_FABRIC_ENABLED
// TODO: revisit this implementation
JSObjectRef objRef = objectRef(obj);
return jsi::Value(createObject(objRef));
#else
throw std::logic_error("Not implemented");
#endif
}

jsi::Array JSCRuntime::createArray(size_t length) {
Expand Down Expand Up @@ -1226,11 +1237,13 @@ JSObjectRef JSCRuntime::objectRef(const jsi::Object& obj) {
return static_cast<const JSCObjectValue*>(getPointerValue(obj))->obj_;
}

#ifdef RN_FABRIC_ENABLED
JSObjectRef JSCRuntime::objectRef(const jsi::WeakObject& obj) {
// TODO: revisit this implementation
return static_cast<const JSCObjectValue*>(getPointerValue(obj))->obj_;
}

#endif

void JSCRuntime::checkException(JSValueRef exc) {
if (JSC_UNLIKELY(exc)) {
throw jsi::JSError(*this, createValue(exc));
Expand Down
9 changes: 9 additions & 0 deletions ReactCommon/jsi/React-jsi.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,18 @@ Pod::Spec.new do |s|
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/Folly\"" }
s.header_dir = "jsi"
s.default_subspec = "Default"

s.dependency "boost-for-react-native", "1.63.0"
s.dependency "DoubleConversion"
s.dependency "Folly", folly_version
s.dependency "glog"

s.subspec "Default" do
# no-op
end

s.subspec "Fabric" do |ss|
ss.pod_target_xcconfig = { "OTHER_CFLAGS" => "$(inherited) -DRN_FABRIC_ENABLED" }
end
end
4 changes: 2 additions & 2 deletions third-party-podspecs/Folly.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ Pod::Spec.new do |spec|

spec.default_subspec = 'Default'

spec.subspec 'Default' do |default|
# no-op
spec.subspec 'Default' do
# no-op
end

spec.subspec 'Fabric' do |fabric|
Expand Down

0 comments on commit 960ba6a

Please sign in to comment.