Skip to content

Instantly share code, notes, and snippets.

View LiewJunTung's full-sized avatar

Liew Jun Tung LiewJunTung

View GitHub Profile
#include "calculator_impl.hpp"
#include <string>
namespace calculator{
std::shared_ptr<Calculator> Calculator::create() {
return std::make_shared<CalculatorImpl>();
}
CalculatorImpl::CalculatorImpl() {}
#include "calculator_impl.hpp"
#include <iostream>
using namespace std;
using namespace calculator;
int main(int argc, char const *argv[])
{
CalculatorImpl calculator = CalculatorImpl();
int sum = calculator.summation(1, 2);
cmake_minimum_required(VERSION 3.4.1)
file(GLOB calculator_sources
../../djinni/support-lib/jni/*.cpp
../../generated/jni/*.cpp
../../src/cpp/*.cpp
)
add_library( # Sets the name of the library.
calculator
package org.gdgkl.androidapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import com.example.yourcompany.Calculator;
public class MainActivity extends AppCompatActivity {
@LiewJunTung
LiewJunTung / calculator.djinni
Created January 28, 2018 16:15
Added a subtraction method
calculator =
interface +c {
# create() is to create an instance of the calculator
static create(): calculator;
# summation, adding two i32.. aka integers together. And return an integer.
summation(number1: i32, number2: i32):i32;
# look at me, a subtraction method! :)
subtraction(number1: i32, number2: i32):i32;
}
#include "calculator_impl.hpp"
#include <string>
namespace calculator{
std::shared_ptr<Calculator> Calculator::create() {
return std::make_shared<CalculatorImpl>();
}
CalculatorImpl::CalculatorImpl() {
@LiewJunTung
LiewJunTung / build.gradle
Last active February 1, 2018 02:03
Get hello cocoa
/*
* This file was generated by the Gradle 'init' task.
*
* This is a general purpose Gradle build.
* Learn how to create Gradle builds at https://guides.gradle.org/creating-new-gradle-builds/
*/
group 'org.netvirta'
version '0.0.1-SNAPSHOT'
xcodebuild -project HelloFramework.xcodeproj -target HelloFramework -sdk iphonesimulator11.2
void CalculatorAndroidImpl::hello(const std::string &text) {
__android_log_print(ANDROID_LOG_DEBUG, "Calculator",
"Calculator", text);
}
namespace djinni {
struct ByteBuffer {
using CppType = int8_t *;
using JniType = jobject;
static CppType toCpp(JNIEnv* env, JniType j) {
return (int8_t *) env->GetDirectBufferAddress(j);
}
static JniType fromCpp(JNIEnv *env, CppType c) {