This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ./android/app/src/main/java/com/cppreactnative/helloworld/HelloWorldModule.java | |
package com.cppreactnative.helloworld; | |
import com.facebook.react.bridge.Promise; | |
import com.facebook.react.bridge.ReactApplicationContext; | |
import com.facebook.react.bridge.ReactContextBaseJavaModule; | |
import com.facebook.react.bridge.ReactMethod; | |
public class HelloWorldModule extends ReactContextBaseJavaModule { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ios/ReactBridge/RCTHelloWorld.m | |
#import "RCTHelloWorld.h" | |
#import "HWHelloWorld.h" | |
@implementation RCTHelloWorld{ | |
HWHelloWorld *_cppApi; | |
} | |
- (RCTHelloWorld *)init | |
{ | |
self = [super init]; | |
_cppApi = [HWHelloWorld create]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
### Configuration | |
# Djinni IDL file location | |
djinni_file="helloworld.djinni" | |
# C++ namespace for generated src | |
namespace="helloworld" | |
# Objective-C class name prefix for generated src | |
objc_prefix="HW" | |
# Java package name for generated src | |
java_package="com.cppreactnative.helloworld" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hello_world = interface +c { | |
static create(): hello_world; | |
get_hello_world(): string; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "hello_world_impl.hpp" | |
#include <string> | |
namespace helloworld { | |
std::shared_ptr<HelloWorld> HelloWorld::create() { | |
return std::make_shared<HelloWorldImpl>(); | |
} | |
HelloWorldImpl::HelloWorldImpl() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "hello_world.hpp" | |
namespace helloworld { | |
class HelloWorldImpl : public helloworld::HelloWorld { | |
public: | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// alter your android/app/src/main/java/com/cppreactnative/MainApplication.java | |
import com.cppreactnative.helloworld.HelloWorldPackage; // Add this import statement | |
//... | |
@Override | |
protected List<ReactPackage> getPackages() { | |
return Arrays.<ReactPackage>asList( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// android/app/src/main/java/com/cppreactnative/helloworld/HelloWorldPackage.java | |
package com.cppreactnative.helloworld; | |
import com.facebook.react.ReactPackage; | |
import com.facebook.react.bridge.NativeModule; | |
import com.facebook.react.bridge.ReactApplicationContext; | |
import com.facebook.react.uimanager.ViewManager; | |
import java.util.ArrayList; | |
import java.util.Collections; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// android/app/src/main/java/com/cppreactnative/helloworld/HelloWorldModule.java | |
package com.cppreactnative.helloworld; | |
import com.facebook.react.bridge.Promise; | |
import com.facebook.react.bridge.ReactApplicationContext; | |
import com.facebook.react.bridge.ReactContextBaseJavaModule; | |
import com.facebook.react.bridge.ReactMethod; | |
public class HelloWorldModule extends ReactContextBaseJavaModule { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ./ios/ReactBridge/RCTHelloWorld.m | |
#import "RCTHelloWorld.h" | |
@implementation RCTHelloWorld | |
RCT_EXPORT_MODULE(); | |
RCT_REMAP_METHOD(sayHello, | |
resolver:(RCTPromiseResolveBlock)resolve | |
rejecter:(RCTPromiseRejectBlock)reject) |