Fix mac compile errors in sort.cpp (#7507)
authormudathirmahgoub <mudathirmahgoub@gmail.com>
Wed, 27 Oct 2021 10:05:43 +0000 (05:05 -0500)
committerGitHub <noreply@github.com>
Wed, 27 Oct 2021 10:05:43 +0000 (10:05 +0000)
This fixes compile errors in Mac for the java api  where `jlong` means `long long`.

src/api/java/jni/sort.cpp

index fed1f3a4128f6a164167cdfeb4e5bde1b06f0b7d..e5b4f06fe1728f8943032f1c0428a8eee93eb3a0 100644 (file)
@@ -652,10 +652,10 @@ Java_io_github_cvc5_api_Sort_getConstructorDomainSorts(JNIEnv* env,
   CVC5_JAVA_API_TRY_CATCH_BEGIN;
   Sort* current = reinterpret_cast<Sort*>(pointer);
   std::vector<Sort> sorts = current->getConstructorDomainSorts();
-  std::vector<long> sortPointers(sorts.size());
+  std::vector<jlong> sortPointers(sorts.size());
   for (size_t i = 0; i < sorts.size(); i++)
   {
-    sortPointers[i] = (long)new Sort(sorts[i]);
+    sortPointers[i] = reinterpret_cast<jlong> (new Sort(sorts[i]));
   }
   jlongArray ret = env->NewLongArray(sorts.size());
   env->SetLongArrayRegion(ret, 0, sorts.size(), sortPointers.data());
@@ -765,10 +765,10 @@ Java_io_github_cvc5_api_Sort_getFunctionDomainSorts(JNIEnv* env,
   CVC5_JAVA_API_TRY_CATCH_BEGIN;
   Sort* current = reinterpret_cast<Sort*>(pointer);
   std::vector<Sort> sorts = current->getFunctionDomainSorts();
-  std::vector<long> sortPointers(sorts.size());
+  std::vector<jlong> sortPointers(sorts.size());
   for (size_t i = 0; i < sorts.size(); i++)
   {
-    sortPointers[i] = (long)new Sort(sorts[i]);
+    sortPointers[i] = reinterpret_cast<jlong>(new Sort(sorts[i]));
   }
   jlongArray ret = env->NewLongArray(sorts.size());
   env->SetLongArrayRegion(ret, 0, sorts.size(), sortPointers.data());
@@ -909,10 +909,10 @@ Java_io_github_cvc5_api_Sort_getUninterpretedSortParamSorts(JNIEnv* env,
   CVC5_JAVA_API_TRY_CATCH_BEGIN;
   Sort* current = reinterpret_cast<Sort*>(pointer);
   std::vector<Sort> sorts = current->getUninterpretedSortParamSorts();
-  std::vector<long> sortPointers(sorts.size());
+  std::vector<jlong> sortPointers(sorts.size());
   for (size_t i = 0; i < sorts.size(); i++)
   {
-    sortPointers[i] = (long)new Sort(sorts[i]);
+    sortPointers[i] = reinterpret_cast<jlong>(new Sort(sorts[i]));
   }
   jlongArray ret = env->NewLongArray(sorts.size());
   env->SetLongArrayRegion(ret, 0, sorts.size(), sortPointers.data());
@@ -1005,10 +1005,10 @@ JNIEXPORT jlongArray JNICALL Java_io_github_cvc5_api_Sort_getDatatypeParamSorts(
   CVC5_JAVA_API_TRY_CATCH_BEGIN;
   Sort* current = reinterpret_cast<Sort*>(pointer);
   std::vector<Sort> sorts = current->getDatatypeParamSorts();
-  std::vector<long> sortPointers(sorts.size());
+  std::vector<jlong> sortPointers(sorts.size());
   for (size_t i = 0; i < sorts.size(); i++)
   {
-    sortPointers[i] = (long)new Sort(sorts[i]);
+    sortPointers[i] = reinterpret_cast<jlong>(new Sort(sorts[i]));
   }
   jlongArray ret = env->NewLongArray(sorts.size());
   env->SetLongArrayRegion(ret, 0, sorts.size(), sortPointers.data());
@@ -1055,10 +1055,10 @@ Java_io_github_cvc5_api_Sort_getTupleSorts(JNIEnv* env, jobject, jlong pointer)
   CVC5_JAVA_API_TRY_CATCH_BEGIN;
   Sort* current = reinterpret_cast<Sort*>(pointer);
   std::vector<Sort> sorts = current->getTupleSorts();
-  std::vector<long> sortPointers(sorts.size());
+  std::vector<jlong> sortPointers(sorts.size());
   for (size_t i = 0; i < sorts.size(); i++)
   {
-    sortPointers[i] = (long)new Sort(sorts[i]);
+    sortPointers[i] = reinterpret_cast<jlong>(new Sort(sorts[i]));
   }
   jlongArray ret = env->NewLongArray(sorts.size());
   env->SetLongArrayRegion(ret, 0, sorts.size(), sortPointers.data());