ReviewOS

also looking at this

craft-native/craft

feat(android): getMemoryUsage and log — ratchet 102 -> 100

#143
Merged chris wants to merge feat/android-tier0-memory-log into main
7 files +377 -3
packages/zig/src/jni_runtime.zigmodified+39-0
Changes to packages/zig/src/jni_runtime.zig
@@ -710,6 +710,45 @@ pub const Jni = struct {
710710 return result;
711711 }
712712
713 pub fn callLongMethod(self: Self, obj: jobject, id: jmethodID) JniError!jlong {
714 const call: *const fn (JNIEnv, jobject, jmethodID) callconv(.c) jlong =
715 @ptrCast(self.table().CallLongMethod orelse return JniError.NotFound);
716 const result = call(self.env, obj, id);
717 try self.check();
718 return result;
719 }
720
721 // --- Static methods ---------------------------------------------------
722 //
723 // `Runtime.getRuntime()` and `Log.d(tag, msg)` are both static, and a
724 // static call is a different table entry from an instance one taking the
725 // class rather than the receiver. Passing a jclass to CallObjectMethod
726 // compiles and is undefined at runtime.
727
728 pub fn staticMethodId(self: Self, cls: jclass, name: [*:0]const u8, sig: [*:0]const u8) JniError!jmethodID {
729 const get: *const fn (JNIEnv, jclass, [*:0]const u8, [*:0]const u8) callconv(.c) jmethodID =
730 @ptrCast(self.table().GetStaticMethodID orelse return JniError.NotFound);
731 const id = get(self.env, cls, name, sig);
732 try self.check();
733 return id orelse JniError.NotFound;
734 }
735
736 pub fn callStaticObjectMethodA(self: Self, cls: jclass, id: jmethodID, args: []const jvalue) JniError!jobject {
737 const call: *const fn (JNIEnv, jclass, jmethodID, [*]const jvalue) callconv(.c) jobject =
738 @ptrCast(self.table().CallStaticObjectMethodA orelse return JniError.NotFound);
739 const result = call(self.env, cls, id, args.ptr);
740 try self.check();
741 return result;
742 }
743
744 pub fn callStaticIntMethodA(self: Self, cls: jclass, id: jmethodID, args: []const jvalue) JniError!jint {
745 const call: *const fn (JNIEnv, jclass, jmethodID, [*]const jvalue) callconv(.c) jint =
746 @ptrCast(self.table().CallStaticIntMethodA orelse return JniError.NotFound);
747 const result = call(self.env, cls, id, args.ptr);
748 try self.check();
749 return result;
750 }
751
713752 pub fn objectClass(self: Self, obj: jobject) JniError!jclass {
714753 const get: *const fn (JNIEnv, jobject) callconv(.c) jclass =
715754 @ptrCast(self.table().GetObjectClass orelse return JniError.NotFound);