-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77d2e5a
commit 891405d
Showing
6 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// Created by Dominik Seifert on 25.07.22 | ||
// | ||
|
||
#include "JNIV8TypedArray.h" | ||
|
||
#include <stdlib.h> | ||
|
||
BGJS_JNI_LINK(JNIV8TypedArray, "ag/boersego/bgjs/JNIV8TypedArray"); | ||
|
||
|
||
|
||
bool JNIV8TypedArray::isWrappableV8Object(v8::Local<v8::Object> object) { | ||
return object->IsTypedArray() || (object->IsProxy() && object.As<v8::Proxy>()->GetTarget()->IsTypedArray()); | ||
} | ||
|
||
void JNIV8TypedArray::initializeJNIBindings(JNIClassInfo *info, bool isReload) { | ||
info->registerNativeMethod("getV8Length", "()I", (void *) JNIV8TypedArray::jniGetV8Length); | ||
} | ||
|
||
/** | ||
* returns the length of the TypedArray | ||
*/ | ||
jint JNIV8TypedArray::jniGetV8Length(JNIEnv *env, jobject obj) { | ||
JNIV8Object_PrepareJNICall(JNIV8TypedArray, v8::TypedArray, 0); | ||
return localRef->Length(); | ||
} | ||
|
||
/** | ||
* cache JNI class references | ||
*/ | ||
void JNIV8TypedArray::initJNICache() { | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// Created by Dominik Seifert on 25.07.22 | ||
// | ||
|
||
#ifndef ANDROID_TRADINGLIB_SAMPLE_JNIV8TYPEDARRAY_H | ||
#define ANDROID_TRADINGLIB_SAMPLE_JNIV8TYPEDARRAY_H | ||
|
||
#include "JNIV8Wrapper.h" | ||
|
||
class JNIV8TypedArray : public JNIScope<JNIV8TypedArray, JNIV8Object> { | ||
public: | ||
JNIV8TypedArray(jobject obj, JNIClassInfo *info) : JNIScope(obj, info) {}; | ||
|
||
static bool isWrappableV8Object(v8::Local<v8::Object> object); | ||
static void initializeJNIBindings(JNIClassInfo *info, bool isReload); | ||
|
||
/** | ||
* returns the length of the TypedArray | ||
*/ | ||
static jint jniGetV8Length(JNIEnv *env, jobject obj); | ||
|
||
/** | ||
* cache JNI class references | ||
*/ | ||
static void initJNICache(); | ||
}; | ||
|
||
BGJS_JNI_LINK_DEF(JNIV8TypedArray) | ||
|
||
#endif //ANDROID_TRADINGLIB_SAMPLE_JNIV8TYPEDARRAY_H |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package ag.boersego.bgjs; | ||
|
||
import androidx.annotation.Keep; | ||
|
||
final public class JNIV8TypedArray extends JNIV8Object { | ||
//------------------------------------------------------------------------ | ||
// internal fields & methods | ||
@Keep | ||
JNIV8TypedArray(V8Engine engine, long jsObjPtr, Object[] arguments) { | ||
super(engine, jsObjPtr, arguments); | ||
} | ||
|
||
/** | ||
* returns the length of the array | ||
*/ | ||
public native int getV8Length(); | ||
} |