<commit_before>// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build java android

package util

import (
	"fmt"
	"reflect"
	"time"
	"unsafe"
)

// #include <stdlib.h>
// #include "jni_wrapper.h"
//
// static jvalue* allocJValueArray(int elements) {
//   return malloc(sizeof(jvalue) * elements);
// }
//
// static setJValueArrayElement(jvalue* arr, int index, jvalue val) {
//   arr[index] = val;
// }
//
import "C"

// jArg converts a Go argument to a Java argument.  It uses the provided sign to
// validate that the argument is of a compatible type.
func jArg(env *C.JNIEnv, v interface{}, sign Sign) (unsafe.Pointer, bool) {
	rv := reflect.ValueOf(v)
	if !rv.IsValid() { // nil value
		jv := C.jobject(nil)
		return unsafe.Pointer(&jv), true
	}
	if rv.Type() == reflect.TypeOf(time.Time{}) {
		if sign != DateTimeSign {
			return unsafe.Pointer(nil), false
		}
		jv, err := JTime(env, rv.Interface().(time.Time))
		if err != nil {
			return unsafe.Pointer(nil), false
		}
		return unsafe.Pointer(&jv), true<commit_msg>TBR: small fix for jni libraries on darwin<commit_after>// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build java android

package util

import (
	"fmt"
	"reflect"
	"time"
	"unsafe"
)

// #include <stdlib.h>
// #include "jni_wrapper.h"
//
// static jvalue* allocJValueArray(int elements) {
//   return malloc(sizeof(jvalue) * elements);
// }
//
// static void setJValueArrayElement(jvalue* arr, int index, jvalue val) {
//   arr[index] = val;
// }
//
import "C"

// jArg converts a Go argument to a Java argument.  It uses the provided sign to
// validate that the argument is of a compatible type.
func jArg(env *C.JNIEnv, v interface{}, sign Sign) (unsafe.Pointer, bool) {
	rv := reflect.ValueOf(v)
	if !rv.IsValid() { // nil value
		jv := C.jobject(nil)
		return unsafe.Pointer(&jv), true
	}
	if rv.Type() == reflect.TypeOf(time.Time{}) {
		if sign != DateTimeSign {
			return unsafe.Pointer(nil), false
		}
		jv, err := JTime(env, rv.Interface().(time.Time))
		if err != nil {
			return unsafe.Pointer(nil), false
		}
		return unsafe.Pointer(&jv), true
{'fraction_non_alphanumeric': 0.14500860585197933, 'fraction_numerical': 0.0034423407917383822, 'mean_word_length': 3.3457943925233646, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6132543', 'n_tokens_mistral': 825, 'n_tokens_neox': 780, 'n_words': 259}