<commit_before>//
//  __ParseBridge-Android.cpp
//  roll-eat
//
//  Created by Zinge on 5/16/16.
//
//

#include "ee/core/internal/MessageBridge.hpp"
#include "ee/core/JniUtils.hpp"
#include "ee/core/internal/JniMethodInfo.hpp"
#include "ee/core/internal/JniString.hpp"
#include "ee/core/Logger.hpp"

namespace ee {
namespace core {
namespace {
extern "C" {
JNIEXPORT jstring JNICALL
Java_com_ee_core_internal_MessageBridge_callCpp(JNIEnv* env, jobject instance,
                                                jstring tag_, jstring msg_) {
    const char* tag = env->GetStringUTFChars(tag_, nullptr);
    const char* msg = env->GetStringUTFChars(msg_, nullptr);

    auto result = MessageBridge::getInstance().call(tag, msg);

    env->ReleaseStringUTFChars(tag_, tag);
    env->ReleaseStringUTFChars(msg_, msg);

    return env->NewStringUTF(result.c_str());
}
} // extern "C"
} // namespace

std::string MessageBridge::call(const std::string& tag,
                                const std::string& msg) {
    auto methodInfo = JniUtils::getStaticMethodInfo(
        "com/ee/core/internal/MessageBridge", "staticCall",
        "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;");

    if (methodInfo == nullptr) {
        throw std::runtime_error("Method not found!");
    }

    auto tag_java = JniUtils::toJavaString(tag.c_str());
    auto msg_java = JniUtils::toJavaString(msg.c_str());

    jobject response = methodInfo->getEnv()->CallStaticObjectMethod(
        methodInfo->getClass(), methodInfo->getMethodId(), tag_java->get(),
        msg_java->get());
<commit_msg>Fix Android callback.<commit_after>//
//  __ParseBridge-Android.cpp
//  roll-eat
//
//  Created by Zinge on 5/16/16.
//
//

#include "ee/core/internal/MessageBridge.hpp"
#include "ee/core/JniUtils.hpp"
#include "ee/core/internal/JniMethodInfo.hpp"
#include "ee/core/internal/JniString.hpp"
#include "ee/core/Logger.hpp"

namespace ee {
namespace core {
namespace {
extern "C" {
JNIEXPORT jstring JNICALL
Java_com_ee_core_internal_MessageBridge_callCpp(JNIEnv* env, jobject instance,
                                                jstring tag_, jstring msg_) {
    const char* tag = env->GetStringUTFChars(tag_, nullptr);
    const char* msg = env->GetStringUTFChars(msg_, nullptr);

    auto result = MessageBridge::getInstance().callCpp(tag, msg);

    env->ReleaseStringUTFChars(tag_, tag);
    env->ReleaseStringUTFChars(msg_, msg);

    return env->NewStringUTF(result.c_str());
}
} // extern "C"
} // namespace

std::string MessageBridge::call(const std::string& tag,
                                const std::string& msg) {
    auto methodInfo = JniUtils::getStaticMethodInfo(
        "com/ee/core/internal/MessageBridge", "staticCall",
        "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;");

    if (methodInfo == nullptr) {
        throw std::runtime_error("Method not found!");
    }

    auto tag_java = JniUtils::toJavaString(tag.c_str());
    auto msg_java = JniUtils::toJavaString(msg.c_str());

    jobject response = methodInfo->getEnv()->CallStaticObjectMethod(
        methodInfo->getClass(), methodInfo->getMethodId(), tag_java->get(),
        msg_java->get());

{'fraction_non_alphanumeric': 0.14366551398931154, 'fraction_numerical': 0.0031436655139893115, 'mean_word_length': 3.323369565217391, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3308161', 'n_tokens_mistral': 1032, 'n_tokens_neox': 994, 'n_words': 186}