<commit_before>#include "parser.h"
#include "in_uncod_android_bypass_Bypass.h"

namespace boost
{
    void throw_exception(std::exception const&) {}
}

jobject recurseElement(Bypass::Element element) {

}

JNIEXPORT jobject JNICALL Java_in_uncod_android_bypass_Bypass_processMarkdown
  (JNIEnv *env, jobject o, jstring markdown) {

	const char* str;
	str = env->GetStringUTFChars(markdown, NULL);

	Bypass::Parser parser;
	Bypass::Document document = parser.parse(str);

	env->ReleaseStringUTFChars(markdown, str);

	jclass java_document_class = env->FindClass("in/uncod/android/bypass/Document");
	jmethodID java_document_init = env->GetMethodID(java_document_class, "<init>", "([Lin/uncod/android/bypass/Element;)V");
	jclass java_element_class = env->FindClass("in/uncod/android/bypass/Element");
	jmethodID java_element_init = env->GetMethodID(java_element_class, "<init>", "(Ljava/lang/String;I[Lin/uncod/android/bypass/Element;)V");

	jobjectArray elements = (jobjectArray) env->NewObjectArray(document.size(), java_element_class, 0);

	for (int i=0; i<document.size(); i++)  {
		jobject jelement = recurseElement(document[i]);
		env->SetObjectArrayElement(elements, i, jelement);
	}

	jobject jdocument = env->NewObject(java_document_class, java_document_init, elements);

	return jdocument;<commit_msg>Convert c++ objects to java objects<commit_after>#include "parser.h"
#include "in_uncod_android_bypass_Bypass.h"

namespace boost
{
    void throw_exception(std::exception const&) {}
}

jclass java_element_class;
jmethodID java_element_init;

jobject recurseElement(JNIEnv *env, Bypass::Element element) {
	jobjectArray elements = (jobjectArray) env->NewObjectArray(element.size(), java_element_class, 0);
	for (int i=0; i<element.size(); i++) {
		jobject jelement = recurseElement(env, element[i]);
		env->SetObjectArrayElement(elements, i, jelement);
	}
	jstring text = env->NewStringUTF(element.getText().c_str());
	jobject jelement = env->NewObject(java_element_class, java_element_init, text, element.getType(), elements);

	return jelement;
}

JNIEXPORT jobject JNICALL Java_in_uncod_android_bypass_Bypass_processMarkdown
  (JNIEnv *env, jobject o, jstring markdown) {

	const char* str;
	str = env->GetStringUTFChars(markdown, NULL);

	Bypass::Parser parser;
	Bypass::Document document = parser.parse(str);

	env->ReleaseStringUTFChars(markdown, str);

	jclass java_document_class = env->FindClass("in/uncod/android/bypass/Document");
	jmethodID java_document_init = env->GetMethodID(java_document_class, "<init>", "([Lin/uncod/android/bypass/Element;)V");
	java_element_class = env->FindClass("in/uncod/android/bypass/Element");
	java_element_init = env->GetMethodID(java_element_class, "<init>", "(Ljava/lang/String;I[Lin/uncod/android/bypass/Element;)V");

	jobjectArray elements = (jobjectArray) env->NewObjectArray(document.size(), java_element_class, 0);

	for (int i=0; i<document.size(); i++)  {
		jobject jelement = recurseElement(env, document[i]);
		env->SetObjectArrayElement(elements, i, jelement);
	}

	jobject jdocument = env->NewObject(java_document_class, java_document_init, elements);

	return jdocument;
{'fraction_non_alphanumeric': 0.13535031847133758, 'fraction_numerical': 0.001910828025477707, 'mean_word_length': 7.116279069767442, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 29, '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': '795306', 'n_tokens_mistral': 1099, 'n_tokens_neox': 1063, 'n_words': 189}