Skip to content
This repository
Browse code

jni: add docs for jni vector helper

  • Loading branch information...
commit ef50cda7557b1af34381e86043c1a9b3128a8d5a 1 parent 1835938
authored August 23, 2013

Showing 1 changed file with 16 additions and 1 deletion. Show diff stats Hide diff stats

  1. 17  xbmc/android/jni/README
17  xbmc/android/jni/README
@@ -83,7 +83,22 @@ The fix:
83 83
     retrun externalDir;
84 84
   }
85 85
 
86  
-b. Probably lots more.
  86
+b. Java has an understanding of arrays like Type[] which contain size info.
  87
+   C-style arrays don't carry size information, so passing a c-array as a
  88
+   parameter does not provide enough info to work with it realistically.
  89
+
  90
+   workaround: Data should be passed in/out of Java arrays as std::vectors of
  91
+   primitive types or jni classes.
  92
+   Care should be taken to avoid making needless copies of objects in the
  93
+   process. To automate this, jcast() can be used to convert a j(h)objectArray
  94
+   directly to a vector of native objects. For example:
  95
+
  96
+  std::vector<CJNIFoo> example()
  97
+  {
  98
+    return jcast<std::vector<CJNIFoo> >(call_method<jhobjectArray>(object, "function", "()[Lsome/Class;"))
  99
+  }
  100
+
  101
+c. Probably lots more.
87 102
 
88 103
 8. Is the entire API implemented?
89 104
 Not even close! Classes and individual functions have been added as-needed.

0 notes on commit ef50cda

Please sign in to comment.
Something went wrong with that request. Please try again.