diff options
author | mudathirmahgoub <mudathirmahgoub@gmail.com> | 2021-10-22 18:00:06 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-22 23:00:06 +0000 |
commit | 60c9b4980920e0f279085e4dd1ea2518b218074c (patch) | |
tree | 4f402f4f1c2c6760a8b877b307ff16cbefed2019 /src/api/java/jni/api_utilities.cpp | |
parent | c6c2cb9d3cc911526266e517460b3e8ae2dab9c0 (diff) |
Refactor java package name from cvc5 to io.github.cvc5.api (#7340)
This PR refactors java package name from cvc5 to io.github.cvc5.api.
It also refactor the names of cpp and java files.
Diffstat (limited to 'src/api/java/jni/api_utilities.cpp')
-rw-r--r-- | src/api/java/jni/api_utilities.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/api/java/jni/api_utilities.cpp b/src/api/java/jni/api_utilities.cpp new file mode 100644 index 000000000..8827b506c --- /dev/null +++ b/src/api/java/jni/api_utilities.cpp @@ -0,0 +1,52 @@ +/****************************************************************************** + * Top contributors (to current version): + * Mudathir Mohamed + * + * This file is part of the cvc5 project. + * + * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS + * in the top-level source directory and their institutional affiliations. + * All rights reserved. See the file COPYING in the top-level source + * directory for licensing information. + * **************************************************************************** + * + * The cvc5 Java API. + */ + +#include "api_utilities.h" + +#include <string> +#include <vector> + +jobjectArray getStringArrayFromStringVector( + JNIEnv* env, const std::vector<std::string>& cStrings) +{ + jclass stringClass = env->FindClass("java/lang/String"); + jobjectArray ret = + env->NewObjectArray(cStrings.size(), stringClass, env->NewStringUTF("")); + for (size_t i = 0; i < cStrings.size(); i++) + { + jstring jString = env->NewStringUTF(cStrings[i].c_str()); + env->SetObjectArrayElement(ret, i, jString); + } + return ret; +} + +jobject getDoubleObject(JNIEnv* env, double cValue) +{ + jdouble jValue = static_cast<jdouble>(cValue); + jclass doubleClass = env->FindClass("java/lang/Double"); + jmethodID methodId = env->GetMethodID(doubleClass, "<init>", "(D)V"); + jobject ret = env->NewObject(doubleClass, methodId, jValue); + return ret; +} + +jobject getBooleanObject(JNIEnv* env, bool cValue) +{ + jboolean jValue = static_cast<jboolean>(cValue); + jclass booleanClass = env->FindClass("Ljava/lang/Boolean;"); + jmethodID booleanConstructor = + env->GetMethodID(booleanClass, "<init>", "(Z)V"); + jobject ret = env->NewObject(booleanClass, booleanConstructor, jValue); + return ret; +}
\ No newline at end of file |