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
name: iOS | |
on: [push, pull_request] | |
jobs: | |
node-stuff: | |
runs-on: macos-latest | |
steps: | |
- name: Checkout project |
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
name: Android | |
on: [push, pull_request] | |
jobs: | |
build: | |
runs-on: macos-latest | |
steps: | |
- name: Checkout project |
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
const Example = { | |
name: "Hans", | |
age: 42, | |
print: function() { | |
console.log(`Name: "${this.name}", age: "${this.age}".`); | |
}, | |
printSomething: function(extra) { | |
console.log(`Extra: ${extra}.`); | |
} | |
}; |
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
function add(a, b) { | |
console.log(a + b); | |
console.log(this); | |
} | |
add(1, 2); | |
// ⇒ 3 | |
// ⇒ Object [global] { global: [Circular], clearInterval ... } | |
add.apply({ example: "test" }, [1, 2]); |
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
const actionTypes = { | |
ACTION_TYPE_TEST: 'ACTION_TYPE_TEST' | |
} | |
class Store { | |
constructor(initialState = { testValue: 0 }) { | |
this.state = initialState; | |
this.subscribers = []; | |
} |
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 { | |
... | |
defaultConfig { | |
... | |
externalNativeBuild { | |
cmake { | |
cppFlags "-O2 -frtti -fexceptions -Wall -fstack-protector-all" | |
abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' | |
} |
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
cmake_minimum_required(VERSION 3.4.1) | |
set (CMAKE_VERBOSE_MAKEFILE ON) | |
set (CMAKE_CXX_STANDARD 11) | |
add_library(cpp-code | |
SHARED | |
../cpp-code/src/src/example.cpp | |
cpp-adapter.cpp | |
) |
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 <jni.h> | |
#include "example.h" | |
extern "C" | |
JNIEXPORT jlong JNICALL | |
Java_com_mariusreimer_rncppcode_RNCPPCodeModule_multiply(JNIEnv *env, jclass type, jlong a, jlong b) { | |
return example::multiply(a, b); | |
} |
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
package com.mariusreimer.rncppcode; | |
... | |
class RNCPPCodeModule { | |
static { | |
try { | |
System.loadLibrary("cpp-code"); | |
Log.d(TAG, "-------- libcpp-code: loaded"); | |
} catch (Exception e){ | |
Log.d(TAG, "-------- libcpp-code: loaded"); |
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
RCT_EXPORT_METHOD( | |
multiply:(nonnull NSNumber*)a | |
withB:(nonnull NSNumber*)b | |
withResolver:(RCTPromiseResolveBlock)resolve | |
withReject:(RCTPromiseRejectBlock)reject | |
) | |
{ | |
long result = example::multiply([a longValue], [b longValue]); | |
resolve(@{ |