<commit_before>use std::collections::HashMap;
use std::sync::atomic::{Ordering};
use std::fmt::Write;

use syntex_syntax::util::small_vector::SmallVector;
use syntex_syntax::ext::base::{ExtCtxt, MacResult, MacEager};
use syntex_syntax::{parse, ast};
use syntex_syntax::print::pprust;

use core::*;
use jni::generate_func_name as jni_generate_func_name;
use COMMON_CODE_GENERATED;

pub static RUST_OBJECT_TO_JOBJECT: &'static str = r#"
  let class_id = ::std::ffi::CString::new("{full_class_name}").unwrap();
  let jcls: jclass = unsafe { (**env).FindClass.unwrap()(env, class_id.as_ptr()) };
  //TODO: check exception and return values
  let jobj: jobject = unsafe { (**env).AllocObject.unwrap()(env, jcls) };
  //TODO: check exception and return values
  let field_id = ::std::ffi::CString::new("mNativeObj").unwrap();
  //TODO: check exception and return values
  let type_id = ::std::ffi::CString::new("J").unwrap();
//TODO: check exception and return values
  let field_id: jfieldID = unsafe { (**env).GetFieldID.unwrap()(env, jcls, field_id.as_ptr(), type_id.as_ptr()) };
//TODO: check exception and return values
  let ret = Box::into_raw(Box::new(ret)) as jlong;
  unsafe { (**env).SetLongField.unwrap()(env, jobj, field_id, ret) };
  //TODO: check exception and return values
  let ret = jobj;<commit_msg>more checks in rust obj to jobject conversation<commit_after>use std::collections::HashMap;
use std::sync::atomic::{Ordering};
use std::fmt::Write;

use syntex_syntax::util::small_vector::SmallVector;
use syntex_syntax::ext::base::{ExtCtxt, MacResult, MacEager};
use syntex_syntax::{parse, ast};
use syntex_syntax::print::pprust;

use core::*;
use jni::generate_func_name as jni_generate_func_name;
use COMMON_CODE_GENERATED;

pub static RUST_OBJECT_TO_JOBJECT: &'static str = r#"
  let class_id = ::std::ffi::CString::new("{full_class_name}").unwrap();
  let jcls: jclass = unsafe { (**env).FindClass.unwrap()(env, class_id.as_ptr()) };
  assert!(!jcls.is_null());
  //TODO: check exception and return values
  let jobj: jobject = unsafe { (**env).AllocObject.unwrap()(env, jcls) };
  assert!(!jobj.is_null());
  //TODO: check exception and return values
  let field_id = ::std::ffi::CString::new("mNativeObj").unwrap();
  //TODO: check exception and return values
  let type_id = ::std::ffi::CString::new("J").unwrap();
//TODO: check exception and return values
  let field_id: jfieldID = unsafe { (**env).GetFieldID.unwrap()(env, jcls, field_id.as_ptr(), type_id.as_ptr()) };
  assert!(!field_id.is_null());
//TODO: check exception and return values
  let ret = Box::into_raw(Box::new(ret)) as jlong;
  unsafe {
    (**env).SetLongField.unwrap()(env, jobj, field_id, ret);
    if (**env).ExceptionCheck.unwrap()(env) != 0 {
      panic!("Can not mNativeObj field: catch exception");
    }
  }

  //TODO: check exception and return values
  let ret = jobj;
{'fraction_non_alphanumeric': 0.17102055033089517, 'fraction_numerical': 0.00034831069313827936, 'mean_word_length': 5.920481927710844, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4902055', 'n_tokens_mistral': 994, 'n_tokens_neox': 1006, 'n_words': 236}