Upgrade to Pro — share decks privately, control downloads, hide ads and more …

iOSとAndroidで共通のc++のコードを使いたいけど厳しかった話

 iOSとAndroidで共通のc++のコードを使いたいけど厳しかった話

2015/08/29 社内勉強会(chocotips)用

chocomelonchan

August 21, 2015
Tweet

More Decks by chocomelonchan

Other Decks in Programming

Transcript

  1. )FMMP 8SBQQJOHTXJGU extension Hello { class func hello() { Hello.helloFromNative()

    } } )FMMPNN @implementation Hello + (void)helloFromNative { return Hello::hello(); } @end )FMMPDQQ void Hello::hello() { printf("Hello"); }
  2. D DBMMGSPN+BWB w "OESPJE4UVEJP (SBEMFͰ TVQQPSU   w /%,Λ࢖ͬͯD

    ΛݺͿ w +/*ͳͷͰD ͷίʔυΛ+/*Ͱѻ͑Δܗʹ͢Δ ඞཁ͕͋Δʢ'VDLʣ w ͍ͩͿΊΜͲ͍͘͞
  3. )FMMPKBWB public class Hello {
 
 public static String hello()

    {
 return helloFromJNI();
 }
 
 public static native String helloFromJNI();
 
 static {
 System.loadLibrary("Hello-JNI");
 }
 } )FMMP+/*DQQ #include <jni.h>
 
 extern "C" {
 JNIEXPORT jstring Java_com_example_hellojni_Utils_stringFromJNI(JNIEnv *env, jobject thiz) {
 return env->NewStringUTF("Hello from JNI!");
 }
 }
  4. -PHJD6UJMT 8SBQQJOHTXJGU extension LogicUtil { class func isStep(map: [[Int32]], characterPoint:

    Point, direction: Direction) -> Bool { let numberOfSquares: Int = map.count let charaIndex: Int = characterPoint.x + characterPoint.y * numberOfSquares var mapIntArray: [Int32] = [] for y in 0..<numberOfSquares { for x in 0..<numberOfSquares { mapIntArray.append(map[y][x]) } } return LogicUtil.isStep(UnsafeMutablePointer<Int32>(mapIntArray), numOfSquares: Int32(numberOfSquares), charaIndex: Int32(charaIndex), direction: Int32(direction.rawValue)) } }
  5. -PHJD6UJMT 8SBQQJOHTXJGU extension LogicUtil { class func isStep(map: [[Int32]], characterPoint:

    Point, direction: Direction) -> Bool { let numberOfSquares: Int = map.count let charaIndex: Int = characterPoint.x + characterPoint.y * numberOfSquares var mapIntArray: [Int32] = [] for y in 0..<numberOfSquares { for x in 0..<numberOfSquares { mapIntArray.append(map[y][x]) } } return LogicUtil.isStep(UnsafeMutablePointer<Int32>(mapIntArray), numOfSquares: Int32(numberOfSquares), charaIndex: Int32(charaIndex), direction: Int32(direction.rawValue)) } }