├── generator
├── scripts
│ ├── plyj
│ │ ├── __init__.py
│ │ └── ply
│ │ │ ├── __init__.py
│ │ │ └── ctokens.py
│ └── lextab.py
└── interfaces
│ ├── Boolean.in
│ ├── Point.in
│ ├── HashMap.in
│ ├── Integer.in
│ ├── Long.in
│ ├── Rect.in
│ ├── Vector.in
│ └── String.in
├── test
├── testapp
│ ├── android
│ │ ├── stub.cpp
│ │ ├── res
│ │ │ └── values
│ │ │ │ └── strings.xml
│ │ ├── AndroidManifest.xml
│ │ └── src
│ │ │ └── com
│ │ │ └── example
│ │ │ └── test
│ │ │ ├── StringGeneratorClient.java
│ │ │ ├── TestActivity.java
│ │ │ └── StringGenerator.java
│ ├── CMakeLists.txt
│ └── win32
│ │ └── WinMain.cpp
├── CMakeLists.txt
└── testlib
│ ├── CMakeLists.txt
│ ├── TestLibPrefix.h
│ ├── StringGeneratorClientNatives.cpp
│ ├── win32
│ └── DLLMain.cpp
│ ├── generic
│ ├── StringGeneratorClient.cpp
│ └── StringGenerator.cpp
│ ├── android
│ └── JNIMain.cpp
│ └── StringGeneratorNatives.cpp
├── androidjni
├── annotations
│ ├── androidjni_annotations_manifest.xml
│ ├── CMakeLists.txt
│ └── src
│ │ └── labs
│ │ └── naver
│ │ └── androidjni
│ │ ├── AbstractMethod.java
│ │ ├── CalledByNative.java
│ │ ├── AccessedByNative.java
│ │ ├── NativeConstructor.java
│ │ ├── NativeDestructor.java
│ │ ├── NativeObjectField.java
│ │ ├── NativeNamespace.java
│ │ └── NativeExportMacro.java
├── JNIIncludes.h
├── platforms
│ ├── android
│ │ ├── JavaVM.h
│ │ ├── AndroidLog.h
│ │ ├── AndroidJNI.h
│ │ ├── ReferenceFunctions.cpp
│ │ ├── androidjni
│ │ │ ├── PassArray.h
│ │ │ └── MarshalingHelpers.h
│ │ └── JavaVM.cpp
│ └── generic
│ │ ├── ObjectReference.cpp
│ │ ├── androidjni
│ │ ├── MarshalingHelpers.h
│ │ └── PassArray.h
│ │ ├── ObjectReference.h
│ │ └── ReferenceFunctions.cpp
├── JNIExportMacros.h
├── ReferenceFunctions.h
├── AnyObject.h
├── CMakeLists.txt
├── Abbreviations.h
├── NativeObject.h
└── WeakGlobalRef.h
├── cmake
├── OptionsAndroid.cmake
├── HelperMacros.cmake
└── OptionsWindows.cmake
├── .gitignore
├── LICENSE
├── android
├── CMakeLists.txt
├── JNI
│ ├── LongJNI.cpp
│ ├── java
│ │ ├── lang
│ │ │ ├── Long.h
│ │ │ ├── String.h
│ │ │ ├── Boolean.h
│ │ │ └── Integer.h
│ │ └── util
│ │ │ ├── Vector.h
│ │ │ └── HashMap.h
│ ├── VectorJNI.cpp
│ ├── BooleanJNI.cpp
│ ├── HashMapJNI.cpp
│ ├── IntegerJNI.cpp
│ ├── RectJNI.cpp
│ ├── PointJNI.cpp
│ ├── android
│ │ └── graphics
│ │ │ ├── Rect.h
│ │ │ └── Point.h
│ └── StringJNI.cpp
├── java
│ ├── lang
│ │ ├── Long.h
│ │ ├── String.h
│ │ ├── Boolean.h
│ │ └── Integer.h
│ └── util
│ │ ├── Vector.h
│ │ └── HashMap.h
├── android
│ └── graphics
│ │ ├── Rect.h
│ │ └── Point.h
├── Boolean.cpp
├── Integer.cpp
├── Long.cpp
├── String.cpp
├── Point.cpp
└── HashMap.cpp
├── CMakeLists.txt
└── README.md
/generator/scripts/plyj/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/testapp/android/stub.cpp:
--------------------------------------------------------------------------------
1 | int main(int argc, char *argv[])
2 | {
3 | return 0;
4 | }
5 |
--------------------------------------------------------------------------------
/generator/scripts/plyj/ply/__init__.py:
--------------------------------------------------------------------------------
1 | # PLY package
2 | # Author: David Beazley (dave@dabeaz.com)
3 |
4 | __all__ = ['lex','yacc']
5 |
--------------------------------------------------------------------------------
/test/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_subdirectory(testapp)
2 | add_subdirectory(testlib)
3 |
4 | add_dependencies(testlib androidjni++)
5 | add_dependencies(testapp testlib)
6 |
--------------------------------------------------------------------------------
/test/testapp/android/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | HelloJni
4 |
5 |
--------------------------------------------------------------------------------
/androidjni/annotations/androidjni_annotations_manifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/androidjni/annotations/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (ANDROID)
2 | set(ANDROIDJNI_SOURCES
3 | androidjni_annotations_manifest.xml
4 |
5 | src/labs/naver/androidjni/AbstractMethod.java
6 | src/labs/naver/androidjni/AccessedByNative.java
7 | src/labs/naver/androidjni/CalledByNative.java
8 | src/labs/naver/androidjni/NativeConstructor.java
9 | src/labs/naver/androidjni/NativeDestructor.java
10 | src/labs/naver/androidjni/NativeExportMacro.java
11 | src/labs/naver/androidjni/NativeNamespace.java
12 | src/labs/naver/androidjni/NativeObjectField.java
13 | )
14 |
15 | add_jar(androidjni.annotations ${ANDROIDJNI_SOURCES} OUTPUT_DIR ${CMAKE_ANDROID_JAR_DIRECTORIES})
16 | endif ()
17 |
--------------------------------------------------------------------------------
/test/testapp/android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
9 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/cmake/OptionsAndroid.cmake:
--------------------------------------------------------------------------------
1 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/lib)
2 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib)
3 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/bin)
4 |
5 | foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
6 | string(TOUPPER ${OUTPUTCONFIG} CONFIG)
7 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONFIG} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
8 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONFIG} "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
9 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONFIG} "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}")
10 | endforeach()
11 |
12 | find_package(Java 1.7 EXACT)
13 | include(UseJava)
14 |
15 | set(CMAKE_ANDROID_API_MIN 14)
16 | set(CMAKE_ANDROID_JAR_DIRECTORIES "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.mode*
2 | *.pbxuser
3 | *.perspective*
4 | *.pyc
5 | .DS_Store
6 | .directory
7 | build/
8 | autoinstall.cache.d
9 | project.xcworkspace
10 | xcuserdata
11 |
12 | # Ignore auto-generated files by VS2005 and VS2010.
13 | *.vcproj.*.user
14 | *.suo
15 | *.ncb
16 |
17 | # Ignore common tool auto-generated files.
18 | .gdbinit
19 | .gdb_history
20 | tags
21 | *~
22 | .*.sw[a-p]
23 |
24 | # Ignore files generated by Qt Creator:
25 | *.pro.user
26 |
27 | # Ignore KDevelop files:
28 | .kdev_include_paths
29 | *.kdev4
30 | *.kate-swp
31 |
32 | # Ignore Eclipse files:
33 | .project
34 | .cproject
35 | .settings
36 |
37 | # Ignore YouCompleteMe symlinks
38 | .ycm_extra_conf.py
39 |
40 | # Ignore ndk-build intermediate files:
41 | test/android/.classpath
42 | test/android/bin
43 | test/android/gen
44 | test/android/libs
45 | test/android/obj
46 |
47 |
--------------------------------------------------------------------------------
/generator/interfaces/Boolean.in:
--------------------------------------------------------------------------------
1 |
2 | package java.lang;
3 |
4 | @NativeNamespace("java.lang")
5 | @NativeExportMacro("JNI_EXPORT")
6 | public final class Boolean {
7 |
8 | @AccessedByNative
9 | private boolean value;
10 |
11 | public Boolean(String string) {}
12 | @CalledByNative
13 | public Boolean(boolean value) {}
14 |
15 | @CalledByNative
16 | public boolean booleanValue();
17 |
18 | @Override
19 | public boolean equals(Object o);
20 | public int compareTo(Boolean that);
21 | public static int compare(boolean lhs, boolean rhs);
22 |
23 | @Override
24 | public int hashCode();
25 |
26 | @Override
27 | public String toString();
28 |
29 | public static boolean getBoolean(String string);
30 | public static boolean parseBoolean(String s);
31 |
32 | public static String toString(boolean value);
33 | public static Boolean valueOf(String string);
34 | public static Boolean valueOf(boolean b);
35 | }
36 |
--------------------------------------------------------------------------------
/generator/interfaces/Point.in:
--------------------------------------------------------------------------------
1 |
2 | package android.graphics;
3 |
4 | import android.os.Parcel;
5 |
6 | /**
7 | * Point holds two integer coordinates
8 | */
9 | @NativeNamespace("android.graphics")
10 | @NativeExportMacro("JNI_EXPORT")
11 | public class Point {
12 | @AccessedByNative
13 | public int x;
14 | @AccessedByNative
15 | public int y;
16 |
17 | @CalledByNative
18 | public Point() {}
19 | @CalledByNative
20 | public Point(int x, int y) {}
21 | @CalledByNative
22 | public Point(Point src) {}
23 |
24 | @CalledByNative
25 | public void set(int x, int y);
26 | @CalledByNative
27 | public final void negate();
28 | @CalledByNative
29 | public final void offset(int dx, int dy);
30 |
31 | @CalledByNative
32 | public final boolean equals(int x, int y);
33 | @CalledByNative
34 | public boolean equals(Object o);
35 |
36 | @CalledByNative
37 | public int hashCode();
38 | public String toString();
39 |
40 | public int describeContents();
41 |
42 | public void writeToParcel(Parcel out, int flags);
43 | public void readFromParcel(Parcel in);
44 | }
45 |
--------------------------------------------------------------------------------
/generator/interfaces/HashMap.in:
--------------------------------------------------------------------------------
1 |
2 | package java.util;
3 |
4 | @NativeNamespace("java.util")
5 | @NativeExportMacro("JNI_EXPORT")
6 | public class HashMap {
7 |
8 | @CalledByNative
9 | @SupplementForManaged("using Data = std::map, std::shared_ptr>;")
10 | public HashMap() {}
11 | @CalledByNative
12 | public HashMap(int capacity) {}
13 | @CalledByNative
14 | public HashMap(int capacity, float loadFactor) {}
15 | public HashMap(Map extends K, ? extends V> map) {}
16 |
17 | @CalledByNative
18 | public void clear();
19 | @CalledByNative
20 | public Object clone();
21 | @CalledByNative
22 | public boolean containsKey(Object key);
23 | @CalledByNative
24 | public boolean containsValue(Object value);
25 | public Set> entrySet();
26 | @CalledByNative
27 | public V get(Object key);
28 | @CalledByNative
29 | public boolean isEmpty();
30 | public Set keySet();
31 | @CalledByNative
32 | public V put(K key, V value);
33 | public void putAll(Map extends K, ? extends V> map);
34 | @CalledByNative
35 | public V remove(Object key);
36 | @CalledByNative
37 | public int size();
38 | @SupplementForManaged("CLASS_EXPORT const Data& data();")
39 | public Collection values();
40 | }
41 |
--------------------------------------------------------------------------------
/test/testapp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(TEST_SOURCES)
2 |
3 | if (ANDROID)
4 | list(APPEND TEST_SOURCES
5 | android/AndroidManifest.xml
6 | android/stub.cpp
7 |
8 | android/src/com/example/test/StringGenerator.java
9 | android/src/com/example/test/StringGeneratorClient.java
10 | android/src/com/example/test/TestActivity.java
11 | )
12 | if (MSVC)
13 | set_source_files_properties(android/stub.cpp PROPERTIES HEADER_FILE_ONLY TRUE)
14 | endif ()
15 |
16 | set(CMAKE_ANDROID_GUI TRUE)
17 | elseif (WIN32)
18 | list(APPEND TEST_SOURCES
19 | win32/WinMain.cpp
20 | )
21 |
22 | add_definitions(-DJNI_STATIC)
23 | endif ()
24 |
25 | include_directories(
26 | "${CMAKE_CURRENT_SOURCE_DIR}"
27 | "${LIBRARY_PRODUCT_DIR}/include/androidjni++"
28 | "${LIBRARY_PRODUCT_DIR}/include/androidjni++/android"
29 | "${CMAKE_SOURCE_DIR}"
30 | "${CMAKE_CURRENT_BINARY_DIR}"
31 | "${CMAKE_CURRENT_BINARY_DIR}/../testlib/GeneratedFiles"
32 | "${CMAKE_BINARY_DIR}"
33 | )
34 |
35 | add_executable(testapp ${TEST_SOURCES})
36 |
37 | if (ANDROID)
38 | set_target_properties(testapp PROPERTIES ANDROID_JAR_DEPENDENCIES androidjni.annotations)
39 | import_libraries(testapp testlib)
40 | add_dependencies(testapp androidjni.annotations)
41 | elseif (WIN32)
42 | target_link_libraries(testapp testlib)
43 | endif ()
44 |
--------------------------------------------------------------------------------
/test/testlib/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(TESTLIB_SOURCES
2 | StringGeneratorClientNatives.cpp
3 | StringGeneratorNatives.cpp
4 | )
5 |
6 | if (ANDROID)
7 | list(APPEND TESTLIB_SOURCES
8 | android/JNIMain.cpp
9 | )
10 | else ()
11 | list(APPEND TESTLIB_SOURCES
12 | generic/StringGeneratorClient.cpp
13 | generic/StringGenerator.cpp
14 | )
15 |
16 | if (WIN32)
17 | list(APPEND TESTLIB_SOURCES
18 | win32/DLLMain.cpp
19 | )
20 | endif ()
21 | endif ()
22 |
23 | include_directories(
24 | "${CMAKE_CURRENT_SOURCE_DIR}"
25 | "${LIBRARY_PRODUCT_DIR}/include/androidjni++"
26 | "${LIBRARY_PRODUCT_DIR}/include/androidjni++/android"
27 | "${CMAKE_SOURCE_DIR}"
28 | "${CMAKE_CURRENT_BINARY_DIR}"
29 | "${CMAKE_CURRENT_BINARY_DIR}/GeneratedFiles"
30 | "${CMAKE_BINARY_DIR}"
31 | )
32 |
33 | link_directories(
34 | ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
35 | )
36 |
37 | set(TESTLIB_JAVA_SOURCES
38 | ../testapp/android/src/com/example/test/StringGenerator.java
39 | ../testapp/android/src/com/example/test/StringGeneratorClient.java
40 | )
41 |
42 | add_definitions(-DJNI_STATIC)
43 |
44 | GENERATE_INTERFACE_STUBS(TESTLIB_SOURCES "${TESTLIB_JAVA_SOURCES}")
45 | WRAP_SOURCELIST(${TESTLIB_SOURCES})
46 |
47 | add_library(testlib SHARED ${TESTLIB_SOURCES})
48 |
49 | ADD_PREFIX_HEADER(testlib TestLibPrefix.h)
50 |
51 | target_link_libraries(testlib PUBLIC androidjni++)
52 |
53 | if (ANDROID)
54 | target_link_libraries(testlib PRIVATE log)
55 | endif ()
56 |
--------------------------------------------------------------------------------
/androidjni/JNIIncludes.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include "LocalRef.h"
29 | #include
30 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2016 NAVER Corp.
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions are met:
5 |
6 | 1. Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 |
9 | 2. Redistributions in binary form must reproduce the above copyright notice,
10 | this list of conditions and the following disclaimer in the documentation
11 | and/or other materials provided with the distribution.
12 |
13 | 3. Neither the name of the copyright holder nor the names of its contributors
14 | may be used to endorse or promote products derived from this software
15 | without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 | POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/androidjni/annotations/src/labs/naver/androidjni/AbstractMethod.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | package labs.naver.androidjni;
27 |
28 | public @interface AbstractMethod {
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/androidjni/annotations/src/labs/naver/androidjni/CalledByNative.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | package labs.naver.androidjni;
27 |
28 | public @interface CalledByNative {
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/androidjni/annotations/src/labs/naver/androidjni/AccessedByNative.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | package labs.naver.androidjni;
27 |
28 | public @interface AccessedByNative {
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/androidjni/annotations/src/labs/naver/androidjni/NativeConstructor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | package labs.naver.androidjni;
27 |
28 | public @interface NativeConstructor {
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/androidjni/annotations/src/labs/naver/androidjni/NativeDestructor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | package labs.naver.androidjni;
27 |
28 | public @interface NativeDestructor {
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/androidjni/annotations/src/labs/naver/androidjni/NativeObjectField.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | package labs.naver.androidjni;
27 |
28 | public @interface NativeObjectField {
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/android/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(ANDROID_SOURCES)
2 |
3 | set(GENERATOR_INTERFACES_DIR "${CMAKE_SOURCE_DIR}/generator/interfaces")
4 |
5 | set(ANDROID_INTERFACES
6 | ${GENERATOR_INTERFACES_DIR}/Boolean.in
7 | ${GENERATOR_INTERFACES_DIR}/HashMap.in
8 | ${GENERATOR_INTERFACES_DIR}/Integer.in
9 | ${GENERATOR_INTERFACES_DIR}/Long.in
10 | ${GENERATOR_INTERFACES_DIR}/Point.in
11 | ${GENERATOR_INTERFACES_DIR}/Rect.in
12 | ${GENERATOR_INTERFACES_DIR}/String.in
13 | ${GENERATOR_INTERFACES_DIR}/Vector.in
14 | )
15 |
16 | foreach (_file ${ANDROID_INTERFACES})
17 | if (NOT ANDROID)
18 | string(REGEX REPLACE "${GENERATOR_INTERFACES_DIR}/(.*).in" "\\1.cpp" _source "${_file}")
19 | set(ANDROID_SOURCES ${ANDROID_SOURCES} ${_source})
20 | endif ()
21 |
22 | string(REGEX REPLACE "${GENERATOR_INTERFACES_DIR}/(.*).in" "JNI/\\1JNI.cpp" _source "${_file}")
23 | set(ANDROID_SOURCES ${ANDROID_SOURCES} ${_source})
24 | endforeach ()
25 |
26 | include_directories(
27 | "${CMAKE_CURRENT_SOURCE_DIR}"
28 | "${CMAKE_SOURCE_DIR}"
29 | "${CMAKE_SOURCE_DIR}/androidjni"
30 | "${CMAKE_SOURCE_DIR}/androidjni/platforms/${TARGET_PLATFORM}"
31 | "${CMAKE_CURRENT_BINARY_DIR}"
32 | "${CMAKE_CURRENT_BINARY_DIR}/GeneratedFiles"
33 | "${CMAKE_BINARY_DIR}"
34 | )
35 |
36 | add_definitions(-DBUILDING_JNILIB -DJNI_STATIC)
37 |
38 | GENERATE_INTERFACE_STUBS(ANDROID_SOURCES "${ANDROID_INTERFACES}")
39 | WRAP_SOURCELIST(${ANDROID_HEADERS} ${ANDROID_SOURCES})
40 |
41 | add_library(android OBJECT ${ANDROID_SOURCES})
42 |
43 | ADD_PREFIX_HEADER(android JNIExportMacros.h)
44 |
--------------------------------------------------------------------------------
/androidjni/annotations/src/labs/naver/androidjni/NativeNamespace.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | package labs.naver.androidjni;
27 |
28 | public @interface NativeNamespace {
29 |
30 | public String value() default "";
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/androidjni/annotations/src/labs/naver/androidjni/NativeExportMacro.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | package labs.naver.androidjni;
27 |
28 | public @interface NativeExportMacro {
29 |
30 | public String value() default "";
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/androidjni/platforms/android/JavaVM.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include "AndroidJNI.h"
29 | #include "AndroidLog.h"
30 |
31 | namespace JNI {
32 |
33 | JNI_EXPORT JNIEnv* getEnv();
34 | JNI_EXPORT JavaVM* getVM();
35 | JNI_EXPORT void setVM(JavaVM*);
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/android/JNI/LongJNI.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include
27 |
28 | namespace java {
29 | namespace lang {
30 | namespace Natives {
31 |
32 | Long* Long::CTOR()
33 | {
34 | return new Long;
35 | }
36 |
37 | } // namespace Natives
38 | } // namespace lang
39 | } // namespace java
40 |
--------------------------------------------------------------------------------
/android/java/lang/Long.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | namespace java {
31 | namespace lang {
32 |
33 | using Long = java::lang::Managed::Long;
34 |
35 | } // namespace lang
36 | } // namespace java
37 |
38 | using Long = java::lang::Long;
39 |
--------------------------------------------------------------------------------
/android/JNI/java/lang/Long.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | namespace java {
31 | namespace lang {
32 |
33 | using Long = java::lang::Natives::Long;
34 |
35 | } // namespace lang
36 | } // namespace java
37 |
38 | using Long = java::lang::Long;
39 |
--------------------------------------------------------------------------------
/android/JNI/VectorJNI.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include
27 |
28 | namespace java {
29 | namespace util {
30 | namespace Natives {
31 |
32 | Vector* Vector::CTOR()
33 | {
34 | return new Vector;
35 | }
36 |
37 | } // namespace Natives
38 | } // namespace util
39 | } // namespace java
40 |
--------------------------------------------------------------------------------
/android/JNI/BooleanJNI.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include
27 |
28 | namespace java {
29 | namespace lang {
30 | namespace Natives {
31 |
32 | Boolean* Boolean::CTOR()
33 | {
34 | return new Boolean;
35 | }
36 |
37 | } // namespace Natives
38 | } // namespace lang
39 | } // namespace java
40 |
--------------------------------------------------------------------------------
/android/JNI/HashMapJNI.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include
27 |
28 | namespace java {
29 | namespace util {
30 | namespace Natives {
31 |
32 | HashMap* HashMap::CTOR()
33 | {
34 | return new HashMap;
35 | }
36 |
37 | } // namespace Natives
38 | } // namespace util
39 | } // namespace java
40 |
--------------------------------------------------------------------------------
/android/JNI/IntegerJNI.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include
27 |
28 | namespace java {
29 | namespace lang {
30 | namespace Natives {
31 |
32 | Integer* Integer::CTOR()
33 | {
34 | return new Integer;
35 | }
36 |
37 | } // namespace Natives
38 | } // namespace lang
39 | } // namespace java
40 |
--------------------------------------------------------------------------------
/android/JNI/java/lang/String.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | namespace java {
31 | namespace lang {
32 |
33 | using String = java::lang::Natives::String;
34 |
35 | } // namespace lang
36 | } // namespace java
37 |
38 | using String = java::lang::String;
39 |
--------------------------------------------------------------------------------
/android/JNI/java/util/Vector.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | namespace java {
31 | namespace util {
32 |
33 | using Vector = java::util::Natives::Vector;
34 |
35 | } // namespace util
36 | } // namespace java
37 |
38 | using Vector = java::util::Vector;
39 |
--------------------------------------------------------------------------------
/android/java/lang/String.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | namespace java {
31 | namespace lang {
32 |
33 | using String = java::lang::Managed::String;
34 |
35 | } // namespace lang
36 | } // namespace java
37 |
38 | using String = java::lang::String;
39 |
--------------------------------------------------------------------------------
/android/java/util/Vector.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | namespace java {
31 | namespace util {
32 |
33 | using Vector = java::util::Managed::Vector;
34 |
35 | } // namespace util
36 | } // namespace java
37 |
38 | using Vector = java::util::Vector;
39 |
--------------------------------------------------------------------------------
/android/java/lang/Boolean.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | namespace java {
31 | namespace lang {
32 |
33 | using Boolean = java::lang::Managed::Boolean;
34 |
35 | } // namespace lang
36 | } // namespace java
37 |
38 | using Boolean = java::lang::Boolean;
39 |
--------------------------------------------------------------------------------
/android/java/lang/Integer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | namespace java {
31 | namespace lang {
32 |
33 | using Integer = java::lang::Managed::Integer;
34 |
35 | } // namespace lang
36 | } // namespace java
37 |
38 | using Integer = java::lang::Integer;
39 |
--------------------------------------------------------------------------------
/android/java/util/HashMap.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | namespace java {
31 | namespace util {
32 |
33 | using HashMap = java::util::Managed::HashMap;
34 |
35 | } // namespace util
36 | } // namespace java
37 |
38 | using HashMap = java::util::HashMap;
39 |
--------------------------------------------------------------------------------
/android/JNI/RectJNI.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include
27 |
28 | namespace android {
29 | namespace graphics {
30 | namespace Natives {
31 |
32 | Rect* Rect::CTOR()
33 | {
34 | return new Rect;
35 | }
36 |
37 | } // namespace Natives
38 | } // namespace graphics
39 | } // namespace android
40 |
--------------------------------------------------------------------------------
/android/JNI/java/lang/Boolean.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | namespace java {
31 | namespace lang {
32 |
33 | using Boolean = java::lang::Natives::Boolean;
34 |
35 | } // namespace lang
36 | } // namespace java
37 |
38 | using Boolean = java::lang::Boolean;
39 |
--------------------------------------------------------------------------------
/android/JNI/java/lang/Integer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | namespace java {
31 | namespace lang {
32 |
33 | using Integer = java::lang::Natives::Integer;
34 |
35 | } // namespace lang
36 | } // namespace java
37 |
38 | using Integer = java::lang::Integer;
39 |
--------------------------------------------------------------------------------
/android/JNI/java/util/HashMap.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | namespace java {
31 | namespace util {
32 |
33 | using HashMap = java::util::Natives::HashMap;
34 |
35 | } // namespace util
36 | } // namespace java
37 |
38 | using HashMap = java::util::HashMap;
39 |
--------------------------------------------------------------------------------
/android/JNI/PointJNI.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include
27 |
28 | namespace android {
29 | namespace graphics {
30 | namespace Natives {
31 |
32 | Point* Point::CTOR()
33 | {
34 | return new Point;
35 | }
36 |
37 | } // namespace Natives
38 | } // namespace graphics
39 | } // namespace android
40 |
--------------------------------------------------------------------------------
/android/JNI/android/graphics/Rect.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | namespace android {
31 | namespace graphics {
32 |
33 | using Rect = android::graphics::Natives::Rect;
34 |
35 | } // namespace graphics
36 | } // namespace android
37 |
38 | using Rect = android::graphics::Rect;
39 |
--------------------------------------------------------------------------------
/android/android/graphics/Rect.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | namespace android {
31 | namespace graphics {
32 |
33 | using Rect = android::graphics::Managed::Rect;
34 |
35 | } // namespace graphics
36 | } // namespace android
37 |
38 | using Rect = android::graphics::Rect;
39 |
--------------------------------------------------------------------------------
/android/android/graphics/Point.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | namespace android {
31 | namespace graphics {
32 |
33 | using Point = android::graphics::Managed::Point;
34 |
35 | } // namespace graphics
36 | } // namespace android
37 |
38 | using Point = android::graphics::Point;
39 |
--------------------------------------------------------------------------------
/android/JNI/android/graphics/Point.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | namespace android {
31 | namespace graphics {
32 |
33 | using Point = android::graphics::Natives::Point;
34 |
35 | } // namespace graphics
36 | } // namespace android
37 |
38 | using Point = android::graphics::Point;
39 |
--------------------------------------------------------------------------------
/test/testlib/TestLibPrefix.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | #if defined(WIN32)
31 | #if defined(testlib_EXPORTS)
32 | #define TESTLIB_EXPORT __declspec(dllexport)
33 | #else
34 | #define TESTLIB_EXPORT __declspec(dllimport)
35 | #endif
36 | #else
37 | #define TESTLIB_EXPORT __attribute__((visibility("default")))
38 | #endif
39 |
--------------------------------------------------------------------------------
/android/Boolean.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include
27 |
28 | namespace java {
29 | namespace lang {
30 | namespace Managed {
31 |
32 | void Boolean::INIT(bool value)
33 | {
34 | this->value = value;
35 | }
36 |
37 | bool Boolean::booleanValue()
38 | {
39 | return value;
40 | }
41 |
42 | } // namespace Managed
43 | } // namespace lang
44 | } // namespace java
45 |
--------------------------------------------------------------------------------
/androidjni/JNIExportMacros.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #if defined(WIN32)
29 | #if defined(JNI_STATIC)
30 | #define JNI_EXPORT
31 | #else
32 | #if defined(JNI_EXPORTS) || defined(BUILDING_JNILIB)
33 | #define JNI_EXPORT __declspec(dllexport)
34 | #else
35 | #define JNI_EXPORT __declspec(dllimport)
36 | #endif
37 | #endif
38 | #else
39 | #define JNI_EXPORT __attribute__((visibility("default")))
40 | #endif
41 |
42 | #define NO_EXPORT
43 |
--------------------------------------------------------------------------------
/test/testlib/StringGeneratorClientNatives.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include
27 |
28 | namespace com {
29 | namespace example {
30 | namespace test {
31 | namespace Natives {
32 |
33 | // TODO: IMPLEMENT
34 | StringGeneratorClient* StringGeneratorClient::CTOR()
35 | {
36 | return new StringGeneratorClient;
37 | }
38 |
39 | } // namespace Natives
40 | } // namespace test
41 | } // namespace example
42 | } // namespace com
43 |
44 |
--------------------------------------------------------------------------------
/android/JNI/StringJNI.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include
27 |
28 | namespace java {
29 | namespace lang {
30 | namespace Natives {
31 |
32 | String* String::CTOR()
33 | {
34 | return new String;
35 | }
36 |
37 | JNI::PassLocalRef String::create(const std::string& data)
38 | {
39 | return String::create(JNI::PassArray(reinterpret_cast(data.data()), data.size(), true));
40 | }
41 |
42 | } // namespace Natives
43 | } // namespace lang
44 | } // namespace java
45 |
--------------------------------------------------------------------------------
/test/testlib/win32/DLLMain.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include
27 | #include
28 |
29 | BOOL APIENTRY DllMain( HMODULE hModule,
30 | DWORD ul_reason_for_call,
31 | LPVOID lpReserved
32 | )
33 | {
34 | switch (ul_reason_for_call)
35 | {
36 | case DLL_PROCESS_ATTACH:
37 | case DLL_THREAD_ATTACH:
38 | case DLL_THREAD_DETACH:
39 | case DLL_PROCESS_DETACH:
40 | break;
41 | }
42 | return TRUE;
43 | }
44 |
45 |
--------------------------------------------------------------------------------
/androidjni/platforms/android/AndroidLog.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #ifndef ONIG_AndroidLog_h
27 | #define ONIG_AndroidLog_h
28 |
29 | #include
30 |
31 | #ifndef LOG_TAG
32 | #define LOG_TAG "JavaJNI"
33 | #endif
34 |
35 | #ifndef ALOGD
36 | #define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
37 | #endif
38 |
39 | #ifndef ALOGE
40 | #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
41 | #endif
42 |
43 | #ifndef ALOG_ASSERT
44 | #define ALOG_ASSERT(env, ...) ALOGE(__VA_ARGS__)
45 | #endif
46 |
47 | #endif // End of File
48 |
--------------------------------------------------------------------------------
/test/testlib/generic/StringGeneratorClient.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include
27 |
28 | namespace com {
29 | namespace example {
30 | namespace test {
31 | namespace Managed {
32 |
33 | // TODO: IMPLEMENT
34 | void StringGeneratorClient::INIT()
35 | {
36 | }
37 |
38 | // TODO: IMPLEMENT
39 | void StringGeneratorClient::stringFromJNI(const std::string& s)
40 | {
41 | }
42 |
43 | // TODO: IMPLEMENT
44 | void StringGeneratorClient::stringFromJNI(std::shared_ptr v)
45 | {
46 | }
47 |
48 | // TODO: IMPLEMENT
49 | void StringGeneratorClient::stringFromJNI(const std::vector& i)
50 | {
51 | }
52 |
53 | } // namespace Managed
54 | } // namespace test
55 | } // namespace example
56 | } // namespace com
57 |
--------------------------------------------------------------------------------
/android/Integer.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include
27 |
28 | namespace java {
29 | namespace lang {
30 | namespace Managed {
31 |
32 | void Integer::INIT(int32_t value)
33 | {
34 | this->value = value;
35 | }
36 |
37 | int8_t Integer::byteValue()
38 | {
39 | return static_cast(value);
40 | }
41 |
42 | float Integer::floatValue()
43 | {
44 | return static_cast(value);
45 | }
46 |
47 | int32_t Integer::intValue()
48 | {
49 | return value;
50 | }
51 |
52 | int64_t Integer::longValue()
53 | {
54 | return static_cast(value);
55 | }
56 |
57 | int16_t Integer::shortValue()
58 | {
59 | return static_cast(value);
60 | }
61 |
62 | } // namespace Managed
63 | } // namespace lang
64 | } // namespace java
65 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.4)
2 |
3 | project(androidjni++)
4 |
5 | set(LIBRARY_PRODUCT_DIR "${CMAKE_BINARY_DIR}" CACHE PATH "Path to the directory where products will be copied to.")
6 |
7 | find_package(PythonInterp 2.7 REQUIRED)
8 | set(GENERATOR_SCRIPT "${CMAKE_SOURCE_DIR}/generator/scripts/interface-generator.py")
9 |
10 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_PRODUCT_DIR})
11 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_PRODUCT_DIR})
12 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBRARY_PRODUCT_DIR})
13 |
14 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
15 | include(HelperMacros)
16 | include(Options${CMAKE_SYSTEM_NAME})
17 |
18 | if (ANDROID)
19 | set(TARGET_PLATFORM android)
20 | else ()
21 | set(TARGET_PLATFORM generic)
22 | endif ()
23 |
24 | macro(LIST_INTERFACE_OUTPUTS _output_list _basename)
25 | set(_interface_outputs
26 | ${CMAKE_CURRENT_BINARY_DIR}/GeneratedFiles/${_basename}NativesStub.cpp
27 | )
28 | if (NOT ANDROID)
29 | set(_interface_outputs ${_interface_outputs}
30 | ${CMAKE_CURRENT_BINARY_DIR}/GeneratedFiles/${_basename}ManagedStub.cpp
31 | )
32 | endif ()
33 |
34 | set(${_output_list} ${${_output_list}} ${_interface_outputs})
35 | unset(_interface_outputs)
36 | endmacro()
37 |
38 | macro(GENERATE_INTERFACE_STUBS _output_sources _idl_list)
39 | foreach (_idl ${_idl_list})
40 | get_filename_component(_basename ${_idl} NAME_WE)
41 | get_filename_component(_absolute ${_idl} ABSOLUTE)
42 | list_interface_outputs(_outputs ${_basename})
43 | set(${_output_sources} ${${_output_sources}} ${_idl} ${_outputs})
44 | add_custom_command(
45 | OUTPUT ${_outputs}
46 | MAIN_DEPENDENCY ${_idl}
47 | DEPENDS ${GENERATOR_SCRIPT}
48 | COMMAND ${PYTHON_EXECUTABLE} ${GENERATOR_SCRIPT} --java ${_absolute} --shared ${CMAKE_CURRENT_BINARY_DIR}/GeneratedFiles --${TARGET_PLATFORM} ${CMAKE_CURRENT_BINARY_DIR}/GeneratedFiles
49 | VERBATIM)
50 | unset(_outputs)
51 | endforeach ()
52 | endmacro()
53 |
54 | add_subdirectory(android)
55 | add_subdirectory(androidjni)
56 | add_subdirectory(test)
57 |
--------------------------------------------------------------------------------
/test/testlib/android/JNIMain.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include
27 |
28 | #include // for registerClass()
29 |
30 | /* This is a trivial JNI example where we use a native method
31 | * to return a new VM String. See the corresponding Java source
32 | * file located at:
33 | *
34 | */
35 | JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* /*reserved*/)
36 | {
37 | // Save the JavaVM pointer for use globally.
38 | JNI::setVM(vm);
39 |
40 | JNIEnv* env = 0;
41 | jint result = -1;
42 |
43 | if (vm->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK) {
44 | ALOGE("GetEnv failed!");
45 | return result;
46 | }
47 |
48 | com::example::test::Natives::StringGenerator::registerClass();
49 | return JNI_VERSION_1_4;
50 | }
51 |
--------------------------------------------------------------------------------
/androidjni/ReferenceFunctions.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include "Abbreviations.h"
29 | #include "JNIExportMacros.h"
30 |
31 | #include
32 | #include
33 | #include
34 | #include
35 |
36 | namespace JNI {
37 |
38 | typedef void* ref_t;
39 | typedef struct _weak_ref* weak_t;
40 |
41 | enum RefType { None, Local, Global };
42 |
43 | JNI_EXPORT ref_t refLocal(ref_t);
44 | JNI_EXPORT void derefLocal(ref_t);
45 |
46 | JNI_EXPORT ref_t refGlobal(ref_t);
47 | JNI_EXPORT void derefGlobal(ref_t);
48 |
49 | JNI_EXPORT bool isExpiredWeakGlobal(weak_t);
50 | JNI_EXPORT weak_t refWeakGlobal(ref_t);
51 | JNI_EXPORT void derefWeakGlobal(weak_t);
52 |
53 | JNI_EXPORT ref_t popLocalCallerObjectRef();
54 | JNI_EXPORT void pushLocalCallerObjectRef(ref_t);
55 |
56 | } // namespace JNI
57 |
--------------------------------------------------------------------------------
/androidjni/platforms/android/AndroidJNI.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | #define JNI_EXPORT __attribute__((visibility("default")))
31 |
32 | #define CALL_JNI(Function, This, ...) JNI::getEnv()->Function(reinterpret_cast(This), ##__VA_ARGS__)
33 |
34 | #define GetStringField GetObjectField
35 | #define SetStringField SetObjectField
36 | #define GetStaticStringField GetStaticObjectField
37 | #define SetStaticStringField SetStaticObjectField
38 | #define CallStringMethod CallObjectMethod
39 | #define CallStaticStringMethod CallStaticObjectMethod
40 | #define NewStringArray NewObjectArray
41 | #define GetStringArrayElement GetObjectArrayElement
42 | #define SetStringArrayElement SetObjectArrayElement
43 |
44 | class _jstringArray : public _jarray {};
45 | typedef _jstringArray *jstringArray;
46 |
--------------------------------------------------------------------------------
/android/Long.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include
27 |
28 | namespace java {
29 | namespace lang {
30 | namespace Managed {
31 |
32 | void Long::INIT(int64_t value)
33 | {
34 | this->value = value;
35 | }
36 |
37 | int8_t Long::byteValue()
38 | {
39 | return static_cast(value);
40 | }
41 |
42 | double Long::doubleValue()
43 | {
44 | return static_cast(value);
45 | }
46 |
47 | float Long::floatValue()
48 | {
49 | return static_cast(value);
50 | }
51 |
52 | int32_t Long::intValue()
53 | {
54 | return static_cast(value);
55 | }
56 |
57 | int64_t Long::longValue()
58 | {
59 | return value;
60 | }
61 |
62 | int16_t Long::shortValue()
63 | {
64 | return static_cast(value);
65 | }
66 |
67 | } // namespace Managed
68 | } // namespace lang
69 | } // namespace java
70 |
--------------------------------------------------------------------------------
/test/testlib/generic/StringGenerator.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include
27 |
28 | #include
29 |
30 | namespace com {
31 | namespace example {
32 | namespace test {
33 | namespace Managed {
34 |
35 | // TODO: IMPLEMENT
36 | void StringGenerator::INIT()
37 | {
38 | nativeCreate();
39 | }
40 |
41 | // TODO: IMPLEMENT
42 | int32_t StringGenerator::getNumber()
43 | {
44 | return 1315;
45 | }
46 |
47 | // TODO: IMPLEMENT
48 | std::shared_ptr StringGenerator::getClient()
49 | {
50 | return std::static_pointer_cast(nativeGetClient());
51 | }
52 |
53 | // TODO: IMPLEMENT
54 | void StringGenerator::setWhat(std::shared_ptr what)
55 | {
56 | nativeSetWhat(what);
57 | }
58 |
59 | } // namespace Managed
60 | } // namespace test
61 | } // namespace example
62 | } // namespace com
63 |
--------------------------------------------------------------------------------
/test/testapp/android/src/com/example/test/StringGeneratorClient.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | package com.example.test;
27 |
28 | import java.util.Vector;
29 |
30 | import labs.naver.androidjni.CalledByNative;
31 | import labs.naver.androidjni.NativeExportMacro;
32 | import labs.naver.androidjni.NativeNamespace;
33 | import android.util.Log;
34 |
35 | @NativeNamespace("com.example.test")
36 | @NativeExportMacro("TESTLIB_EXPORT")
37 | public class StringGeneratorClient {
38 |
39 | @CalledByNative
40 | void stringFromJNI(String s) {
41 | Log.d("StringGeneratorClient", "String from JNI: " + s);
42 | }
43 |
44 | @CalledByNative
45 | void stringFromJNI(Vector v) {
46 | Log.d("StringGeneratorClient", "String from JNI: " + v.toString());
47 | }
48 |
49 | @CalledByNative
50 | void stringFromJNI(String[] i) {
51 | Log.d("StringGeneratorClient", "String from JNI: " + i.toString());
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/androidjni/AnyObject.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include "ReferenceFunctions.h"
29 |
30 | #include
31 |
32 | namespace JNI {
33 |
34 | template class LocalRef;
35 |
36 | class JNI_EXPORT AnyObject {
37 | public:
38 | AnyObject() = default;
39 | virtual ~AnyObject() = default;
40 |
41 | virtual void ref() { }
42 | virtual void deref() { }
43 |
44 | virtual ref_t refLocal() { return 0; }
45 | virtual ref_t refGlobal() { return 0; }
46 |
47 | private:
48 | AnyObject(const AnyObject&) = delete;
49 | AnyObject& operator=(const AnyObject&) = delete;
50 | }; // class AnyObject
51 |
52 | template inline T* getPtr(ref_t, AnyObject* ptr)
53 | {
54 | return static_cast(ptr);
55 | }
56 |
57 | template<> inline AnyObject* getPtr(ref_t, AnyObject* ptr)
58 | {
59 | return ptr;
60 | }
61 |
62 | template inline T* adoptPtr(ref_t ref, AnyObject* ptr)
63 | {
64 | if (ptr)
65 | return getPtr(ref, ptr);
66 |
67 | LocalRef adoptedPtr = T::fromRef(JNI::refLocal(ref));
68 | adoptedPtr.getPtr()->ref();
69 | return adoptedPtr.getPtr();
70 | }
71 |
72 | } // namespace JNI
73 |
--------------------------------------------------------------------------------
/androidjni/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(ANDROIDJNI_HEADERS
2 | Abbreviations.h
3 | AnyObject.h
4 | GlobalRef.h
5 | JNIExportMacros.h
6 | JNIIncludes.h
7 | LocalRef.h
8 | NativeObject.h
9 | PassLocalRef.h
10 | ReferenceFunctions.h
11 | WeakGlobalRef.h
12 | )
13 |
14 | if (ANDROID)
15 | list(APPEND ANDROIDJNI_HEADERS
16 | platforms/android/AndroidJNI.h
17 | platforms/android/AndroidLog.h
18 | platforms/android/JavaVM.h
19 |
20 | platforms/android/androidjni/ArrayFunctions.h
21 | platforms/android/androidjni/MarshalingHelpers.h
22 | platforms/android/androidjni/PassArray.h
23 | )
24 |
25 | list(APPEND ANDROIDJNI_SOURCES
26 | platforms/android/JavaVM.cpp
27 | platforms/android/ReferenceFunctions.cpp
28 |
29 | platforms/android/androidjni/ArrayFunctions.cpp
30 | )
31 | else ()
32 | list(APPEND ANDROIDJNI_HEADERS
33 | platforms/generic/ObjectReference.h
34 |
35 | platforms/generic/androidjni/MarshalingHelpers.h
36 | platforms/generic/androidjni/PassArray.h
37 | )
38 |
39 | list(APPEND ANDROIDJNI_SOURCES
40 | platforms/generic/ObjectReference.cpp
41 | platforms/generic/ReferenceFunctions.cpp
42 | )
43 | endif ()
44 |
45 | include_directories(
46 | "${CMAKE_CURRENT_SOURCE_DIR}"
47 | "${CMAKE_CURRENT_SOURCE_DIR}/platforms/${TARGET_PLATFORM}"
48 | "${CMAKE_SOURCE_DIR}"
49 | "${CMAKE_CURRENT_BINARY_DIR}"
50 | "${CMAKE_BINARY_DIR}"
51 | )
52 |
53 | add_custom_command(
54 | OUTPUT ${LIBRARY_PRODUCT_DIR}/scripts/interface-generator.py
55 | MAIN_DEPENDENCY ${GENERATOR_SCRIPT}
56 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/generator/scripts ${LIBRARY_PRODUCT_DIR}/scripts
57 | VERBATIM)
58 |
59 | add_subdirectory(annotations)
60 |
61 | add_definitions(-DBUILDING_JNILIB -DJNI_STATIC)
62 |
63 | WRAP_SOURCELIST(${ANDROIDJNI_HEADERS} ${ANDROIDJNI_SOURCES})
64 |
65 | add_library(androidjni++ ${ANDROIDJNI_HEADERS} ${ANDROIDJNI_SOURCES} ${GENERATOR_SCRIPT} $)
66 |
67 | ADD_PREFIX_HEADER(androidjni++ JNIExportMacros.h)
68 | ADD_POST_BUILD_COMMAND(androidjni++)
69 |
70 | COPY_LIBRARY_HEADERS(androidjni++ "${ANDROIDJNI_HEADERS}" include/androidjni++/androidjni)
71 |
72 | set(ANDROID_SOURCE_DIR ${CMAKE_SOURCE_DIR}/android)
73 | set(ANDROID_BINARY_DIR ${CMAKE_BINARY_DIR}/android)
74 |
75 | COPY_LIBRARY_HEADERS_DIRECTORY(androidjni++ "${ANDROID_SOURCE_DIR}" include/androidjni++/android)
76 | COPY_LIBRARY_HEADERS_DIRECTORY(androidjni++ "${ANDROID_BINARY_DIR}/GeneratedFiles" include/androidjni++/android)
77 |
--------------------------------------------------------------------------------
/generator/interfaces/Integer.in:
--------------------------------------------------------------------------------
1 |
2 | package java.lang;
3 |
4 | @NativeNamespace("java.lang")
5 | @NativeExportMacro("JNI_EXPORT")
6 | public final class Integer {
7 |
8 | @AccessedByNative
9 | public static final int MAX_VALUE = 0x7FFFFFFF;
10 | @AccessedByNative
11 | public static final int MIN_VALUE = 0x80000000;
12 | @AccessedByNative
13 | public static final int SIZE = 32;
14 |
15 | @AccessedByNative
16 | private int value;
17 |
18 | @CalledByNative
19 | public Integer(int value) {}
20 | public Integer(String string) {}
21 |
22 | @Override
23 | @CalledByNative
24 | public byte byteValue();
25 |
26 | public int compareTo(Integer object);
27 | public static int compare(int lhs, int rhs);
28 |
29 | public static Integer decode(String string);
30 |
31 | @Override
32 | public double doubleValue();
33 |
34 | @Override
35 | public boolean equals(Object o);
36 |
37 | @Override
38 | @CalledByNative
39 | public float floatValue() ;
40 |
41 | public static Integer getInteger(String string);
42 | public static Integer getInteger(String string, int defaultValue);
43 | public static Integer getInteger(String string, Integer defaultValue);
44 |
45 | @Override
46 | public int hashCode();
47 |
48 | @Override
49 | @CalledByNative
50 | public int intValue();
51 | @Override
52 | @CalledByNative
53 | public long longValue();
54 |
55 | public static int parseInt(String string);
56 | public static int parseInt(String string, int radix);
57 |
58 | @Override
59 | @CalledByNative
60 | public short shortValue();
61 |
62 | public static String toBinaryString(int i);
63 | public static String toHexString(int i);
64 | public static String toOctalString(int i);
65 |
66 | @Override
67 | public String toString();
68 |
69 | public static String toString(int i);
70 | public static String toString(int i, int radix);
71 | public static Integer valueOf(String string);
72 | public static Integer valueOf(String string, int radix);
73 |
74 | public static int highestOneBit(int i);
75 | public static int lowestOneBit(int i);
76 |
77 | public static int numberOfLeadingZeros(int i);
78 | public static int numberOfTrailingZeros(int i);
79 |
80 | public static int bitCount(int i);
81 | public static int rotateLeft(int i, int distance);
82 | public static int rotateRight(int i, int distance);
83 | public static int reverseBytes(int i);
84 | public static int reverse(int i);
85 | public static int signum(int i);
86 |
87 | public static Integer valueOf(int i);
88 | }
89 |
--------------------------------------------------------------------------------
/androidjni/Abbreviations.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #if !defined(UNUSED_PARAM) && defined(_MSC_VER)
29 | #define UNUSED_PARAM(variable) (void)&variable
30 | #endif
31 |
32 | #if !defined(UNUSED_PARAM)
33 | #define UNUSED_PARAM(variable) (void)variable
34 | #endif
35 |
36 | #define FIELD_INTERFACE_CLASS_NAME(FieldName) GeneratedClassFor##FieldName
37 |
38 | #define FIELD_INTERFACE(FieldName, NativeType) \
39 | class CLASS_EXPORT FIELD_INTERFACE_CLASS_NAME(FieldName) final { \
40 | public: \
41 | void set(NativeType); \
42 | std::decay::type get(); \
43 | FIELD_INTERFACE_CLASS_NAME(FieldName)(JNI::weak_t& ref) : m_ref(ref) { } \
44 | ~FIELD_INTERFACE_CLASS_NAME(FieldName)() { } \
45 | private: \
46 | JNI::weak_t& m_ref; \
47 | } FieldName
48 |
49 | #define STATIC_FIELD_INTERFACE(FieldName, NativeType) \
50 | static class CLASS_EXPORT FIELD_INTERFACE_CLASS_NAME(FieldName) final { \
51 | public: \
52 | void set(NativeType); \
53 | std::decay::type get(); \
54 | } FieldName
55 |
56 | #define ADD_TYPE_MAPPING(ManagedType, NativeType) \
57 | static inline ManagedType toManaged(NativeType value) { return (ManagedType)value; } \
58 | static inline NativeType toNative(ManagedType value) { return (NativeType)value; }
59 |
--------------------------------------------------------------------------------
/androidjni/platforms/generic/ObjectReference.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include "ObjectReference.h"
27 |
28 | namespace JNI {
29 |
30 | ref_t ObjectReference::refLocal()
31 | {
32 | if (m_localRefCount == 0 && !m_referencedPtr)
33 | m_referencedPtr = m_dereferencedPtr.lock();
34 |
35 | ++m_localRefCount;
36 | return this;
37 | }
38 |
39 | void ObjectReference::derefLocal(ref_t ref)
40 | {
41 | assert(ref == this);
42 | assert(m_localRefCount > 0);
43 | --m_localRefCount;
44 | deleteIfPossible();
45 | }
46 |
47 | ref_t ObjectReference::refGlobal()
48 | {
49 | if (m_globalRefCount == 0 && !m_referencedPtr)
50 | m_referencedPtr = m_dereferencedPtr.lock();
51 |
52 | ++m_globalRefCount;
53 | return this;
54 | }
55 |
56 | void ObjectReference::derefGlobal(ref_t ref)
57 | {
58 | assert(ref == this);
59 | assert(m_globalRefCount > 0);
60 | --m_globalRefCount;
61 | deleteIfPossible();
62 | }
63 |
64 | void ObjectReference::deleteIfPossible()
65 | {
66 | if (m_localRefCount > 0 || m_globalRefCount > 0)
67 | return;
68 |
69 | if (m_referencedPtr) {
70 | m_dereferencedPtr = m_referencedPtr;
71 | m_referencedPtr.reset();
72 | return;
73 | }
74 |
75 | if (m_preventDeletion > 0)
76 | return;
77 |
78 | delete this;
79 | }
80 |
81 | } // namespace Managed
82 |
--------------------------------------------------------------------------------
/androidjni/NativeObject.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include "AnyObject.h"
29 |
30 | namespace JNI {
31 |
32 | class JNI_EXPORT NativeObject : public AnyObject {
33 | public:
34 | NativeObject()
35 | : m_refCount(1)
36 | , m_bind(JNI::refWeakGlobal(JNI::popLocalCallerObjectRef()))
37 | {
38 | }
39 | virtual ~NativeObject() { JNI::derefWeakGlobal(m_bind); }
40 |
41 | void ref() override { ++m_refCount; }
42 | void deref() override { --m_refCount; deleteIfPossible(); }
43 |
44 | ref_t refLocal() override { return JNI::refLocal(m_bind); }
45 | ref_t refGlobal() override { return JNI::refGlobal(m_bind); }
46 |
47 | protected:
48 | NativeObject(const NativeObject&) = delete;
49 | NativeObject& operator=(const NativeObject&) = delete;
50 |
51 | void deleteIfPossible() { if (m_refCount > 0) return; delete this; }
52 |
53 | std::atomic m_refCount;
54 | weak_t m_bind;
55 | }; // class NativeObject
56 |
57 | template inline T* getPtr(ref_t, NativeObject* ptr)
58 | {
59 | return static_cast(ptr);
60 | }
61 |
62 | template<> inline AnyObject* getPtr(ref_t, NativeObject* ptr)
63 | {
64 | return reinterpret_cast(ptr);
65 | }
66 |
67 | template inline T* adoptPtr(ref_t ref, NativeObject* ptr)
68 | {
69 | return getPtr(ref, ptr);
70 | }
71 |
72 | } // namespace JNI
73 |
--------------------------------------------------------------------------------
/generator/interfaces/Long.in:
--------------------------------------------------------------------------------
1 |
2 | package java.lang;
3 |
4 | @NativeNamespace("java.lang")
5 | @NativeExportMacro("JNI_EXPORT")
6 | public final class Long {
7 |
8 | @AccessedByNative
9 | public static final long MAX_VALUE = 0x7FFFFFFFFFFFFFFFL;
10 | @AccessedByNative
11 | public static final long MIN_VALUE = 0x8000000000000000L;
12 | @AccessedByNative
13 | public static final int SIZE = 64;
14 |
15 | @AccessedByNative
16 | private long value;
17 |
18 | @CalledByNative
19 | public Long(long value) {}
20 | public Long(String string) {}
21 |
22 | @Override
23 | @CalledByNative
24 | public byte byteValue();
25 |
26 | public int compareTo(Long object);
27 | public static int compare(long lhs, long rhs);
28 |
29 | private static NumberFormatException invalidLong(String s);
30 |
31 | public static Long decode(String string);
32 |
33 | @Override
34 | @CalledByNative
35 | public double doubleValue();
36 |
37 | @Override
38 | public boolean equals(Object o);
39 |
40 | @Override
41 | @CalledByNative
42 | public float floatValue();
43 |
44 | public static Long getLong(String string);
45 | public static Long getLong(String string, long defaultValue);
46 | public static Long getLong(String string, Long defaultValue);
47 |
48 | @Override
49 | public int hashCode();
50 |
51 | @Override
52 | @CalledByNative
53 | public int intValue();
54 |
55 | @Override
56 | @CalledByNative
57 | public long longValue();
58 |
59 | public static long parseLong(String string);
60 | public static long parseLong(String string, int radix);
61 | private static long parse(String string, int offset, int radix, boolean negative);
62 |
63 | @Override
64 | @CalledByNative
65 | public short shortValue();
66 |
67 | public static String toBinaryString(long v);
68 | public static String toHexString(long v);
69 | public static String toOctalString(long v);
70 |
71 | @Override
72 | public String toString();
73 |
74 | public static String toString(long n);
75 | public static String toString(long v, int radix);
76 |
77 | public static Long valueOf(String string);
78 | public static Long valueOf(String string, int radix);
79 |
80 | public static long highestOneBit(long v);
81 | public static long lowestOneBit(long v);
82 |
83 | public static int numberOfLeadingZeros(long v);
84 | public static int numberOfTrailingZeros(long v);
85 |
86 | public static int bitCount(long v);
87 |
88 | public static long rotateLeft(long v, int distance);
89 | public static long rotateRight(long v, int distance);
90 | public static long reverseBytes(long v);
91 | public static long reverse(long v);
92 | public static int signum(long v);
93 |
94 | public static Long valueOf(long v);
95 | }
96 |
--------------------------------------------------------------------------------
/android/String.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include
27 |
28 | namespace java {
29 | namespace lang {
30 | namespace Managed {
31 |
32 | class StringPrivate : public String::Private {
33 | public:
34 | std::string m_data;
35 | };
36 |
37 | static StringPrivate& string(String::Private& d)
38 | {
39 | return static_cast(d);
40 | }
41 |
42 | class String::NativeBindings {
43 | public:
44 | static void setData(String& s, const char* chars)
45 | {
46 | string(*s.m_private).m_data = std::string(chars);
47 | }
48 | };
49 |
50 | void String::INIT()
51 | {
52 | m_private = std::make_unique();
53 | string(*m_private).m_data = std::string("");
54 | }
55 |
56 | void String::INIT(const std::vector& data)
57 | {
58 | m_private = std::make_unique();
59 | string(*m_private).m_data = std::string(reinterpret_cast(data.data()), data.size());
60 | }
61 |
62 | std::shared_ptr String::create(const char* chars)
63 | {
64 | std::shared_ptr string = String::create();
65 | String::NativeBindings::setData(*string, chars);
66 | return string;
67 | }
68 |
69 | std::vector String::getBytes()
70 | {
71 | return std::vector(string(*m_private).m_data.data(), string(*m_private).m_data.data() + string(*m_private).m_data.length());
72 | }
73 |
74 | } // namespace Managed
75 | } // namespace lang
76 | } // namespace java
77 |
--------------------------------------------------------------------------------
/generator/scripts/lextab.py:
--------------------------------------------------------------------------------
1 | # lextab.py. This file automatically created by PLY (version 3.4). Don't edit!
2 | _tabversion = '3.4'
3 | _lextokens = {'DO': 1, 'REMAINDER_ASSIGN': 1, 'RSHIFT': 1, 'SYNCHRONIZED': 1, 'GTEQ': 1, 'MINUS_ASSIGN': 1, 'OR_ASSIGN': 1, 'VOID': 1, 'STRING_LITERAL': 1, 'ABSTRACT': 1, 'CHAR': 1, 'LSHIFT_ASSIGN': 1, 'WHILE': 1, 'SHORT': 1, 'STATIC': 1, 'PRIVATE': 1, 'LSHIFT': 1, 'CONTINUE': 1, 'THROWS': 1, 'NULL': 1, 'TRUE': 1, 'BYTE': 1, 'NEQ': 1, 'CASE': 1, 'TIMES_ASSIGN': 1, 'THROW': 1, 'NEW': 1, 'SWITCH': 1, 'LONG': 1, 'FINAL': 1, 'PROTECTED': 1, 'STRICTFP': 1, 'IF': 1, 'NUM': 1, 'CATCH': 1, 'ELLIPSIS': 1, 'NATIVE': 1, 'CLASS': 1, 'BLOCK_COMMENT': 1, 'IMPLEMENTS': 1, 'TRANSIENT': 1, 'LINE_COMMENT': 1, 'FOR': 1, 'PACKAGE': 1, 'PLUSPLUS': 1, 'AND_ASSIGN': 1, 'RRSHIFT_ASSIGN': 1, 'ENUM': 1, 'ELSE': 1, 'TRY': 1, 'FINALLY': 1, 'DIVIDE_ASSIGN': 1, 'PUBLIC': 1, 'MINUSMINUS': 1, 'EQ': 1, 'RRSHIFT': 1, 'AND': 1, 'ASSERT': 1, 'RETURN': 1, 'FALSE': 1, 'NAME': 1, 'XOR_ASSIGN': 1, 'THIS': 1, 'DOUBLE': 1, 'LTEQ': 1, 'RSHIFT_ASSIGN': 1, 'CHAR_LITERAL': 1, 'DEFAULT': 1, 'FLOAT': 1, 'BREAK': 1, 'INT': 1, 'BOOLEAN': 1, 'VOLATILE': 1, 'IMPORT': 1, 'PLUS_ASSIGN': 1, 'INTERFACE': 1, 'EXTENDS': 1, 'INSTANCEOF': 1, 'SUPER': 1, 'OR': 1}
4 | _lexreflags = 0
5 | _lexliterals = '()+-*/=?:,.^|&~!=[]{};<>@%'
6 | _lexstateinfo = {'INITIAL': 'inclusive'}
7 | _lexstatere = {'INITIAL': [('(?P/\\*(.|\\n)*?\\*/)|(?P[A-Za-z_$][A-Za-z0-9_$]*)|(?P\\n+)|(?P(\\r\\n)+)|(?P\\.?[0-9][0-9eE_lLdDa-fA-F.xXpP]*)|(?P\\"([^\\\\\\n]|(\\\\.))*?\\")|(?P\\\'([^\\\\\\n]|(\\\\.))*?\\\')|(?P\\.\\.\\.)|(?P//.*)|(?P\\+\\+)|(?P\\-\\-)|(?P\\|\\|)|(?P>>>=)|(?P\\^=)|(?P>>=)|(?P<<=)|(?P\\|=)|(?P\\+=)|(?P>>>)|(?P\\*=)|(?P<=)|(?P>>)|(?P&=)|(?P/=)|(?P>=)|(?P-=)|(?P==)|(?P&&)|(?P%=)|(?P!=)|(?P<<)', [None, ('t_BLOCK_COMMENT', 'BLOCK_COMMENT'), None, ('t_NAME', 'NAME'), ('t_newline', 'newline'), ('t_newline2', 'newline2'), None, (None, 'NUM'), (None, 'STRING_LITERAL'), None, None, (None, 'CHAR_LITERAL'), None, None, (None, 'ELLIPSIS'), (None, None), (None, 'PLUSPLUS'), (None, 'MINUSMINUS'), (None, 'OR'), (None, 'RRSHIFT_ASSIGN'), (None, 'XOR_ASSIGN'), (None, 'RSHIFT_ASSIGN'), (None, 'LSHIFT_ASSIGN'), (None, 'OR_ASSIGN'), (None, 'PLUS_ASSIGN'), (None, 'RRSHIFT'), (None, 'TIMES_ASSIGN'), (None, 'LTEQ'), (None, 'RSHIFT'), (None, 'AND_ASSIGN'), (None, 'DIVIDE_ASSIGN'), (None, 'GTEQ'), (None, 'MINUS_ASSIGN'), (None, 'EQ'), (None, 'AND'), (None, 'REMAINDER_ASSIGN'), (None, 'NEQ'), (None, 'LSHIFT')])]}
8 | _lexstateignore = {'INITIAL': ' \t\x0c'}
9 | _lexstateerrorf = {'INITIAL': 't_error'}
10 |
--------------------------------------------------------------------------------
/android/Point.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include
27 |
28 | namespace android {
29 | namespace graphics {
30 | namespace Managed {
31 |
32 | void Point::INIT()
33 | {
34 | this->x = 0;
35 | this->y = 0;
36 | }
37 |
38 | void Point::INIT(int32_t x
39 | , int32_t y)
40 | {
41 | this->x = x;
42 | this->y = y;
43 | }
44 |
45 | void Point::INIT(std::shared_ptr src)
46 | {
47 | x = src->x;
48 | y = src->y;
49 | }
50 |
51 | void Point::set(int32_t x
52 | , int32_t y)
53 | {
54 | this->x = x;
55 | this->y = y;
56 | }
57 |
58 | void Point::negate()
59 | {
60 | x = -x;
61 | y = -y;
62 | }
63 |
64 | void Point::offset(int32_t dx
65 | , int32_t dy)
66 | {
67 | x += dx;
68 | y += dy;
69 | }
70 |
71 | bool Point::equals(int32_t x
72 | , int32_t y)
73 | {
74 | return this->x == x && this->y == y;
75 | }
76 |
77 | bool Point::equals(std::shared_ptr o)
78 | {
79 | if (this == o.get())
80 | return true;
81 | if (o.get() == nullptr)
82 | return false;
83 |
84 | Point* point = (Point*)o.get();
85 |
86 | if (x != point->x)
87 | return false;
88 | if (y != point->y)
89 | return false;
90 |
91 | return true;
92 | }
93 |
94 | int32_t Point::hashCode()
95 | {
96 | int result = x;
97 | result = 31 * result + y;
98 | return result;
99 | }
100 |
101 | } // namespace Managed
102 | } // namespace graphics
103 | } // namespace android
104 |
--------------------------------------------------------------------------------
/androidjni/platforms/generic/androidjni/MarshalingHelpers.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include "PassArray.h"
29 | #include "ObjectReference.h"
30 | #include
31 |
32 | namespace JNI {
33 |
34 | template
35 | T&& toManaged(T&& value)
36 | {
37 | return std::forward(value);
38 | }
39 |
40 | template
41 | T&& toNative(T&& value)
42 | {
43 | return std::forward(value);
44 | }
45 |
46 | template
47 | std::shared_ptr toManaged(const PassLocalRef& ref)
48 | {
49 | return std::static_pointer_cast(sharePtr(ref.get()));
50 | }
51 |
52 | template
53 | PassLocalRef toNative(std::shared_ptr& ref)
54 | {
55 | return (ref) ? T::fromPtr(ref) : nullptr;
56 | }
57 |
58 | template<> inline std::shared_ptr toManaged(const PassLocalRef& ref)
59 | {
60 | return sharePtr(ref.get());
61 | }
62 |
63 | template<> inline PassLocalRef toNative(std::shared_ptr& ref)
64 | {
65 | return JNI::adoptRef(new ObjectReference(ref), reinterpret_cast(nullptr));
66 | }
67 |
68 | template
69 | inline std::vector toManaged(PassArray value)
70 | {
71 | return std::vector(value.data(), value.data() + value.count());
72 | }
73 |
74 | template
75 | inline PassArray toNative(std::vector& value)
76 | {
77 | return PassArray(value.data(), value.size(), true);
78 | }
79 |
80 | template
81 | inline std::vector> toManaged(PassArray> value)
82 | {
83 | return value.vectorize();
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/androidjni/platforms/generic/androidjni/PassArray.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | #include
31 | #include
32 |
33 | namespace JNI {
34 |
35 | template
36 | class JNI_EXPORT PassArray final {
37 | public:
38 | PassArray(const T* data, size_t count, bool makeCopy = false)
39 | : m_data(data)
40 | , m_count(count)
41 | , m_copy(0)
42 | {
43 | if (makeCopy)
44 | copyData();
45 | }
46 | PassArray(const PassArray& array)
47 | : m_data(array.m_data)
48 | , m_count(array.m_count)
49 | , m_copy(0)
50 | {
51 | std::swap(m_copy, array.m_copy);
52 | }
53 | PassArray(const std::vector& vector)
54 | : m_data(vector.data())
55 | , m_count(vector.size())
56 | , m_copy(0)
57 | {
58 | copyData();
59 | }
60 | ~PassArray()
61 | {
62 | deleteDataIfNeeded();
63 | }
64 |
65 | const T* data() const { return m_data; }
66 | size_t count() const { return m_count; }
67 |
68 | template
69 | std::vector> vectorize()
70 | {
71 | std::vector> v;
72 | for (size_t i = 0; i < m_count; ++i)
73 | v.push_back(toManaged(m_data[i]));
74 | return v;
75 | }
76 |
77 | private:
78 | void copyData()
79 | {
80 | m_copy = new T[m_count];
81 | memcpy(m_copy, m_data, m_count * sizeof(T));
82 | m_data = m_copy;
83 | }
84 | void deleteDataIfNeeded()
85 | {
86 | if (m_copy)
87 | delete [] m_copy;
88 | }
89 |
90 | const T* m_data;
91 | size_t m_count;
92 | mutable T* m_copy;
93 | }; // class PassArray
94 |
95 | } // namespace JNI
96 |
--------------------------------------------------------------------------------
/test/testapp/win32/WinMain.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include
27 | #include
28 |
29 | #include
30 | #include
31 | #include
32 |
33 | #include
34 | #include
35 | #include
36 |
37 | using namespace com::example::test::Managed;
38 |
39 | class HelloJniStringGeneratorClient : public StringGeneratorClient {
40 | void stringFromJNI(const std::string& s) override {
41 | }
42 |
43 | void stringFromJNI(std::shared_ptr v) override {
44 | }
45 |
46 | void stringFromJNI(const std::vector& i) override {
47 | }
48 | };
49 |
50 | int _tmain(int argc, _TCHAR* argv[])
51 | {
52 | std::shared_ptr generator = StringGenerator::create();
53 | std::shared_ptr generatorClient = StringGeneratorClient::create();
54 | StringGenerator::mMutableStatic = 2015;
55 | generator->mMutable = 1234;
56 | generator->setClient("TestActivityClient", generatorClient);
57 | generator->stringFromJNI();
58 | generator->requestStringFromJNI();
59 | std::shared_ptr generatorClientRef = generator->getClient();
60 | std::shared_ptr string = java::lang::String::create("Hello, World!");
61 | std::shared_ptr stringVector = java::util::Vector::create();
62 | std::shared_ptr rect = android::graphics::Rect::create(0, 0, 10, 10);
63 | stringVector->add(string);
64 | generator->setWhat(stringVector);
65 | generator->setWhat(generatorClientRef);
66 | generator.reset();
67 | generatorClientRef.reset();
68 | generatorClient.reset();
69 | return 0;
70 | }
71 |
72 |
--------------------------------------------------------------------------------
/generator/interfaces/Rect.in:
--------------------------------------------------------------------------------
1 |
2 | package android.graphics;
3 |
4 | import android.os.Parcel;
5 |
6 | import java.io.PrintWriter;
7 |
8 | /**
9 | * Rect holds four integer coordinates for a rectangle. The rectangle is
10 | * represented by the coordinates of its 4 edges (left, top, right bottom).
11 | * These fields can be accessed directly. Use width() and height() to retrieve
12 | * the rectangle's width and height. Note: most methods do not check to see that
13 | * the coordinates are sorted correctly (i.e. left <= right and top <= bottom).
14 | */
15 | @NativeNamespace("android.graphics")
16 | @NativeExportMacro("JNI_EXPORT")
17 | public final class Rect {
18 | @AccessedByNative
19 | public int left;
20 | @AccessedByNative
21 | public int top;
22 | @AccessedByNative
23 | public int right;
24 | @AccessedByNative
25 | public int bottom;
26 |
27 | @CalledByNative
28 | public Rect() {}
29 | @CalledByNative
30 | public Rect(int left, int top, int right, int bottom) {}
31 | @CalledByNative
32 | public Rect(Rect r) {}
33 |
34 | @CalledByNative
35 | public boolean equals(Object o);
36 | @CalledByNative
37 | public int hashCode();
38 |
39 | public String toString();
40 | public String toShortString();
41 | public String toShortString(StringBuilder sb);
42 | public String flattenToString();
43 | public static Rect unflattenFromString(String str);
44 | public void printShortString(PrintWriter pw);
45 |
46 | @CalledByNative
47 | public final boolean isEmpty();
48 |
49 | @CalledByNative
50 | public final int width();
51 | @CalledByNative
52 | public final int height();
53 |
54 | @CalledByNative
55 | public final int centerX();
56 | @CalledByNative
57 | public final int centerY();
58 | @CalledByNative
59 | public final float exactCenterX();
60 | @CalledByNative
61 | public final float exactCenterY();
62 |
63 | @CalledByNative
64 | public void setEmpty();
65 | @CalledByNative
66 | public void set(int left, int top, int right, int bottom);
67 | @CalledByNative
68 | public void set(Rect src);
69 |
70 | @CalledByNative
71 | public void offset(int dx, int dy);
72 | @CalledByNative
73 | public void offsetTo(int newLeft, int newTop);
74 | @CalledByNative
75 | public void inset(int dx, int dy);
76 |
77 | @CalledByNative
78 | public boolean contains(int x, int y);
79 | @CalledByNative
80 | public boolean contains(int left, int top, int right, int bottom);
81 | @CalledByNative
82 | public boolean contains(Rect r);
83 |
84 | @CalledByNative
85 | public boolean intersect(int left, int top, int right, int bottom);
86 | @CalledByNative
87 | public boolean intersect(Rect r);
88 | @CalledByNative
89 | public boolean setIntersect(Rect a, Rect b);
90 | @CalledByNative
91 | public boolean intersects(int left, int top, int right, int bottom);
92 | @CalledByNative
93 | public static boolean intersects(Rect a, Rect b);
94 |
95 | public void union(int left, int top, int right, int bottom);
96 | public void union(Rect r);
97 | public void union(int x, int y);
98 |
99 | @CalledByNative
100 | public void sort();
101 |
102 | public int describeContents();
103 | public void writeToParcel(Parcel out, int flags);
104 | public void readFromParcel(Parcel in);
105 |
106 | @CalledByNative
107 | public void scale(float scale);
108 | }
109 |
--------------------------------------------------------------------------------
/androidjni/platforms/android/ReferenceFunctions.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include "androidjni/ReferenceFunctions.h"
27 |
28 | #include "JavaVM.h"
29 |
30 | namespace JNI {
31 |
32 | ref_t refLocal(ref_t ref)
33 | {
34 | if (!ref)
35 | return 0;
36 |
37 | return CALL_JNI(NewLocalRef, ref);
38 | }
39 |
40 | void derefLocal(ref_t ref)
41 | {
42 | if (!ref)
43 | return;
44 |
45 | CALL_JNI(DeleteLocalRef, ref);
46 | }
47 |
48 | ref_t refGlobal(ref_t ref)
49 | {
50 | if (!ref)
51 | return 0;
52 |
53 | return CALL_JNI(NewGlobalRef, ref);
54 | }
55 |
56 | void derefGlobal(ref_t ref)
57 | {
58 | if (!ref)
59 | return;
60 |
61 | CALL_JNI(DeleteGlobalRef, ref);
62 | }
63 |
64 | bool isExpiredWeakGlobal(weak_t ref)
65 | {
66 | if (CALL_JNI(IsSameObject, ref, NULL))
67 | return true;
68 |
69 | return false;
70 | }
71 |
72 | weak_t refWeakGlobal(ref_t ref)
73 | {
74 | if (!ref)
75 | return 0;
76 |
77 | jweak weak = CALL_JNI(NewWeakGlobalRef, ref);
78 | return reinterpret_cast(weak);
79 | }
80 |
81 | void derefWeakGlobal(weak_t ref)
82 | {
83 | if (!ref)
84 | return;
85 |
86 | CALL_JNI(DeleteWeakGlobalRef, ref);
87 | }
88 |
89 | struct LocalCallerObject {
90 | ref_t oref;
91 | LocalCallerObject* next;
92 | };
93 |
94 | static thread_local LocalCallerObject localCallerObjects;
95 |
96 | ref_t popLocalCallerObjectRef()
97 | {
98 | ref_t ref = 0;
99 | std::swap(ref, localCallerObjects.oref);
100 |
101 | if (!localCallerObjects.next)
102 | return ref;
103 |
104 | std::unique_ptr next(localCallerObjects.next);
105 | localCallerObjects.oref = next->oref;
106 | localCallerObjects.next = next->next;
107 | return ref;
108 | }
109 |
110 | void pushLocalCallerObjectRef(ref_t ref)
111 | {
112 | if (!localCallerObjects.oref) {
113 | localCallerObjects.oref = ref;
114 | return;
115 | }
116 |
117 | LocalCallerObject* next = new LocalCallerObject;
118 | next->oref = localCallerObjects.oref;
119 | next->next = localCallerObjects.next;
120 | localCallerObjects.oref = ref;
121 | localCallerObjects.next = next;
122 | }
123 |
124 | } // namespace JNI
125 |
--------------------------------------------------------------------------------
/android/HashMap.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include
27 |
28 | namespace java {
29 | namespace util {
30 | namespace Managed {
31 |
32 | class HashMapPrivate : public HashMap::Private {
33 | public:
34 | std::map, std::shared_ptr> m_map;
35 | };
36 |
37 | static HashMapPrivate& map(HashMap::Private& d)
38 | {
39 | return static_cast(d);
40 | }
41 |
42 | class HashMap::NativeBindings {
43 | public:
44 | static std::map, std::shared_ptr>& data(HashMap& m)
45 | {
46 | return map(*m.m_private).m_map;
47 | }
48 | };
49 |
50 | void HashMap::INIT()
51 | {
52 | m_private = std::make_unique();
53 | }
54 |
55 | void HashMap::INIT(int32_t capacity)
56 | {
57 | m_private = std::make_unique();
58 | }
59 |
60 | void HashMap::INIT(int32_t capacity, float loadFactor)
61 | {
62 | m_private = std::make_unique();
63 | }
64 |
65 |
66 | void HashMap::clear()
67 | {
68 | map(*m_private).m_map.clear();
69 | }
70 |
71 | std::shared_ptr HashMap::clone()
72 | {
73 | return nullptr;
74 | }
75 |
76 | bool HashMap::containsKey(std::shared_ptr key)
77 | {
78 | return false;
79 | }
80 |
81 | bool HashMap::containsValue(std::shared_ptr value)
82 | {
83 | return false;
84 | }
85 |
86 | std::shared_ptr HashMap::get(std::shared_ptr key)
87 | {
88 | return map(*m_private).m_map[key];
89 | }
90 |
91 | bool HashMap::isEmpty()
92 | {
93 | return map(*m_private).m_map.empty();
94 | }
95 |
96 | std::shared_ptr HashMap::put(std::shared_ptr key, std::shared_ptr value)
97 | {
98 | map(*m_private).m_map.insert(std::pair, std::shared_ptr>(key, value));
99 | return nullptr;
100 | }
101 |
102 | std::shared_ptr HashMap::remove(std::shared_ptr key)
103 | {
104 | map(*m_private).m_map.erase(key);
105 | return nullptr;
106 | }
107 |
108 | int32_t HashMap::size()
109 | {
110 | return map(*m_private).m_map.size();
111 | }
112 |
113 | const HashMap::Data& HashMap::data()
114 | {
115 | return java::util::Managed::HashMap::NativeBindings::data(*this);
116 | }
117 |
118 | } // namespace Managed
119 | } // namespace util
120 | } // namespace java
121 |
--------------------------------------------------------------------------------
/androidjni/platforms/generic/ObjectReference.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | namespace JNI {
31 |
32 | template
33 | class PassLocalRef;
34 |
35 | class JNI_EXPORT ObjectReference {
36 | public:
37 | template ObjectReference(const std::shared_ptr& ptr)
38 | : m_localRefCount(1)
39 | , m_globalRefCount(0)
40 | , m_preventDeletion(0)
41 | , m_referencedPtr(std::static_pointer_cast(ptr))
42 | , m_immutableReferencedPtrValue(m_referencedPtr.get())
43 | { }
44 | template ObjectReference(std::shared_ptr&& ptr)
45 | : m_localRefCount(1)
46 | , m_globalRefCount(0)
47 | , m_preventDeletion(0)
48 | , m_referencedPtr(std::static_pointer_cast(ptr))
49 | , m_immutableReferencedPtrValue(m_referencedPtr.get())
50 | {
51 | ptr.reset();
52 | }
53 | virtual ~ObjectReference() = default;
54 |
55 | ref_t refLocal();
56 | void derefLocal(ref_t);
57 |
58 | ref_t refGlobal();
59 | void derefGlobal(ref_t);
60 |
61 | void* ptr() const { return m_immutableReferencedPtrValue; }
62 | void* safePtr() const { return m_referencedPtr.get(); }
63 | std::shared_ptr sharePtr() const { return m_referencedPtr; }
64 |
65 | bool isExpired() const { return m_localRefCount.load() == 0 && m_globalRefCount.load() == 0 && m_dereferencedPtr.expired(); }
66 | void preventDeletion(bool f) { (f) ? ++m_preventDeletion : --m_preventDeletion; }
67 | void deleteIfPossible();
68 |
69 | private:
70 | ObjectReference(const ObjectReference&) = delete;
71 | ObjectReference& operator=(const ObjectReference&) = delete;
72 |
73 | std::atomic m_localRefCount;
74 | std::atomic m_globalRefCount;
75 | std::shared_ptr m_referencedPtr;
76 | std::weak_ptr m_dereferencedPtr;
77 | void* const m_immutableReferencedPtrValue;
78 | std::atomic m_preventDeletion;
79 | }; // class ObjectReference
80 |
81 | template inline T* getPtr(ref_t ref)
82 | {
83 | return (ref) ? static_cast(reinterpret_cast(ref)->ptr()) : nullptr;
84 | }
85 |
86 | inline std::shared_ptr sharePtr(ref_t ref)
87 | {
88 | return (ref) ? reinterpret_cast(ref)->sharePtr() : nullptr;
89 | }
90 |
91 | } // namespace JNI
92 |
--------------------------------------------------------------------------------
/generator/interfaces/Vector.in:
--------------------------------------------------------------------------------
1 |
2 | package java.util;
3 |
4 | @NativeNamespace("java.util")
5 | @NativeExportMacro("JNI_EXPORT")
6 | public class Vector {
7 |
8 | @CalledByNative
9 | @SupplementForManaged("using Data = std::vector>;")
10 | public Vector() {}
11 | @CalledByNative
12 | public Vector(int capacity) {}
13 | @CalledByNative
14 | public Vector(int capacity, int capacityIncrement) {}
15 | public Vector(Collection extends E> collection) {}
16 |
17 | @CalledByNative
18 | public void add(int location, E object);
19 | @CalledByNative
20 | public synchronized boolean add(E object);
21 | public synchronized boolean addAll(int location, Collection extends E> collection);
22 | public synchronized boolean addAll(Collection extends E> collection);
23 | @CalledByNative
24 | public synchronized void addElement(E object);
25 |
26 | @CalledByNative
27 | public synchronized int capacity();
28 |
29 | @CalledByNative
30 | public void clear();
31 |
32 | @CalledByNative
33 | public synchronized Object clone();
34 |
35 | @CalledByNative
36 | public boolean contains(Object object);
37 | public synchronized boolean containsAll(Collection> collection);
38 |
39 | public synchronized void copyInto(Object[] elements);
40 |
41 | @CalledByNative
42 | public synchronized E elementAt(int location);
43 | public Enumeration elements();
44 |
45 | @CalledByNative
46 | public synchronized void ensureCapacity(int minimumCapacity);
47 |
48 | @CalledByNative
49 | public synchronized boolean equals(Object object);
50 |
51 | @CalledByNative
52 | public synchronized E firstElement();
53 | @CalledByNative
54 | public E get(int location);
55 | @CalledByNative
56 | public synchronized int hashCode();
57 |
58 | @CalledByNative
59 | public int indexOf(Object object);
60 | @CalledByNative
61 | public synchronized int indexOf(Object object, int location);
62 | @CalledByNative
63 | public synchronized void insertElementAt(E object, int location);
64 |
65 | @CalledByNative
66 | public synchronized boolean isEmpty();
67 |
68 | @CalledByNative
69 | public synchronized E lastElement();
70 | @CalledByNative
71 | public synchronized int lastIndexOf(Object object);
72 | @CalledByNative
73 | public synchronized int lastIndexOf(Object object, int location);
74 |
75 | @CalledByNative
76 | public synchronized E remove(int location);
77 |
78 | @CalledByNative
79 | public boolean remove(Object object);
80 | public synchronized boolean removeAll(Collection> collection);
81 | @CalledByNative
82 | public synchronized void removeAllElements();
83 | @CalledByNative
84 | public synchronized boolean removeElement(Object object);
85 | @CalledByNative
86 | public synchronized void removeElementAt(int location);
87 |
88 | public synchronized boolean retainAll(Collection> collection);
89 |
90 | @CalledByNative
91 | public synchronized E set(int location, E object);
92 | @CalledByNative
93 | public synchronized void setElementAt(E object, int location);
94 |
95 | @CalledByNative
96 | public synchronized void setSize(int length);
97 |
98 | @CalledByNative
99 | public synchronized int size();
100 |
101 | public synchronized List subList(int start, int end);
102 | @SupplementForManaged("CLASS_EXPORT const Data& data();")
103 | public synchronized Object[] toArray();
104 | public synchronized T[] toArray(T[] contents);
105 | public synchronized String toString();
106 |
107 | @CalledByNative
108 | public synchronized void trimToSize();
109 | }
110 |
--------------------------------------------------------------------------------
/generator/scripts/plyj/ply/ctokens.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------
2 | # ctokens.py
3 | #
4 | # Token specifications for symbols in ANSI C and C++. This file is
5 | # meant to be used as a library in other tokenizers.
6 | # ----------------------------------------------------------------------
7 |
8 | # Reserved words
9 |
10 | tokens = [
11 | # Literals (identifier, integer constant, float constant, string constant, char const)
12 | 'ID', 'TYPEID', 'ICONST', 'FCONST', 'SCONST', 'CCONST',
13 |
14 | # Operators (+,-,*,/,%,|,&,~,^,<<,>>, ||, &&, !, <, <=, >, >=, ==, !=)
15 | 'PLUS', 'MINUS', 'TIMES', 'DIVIDE', 'MOD',
16 | 'OR', 'AND', 'NOT', 'XOR', 'LSHIFT', 'RSHIFT',
17 | 'LOR', 'LAND', 'LNOT',
18 | 'LT', 'LE', 'GT', 'GE', 'EQ', 'NE',
19 |
20 | # Assignment (=, *=, /=, %=, +=, -=, <<=, >>=, &=, ^=, |=)
21 | 'EQUALS', 'TIMESEQUAL', 'DIVEQUAL', 'MODEQUAL', 'PLUSEQUAL', 'MINUSEQUAL',
22 | 'LSHIFTEQUAL','RSHIFTEQUAL', 'ANDEQUAL', 'XOREQUAL', 'OREQUAL',
23 |
24 | # Increment/decrement (++,--)
25 | 'PLUSPLUS', 'MINUSMINUS',
26 |
27 | # Structure dereference (->)
28 | 'ARROW',
29 |
30 | # Ternary operator (?)
31 | 'TERNARY',
32 |
33 | # Delimeters ( ) [ ] { } , . ; :
34 | 'LPAREN', 'RPAREN',
35 | 'LBRACKET', 'RBRACKET',
36 | 'LBRACE', 'RBRACE',
37 | 'COMMA', 'PERIOD', 'SEMI', 'COLON',
38 |
39 | # Ellipsis (...)
40 | 'ELLIPSIS',
41 | ]
42 |
43 | # Operators
44 | t_PLUS = r'\+'
45 | t_MINUS = r'-'
46 | t_TIMES = r'\*'
47 | t_DIVIDE = r'/'
48 | t_MODULO = r'%'
49 | t_OR = r'\|'
50 | t_AND = r'&'
51 | t_NOT = r'~'
52 | t_XOR = r'\^'
53 | t_LSHIFT = r'<<'
54 | t_RSHIFT = r'>>'
55 | t_LOR = r'\|\|'
56 | t_LAND = r'&&'
57 | t_LNOT = r'!'
58 | t_LT = r'<'
59 | t_GT = r'>'
60 | t_LE = r'<='
61 | t_GE = r'>='
62 | t_EQ = r'=='
63 | t_NE = r'!='
64 |
65 | # Assignment operators
66 |
67 | t_EQUALS = r'='
68 | t_TIMESEQUAL = r'\*='
69 | t_DIVEQUAL = r'/='
70 | t_MODEQUAL = r'%='
71 | t_PLUSEQUAL = r'\+='
72 | t_MINUSEQUAL = r'-='
73 | t_LSHIFTEQUAL = r'<<='
74 | t_RSHIFTEQUAL = r'>>='
75 | t_ANDEQUAL = r'&='
76 | t_OREQUAL = r'\|='
77 | t_XOREQUAL = r'^='
78 |
79 | # Increment/decrement
80 | t_INCREMENT = r'\+\+'
81 | t_DECREMENT = r'--'
82 |
83 | # ->
84 | t_ARROW = r'->'
85 |
86 | # ?
87 | t_TERNARY = r'\?'
88 |
89 | # Delimeters
90 | t_LPAREN = r'\('
91 | t_RPAREN = r'\)'
92 | t_LBRACKET = r'\['
93 | t_RBRACKET = r'\]'
94 | t_LBRACE = r'\{'
95 | t_RBRACE = r'\}'
96 | t_COMMA = r','
97 | t_PERIOD = r'\.'
98 | t_SEMI = r';'
99 | t_COLON = r':'
100 | t_ELLIPSIS = r'\.\.\.'
101 |
102 | # Identifiers
103 | t_ID = r'[A-Za-z_][A-Za-z0-9_]*'
104 |
105 | # Integer literal
106 | t_INTEGER = r'\d+([uU]|[lL]|[uU][lL]|[lL][uU])?'
107 |
108 | # Floating literal
109 | t_FLOAT = r'((\d+)(\.\d+)(e(\+|-)?(\d+))? | (\d+)e(\+|-)?(\d+))([lL]|[fF])?'
110 |
111 | # String literal
112 | t_STRING = r'\"([^\\\n]|(\\.))*?\"'
113 |
114 | # Character constant 'c' or L'c'
115 | t_CHARACTER = r'(L)?\'([^\\\n]|(\\.))*?\''
116 |
117 | # Comment (C-Style)
118 | def t_COMMENT(t):
119 | r'/\*(.|\n)*?\*/'
120 | t.lexer.lineno += t.value.count('\n')
121 | return t
122 |
123 | # Comment (C++-Style)
124 | def t_CPPCOMMENT(t):
125 | r'//.*\n'
126 | t.lexer.lineno += 1
127 | return t
128 |
129 |
130 |
131 |
132 |
133 |
134 |
--------------------------------------------------------------------------------
/test/testapp/android/src/com/example/test/TestActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | package com.example.test;
27 |
28 | import labs.naver.androidjni.CalledByNative;
29 | import android.app.Activity;
30 | import android.util.Log;
31 | import android.view.MotionEvent;
32 | import android.widget.TextView;
33 | import android.os.Bundle;
34 |
35 |
36 | public class TestActivity extends Activity
37 | {
38 | private static final long INTERVAL_IN_MS = 3000;
39 |
40 | private StringGenerator mGenerator = new StringGenerator();
41 | private boolean mRequestedExit = false;
42 |
43 | /** Called when the activity is first created. */
44 | @Override
45 | public void onCreate(Bundle savedInstanceState)
46 | {
47 | super.onCreate(savedInstanceState);
48 |
49 | /* Create a TextView and set its content.
50 | * the text is retrieved by calling a native
51 | * function.
52 | */
53 | final TextView tv = new TextView(this);
54 | StringGeneratorClient client = new StringGeneratorClient() {
55 | @CalledByNative
56 | void stringFromJNI(String s) {
57 | super.stringFromJNI(s);
58 | tv.setText(s);
59 | }
60 | };
61 | mGenerator.setClient("TestActivityClient", client);
62 | tv.setText( mGenerator.stringFromJNI() );
63 |
64 | mGenerator.setWhat(new StringGeneratorClient() {
65 | protected void finalize() {
66 | Log.d("WeakObject", "Weak reference does not help me to live at all!");
67 | }
68 |
69 | @CalledByNative
70 | void stringFromJNI(String s) {
71 | Log.d("WeakObject", "Hey, I'm still alive! Here's the string: " + s);
72 | }
73 | });
74 |
75 | setContentView(tv);
76 | tv.postDelayed(new Runnable() {
77 | @Override
78 | public void run() {
79 | if (mRequestedExit)
80 | return;
81 |
82 | mGenerator.generateNumberForJNI();
83 | mGenerator.requestStringFromJNI();
84 | tv.postDelayed(this, INTERVAL_IN_MS);
85 | }}, INTERVAL_IN_MS);
86 | }
87 |
88 | @Override
89 | public boolean onTouchEvent(MotionEvent event) {
90 | Log.d("TestActivity", "TestActivity will exit...");
91 | mRequestedExit = true;
92 | mGenerator = null;
93 | return super.onTouchEvent(event);
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/androidjni/platforms/android/androidjni/PassArray.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #pragma once
27 |
28 | #include "ArrayFunctions.h"
29 |
30 | #include
31 |
32 | namespace JNI {
33 |
34 | template
35 | class JNI_EXPORT PassArray final {
36 | public:
37 | PassArray(const T* data, size_t count, bool copyData = false)
38 | : m_data(data)
39 | , m_count(count)
40 | , m_ref(ArrayFunctions::newArrayObject(m_data, m_count))
41 | , m_elements(0)
42 | {
43 | }
44 | PassArray(const PassArray& array)
45 | : m_data(0)
46 | , m_count(getArrayObjectElementsCount(array.m_ref))
47 | , m_ref(JNI::refLocal(array.m_ref))
48 | , m_elements(0)
49 | {
50 | }
51 | PassArray(ref_t array)
52 | : m_data(0)
53 | , m_count(getArrayObjectElementsCount(array))
54 | , m_ref(JNI::refLocal(array))
55 | , m_elements(0)
56 | {
57 | }
58 | template PassArray(const std::array& array)
59 | : m_data(array.data())
60 | , m_count(array.size())
61 | , m_ref(ArrayFunctions::newArrayObject(m_data, m_count))
62 | , m_elements(0)
63 | {
64 | }
65 | PassArray(const std::string& string)
66 | : m_data(reinterpret_cast(string.data()))
67 | , m_count(string.size())
68 | , m_ref(ArrayFunctions::newArrayObject(m_data, m_count))
69 | , m_elements(0)
70 | {
71 | }
72 | PassArray(const std::vector& vector)
73 | : m_data(vector.data())
74 | , m_count(vector.size())
75 | , m_ref(ArrayFunctions::newArrayObject(m_data, m_count))
76 | , m_elements(0)
77 | {
78 | }
79 | ~PassArray()
80 | {
81 | ArrayFunctions::releaseArrayObjectElements(m_ref, m_elements, m_count);
82 | deleteArrayObject(m_ref);
83 | }
84 |
85 | const T* data() const { return (m_data) ? m_data : (m_data = m_elements = ArrayFunctions::getArrayObjectElements(m_ref)); }
86 | size_t count() const { return m_count; }
87 |
88 | ref_t leak() const
89 | {
90 | ref_t oref = 0;
91 | std::swap(oref, m_ref);
92 | return oref;
93 | }
94 |
95 | private:
96 | mutable const T* m_data;
97 | size_t m_count;
98 | mutable ref_t m_ref;
99 | mutable T* m_elements;
100 | }; // class PassArray
101 |
102 | } // namespace JNI
103 |
--------------------------------------------------------------------------------
/cmake/HelperMacros.cmake:
--------------------------------------------------------------------------------
1 | macro(WRAP_SOURCELIST)
2 | foreach (_file ${ARGN})
3 | get_filename_component(_basename ${_file} NAME_WE)
4 | get_filename_component(_path ${_file} PATH)
5 |
6 | if (NOT _file MATCHES "${CMAKE_CURRENT_BINARY_DIR}/GeneratedFiles")
7 | string(REGEX REPLACE "/" "\\\\\\\\" _sourcegroup "${_path}")
8 | source_group("${_sourcegroup}" FILES ${_file})
9 | endif ()
10 | endforeach ()
11 |
12 | source_group("GeneratedFiles" REGULAR_EXPRESSION "${CMAKE_CURRENT_BINARY_DIR}/GeneratedFiles")
13 | endmacro()
14 |
15 | macro(ADD_PREFIX_HEADER _target _header)
16 | get_target_property(_old_compile_flags ${_target} COMPILE_FLAGS)
17 | if (${_old_compile_flags} STREQUAL "_old_compile_flags-NOTFOUND")
18 | set(_old_compile_flags "")
19 | endif ()
20 | if (MSVC)
21 | set_target_properties(${_target} PROPERTIES COMPILE_FLAGS "/FI\"${_header}\" ${_old_compile_flags}")
22 | else ()
23 | set_target_properties(${_target} PROPERTIES COMPILE_FLAGS "-include ${_header} ${_old_compile_flags}")
24 | endif ()
25 | endmacro()
26 |
27 | macro(ADD_POST_BUILD_COMMAND _target)
28 | if (CMAKE_HOST_WIN32)
29 | set(${_target}_POST_BUILD_COMMAND "${CMAKE_BINARY_DIR}/${_target}/postBuild.cmd")
30 | file(WRITE "${${_target}_POST_BUILD_COMMAND}" "@echo Running ${_target} post build tasks...\n")
31 | add_custom_command(TARGET ${_target} POST_BUILD COMMAND ${${_target}_POST_BUILD_COMMAND} VERBATIM)
32 | else ()
33 | add_custom_command(TARGET ${_target} POST_BUILD COMMAND echo Running ${_target} post build tasks... VERBATIM)
34 | endif ()
35 | endmacro()
36 |
37 | macro(COPY_LIBRARY_HEADERS _target _list _destination)
38 | if (CMAKE_HOST_WIN32)
39 | file(APPEND "${${_target}_POST_BUILD_COMMAND}" "@mkdir \"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/../${_destination}\" >nul 2>nul\n")
40 | foreach (_file ${_list})
41 | get_filename_component(_absolute "${_file}" ABSOLUTE)
42 | file(APPEND "${${_target}_POST_BUILD_COMMAND}" "@xcopy /y /d /f \"${_absolute}\" \"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/../${_destination}\" >nul 2>nul\n")
43 | endforeach ()
44 | else ()
45 | add_custom_command(TARGET ${_target} POST_BUILD COMMAND echo Copying ${_target} library headers... VERBATIM)
46 | foreach (_file ${_list})
47 | get_filename_component(_absolute "${_file}" ABSOLUTE)
48 | add_custom_command(TARGET ${_target} POST_BUILD COMMAND mkdir -p ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/../${_destination} && cp -u ${_absolute} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/../${_destination} VERBATIM)
49 | endforeach ()
50 | endif ()
51 | endmacro()
52 |
53 | macro(COPY_LIBRARY_HEADERS_DIRECTORY _target _source _destination)
54 | get_filename_component(_absolute "${_source}" ABSOLUTE)
55 | if (CMAKE_HOST_WIN32)
56 | file(APPEND "${${_target}_POST_BUILD_COMMAND}" "@robocopy /s /e \"${_absolute}/\" \"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/../${_destination}/\" \"*.h\" \"*.hpp\" >nul 2>nul\n")
57 | file(APPEND "${${_target}_POST_BUILD_COMMAND}" "IF %ERRORLEVEL% LEQ 3 set ERRORLEVEL=0\n")
58 | else ()
59 | add_custom_command(TARGET ${_target} POST_BUILD COMMAND echo Copying ${_target} library headers... VERBATIM)
60 | add_custom_command(TARGET ${_target} POST_BUILD COMMAND mkdir -p ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/../${_destination} && rsync -rpuL --include='*.h' --include='*.hpp' --exclude='*.*' ${_absolute}/* ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/../${_destination})
61 | endif ()
62 | endmacro()
63 |
64 | macro(IMPORT_LIBRARIES _target _list)
65 | get_target_property(_target_dir ${_target} SOURCE_DIR)
66 | string(REPLACE "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" _target_dir ${_target_dir})
67 | set(_target_object_dir ${_target_dir}/${_target}.dir/$)
68 | foreach (_library ${_list})
69 | set(_library_name ${CMAKE_SHARED_LIBRARY_PREFIX}${_library}${CMAKE_SHARED_LIBRARY_SUFFIX})
70 | set(_library_path ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${_library_name})
71 | add_custom_command(TARGET ${_target} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${_library_path} ${_target_object_dir}/libs/${ANDROID_NDK_ABI_NAME}/${_library_name})
72 | endforeach ()
73 | endmacro()
74 |
--------------------------------------------------------------------------------
/cmake/OptionsWindows.cmake:
--------------------------------------------------------------------------------
1 | # To build /MDd, uncomment below line.
2 | # set(DEBUG_SUFFIX 1)
3 |
4 | add_definitions(-DNOMINMAX -DUNICODE -D_UNICODE -D_WINDOWS -DWINVER=0x601)
5 |
6 | if (${MSVC_CXX_ARCHITECTURE_ID} STREQUAL "X86")
7 | link_directories("${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib32")
8 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/lib32)
9 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib32)
10 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/bin32)
11 | else ()
12 | link_directories("${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib64")
13 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/lib64)
14 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib64)
15 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/bin64)
16 | endif ()
17 |
18 | add_definitions(
19 | /wd4018 /wd4068 /wd4099 /wd4100 /wd4127 /wd4138 /wd4146 /wd4180 /wd4189
20 | /wd4201 /wd4244 /wd4251 /wd4267 /wd4275 /wd4288 /wd4291 /wd4305 /wd4309
21 | /wd4344 /wd4355 /wd4389 /wd4396 /wd4456 /wd4457 /wd4458 /wd4459 /wd4481
22 | /wd4503 /wd4505 /wd4510 /wd4512 /wd4530 /wd4610 /wd4611 /wd4702 /wd4706
23 | /wd4800 /wd4819 /wd4951 /wd4952 /wd4996 /wd6011 /wd6031 /wd6211 /wd6246
24 | /wd6255 /wd6387
25 | )
26 |
27 | # Create pdb files for debugging purposes, also for Release builds
28 | add_compile_options(/Zi /GS)
29 |
30 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEBUG")
31 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG")
32 |
33 | # We do not use exceptions
34 | add_definitions(-D_HAS_EXCEPTIONS=0)
35 | add_compile_options(/EHa- /EHc- /EHs- /fp:except-)
36 |
37 | # We have some very large object files that have to be linked
38 | add_compile_options(/analyze- /bigobj)
39 |
40 | # Use CRT security features
41 | add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1)
42 |
43 | # Turn off certain link features
44 | add_compile_options(/Gy- /openmp- /GF-)
45 |
46 | if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
47 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /OPT:NOREF /OPT:NOICF")
48 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /OPT:NOREF /OPT:NOICF")
49 |
50 | # To debug linking time issues, uncomment the following three lines:
51 | #add_compile_options(/Bv)
52 | #set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /VERBOSE /VERBOSE:INCR /TIME")
53 | #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /VERBOSE /VERBOSE:INCR /TIME")
54 | elseif (${CMAKE_BUILD_TYPE} MATCHES "Release")
55 | add_compile_options(/Oy-)
56 | endif ()
57 |
58 | if (NOT ${CMAKE_GENERATOR} MATCHES "Ninja")
59 | link_directories("${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}")
60 | add_definitions(/MP)
61 | endif ()
62 | if (NOT ${CMAKE_CXX_FLAGS} STREQUAL "")
63 | string(REGEX REPLACE "(/EH[a-z]+) " "\\1- " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Disable C++ exceptions
64 | string(REGEX REPLACE "/EHsc$" "/EHs- /EHc- " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Disable C++ exceptions
65 | string(REGEX REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Disable RTTI
66 | string(REGEX REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Warnings are important
67 | endif ()
68 |
69 | foreach (flag_var
70 | CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
71 | CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
72 | # Use the multithreaded static runtime library instead of the default DLL runtime.
73 | string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
74 |
75 | # No debug runtime, even in debug builds.
76 | if (NOT DEBUG_SUFFIX)
77 | string(REGEX REPLACE "/MTd" "/MT" ${flag_var} "${${flag_var}}")
78 | string(REGEX REPLACE "/D_DEBUG" "" ${flag_var} "${${flag_var}}")
79 | endif ()
80 | endforeach ()
81 |
82 | foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
83 | string(TOUPPER ${OUTPUTCONFIG} CONFIG)
84 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONFIG} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${OUTPUTCONFIG}")
85 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONFIG} "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${OUTPUTCONFIG}")
86 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONFIG} "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${OUTPUTCONFIG}")
87 | endforeach()
88 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # androidjni++
2 | While writing code in Java is fairly convienient, writing JNI code is not.
3 | By using androidjni++ in your Android project you can remove effort for boring and painful JNI code writing.
4 | Another alternative for get the things done is more famous SWIG, but androidjni++ should be better choice for this particular case for reasons below:
5 | * You don't have to learn to write interface definition files for Java classes.
6 | * You don't have to worry about your project being messed up by generated Java source files.
7 | * You don't have to guess corresponding class methods by reading C functions.
8 | * You don't have to care about Java reference management by using JNI functions.
9 |
10 | And last but not least, androidjni++ supports generating wrappers in C++.
11 | This enables you to write native modules for cross-platform usage much easier.
12 |
13 | ## Prerequisite
14 | * Python - 2.7 or later needed.
15 | * CMake - 3.4 or later.
16 | * Android NDK - r12 or later preferred.
17 |
18 | For cross-platform development on Windows, you'll need Visual Studio 2015.
19 |
20 | ## Getting Started
21 | ### Building Binaries for Android
22 | With CMake and NDK installed, do like this:
23 | ```
24 | export ANDROID_NDK=
25 | export PATH=$PATH:
26 | mkdir build
27 | cd build
28 | cmake -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DANDROID_TOOLCHAIN_NAME=clang -DANDROID_ABI="armeabi-v7a with NEON" -DLIBRARY_PRODUCT_DIR= ..
29 | cmake --build .
30 | ```
31 |
32 | ### Building Binaries for Windows
33 | With CMake installed, do like this:
34 | ```
35 | mkdir build
36 | cd build
37 | cmake -G "Visual Studio 14 2015" -D LIBRARY_PRODUCT_DIR= ..
38 | ```
39 | Then open androidjni++.sln, Hit "Build Solution". or type `cmake --build .`
40 |
41 | ### Building Binaries for Other Platforms
42 | Not yet supported. However we believe most of the implementation for Windows can be used as-is,
43 | for platforms using C++ as their native language.
44 |
45 | ### Intergrating with Your Android Project
46 | * Compile with annotations .java file and native .h header files.
47 | * Link androidjni++.jar and libandroidjni++.so while building.
48 | * You should directly use interface-generator.py for generating stub source files. Do it in generation step while running build script.
49 | * Stubs for native interfaces are generated automatically, but you'll have to write the actual logic yourself.
50 | Otherwise you'll suffer link errors. Link errors are useful for identifying what you should do.
51 |
52 | ## Resources(Under construction)
53 | * The Idea Behind androidjni++
54 | * Code Generation
55 | * Java Reference Management
56 | * Quick Tutorials
57 |
58 | ## Sample Code
59 | See test/testapp.
60 |
61 | ## License
62 | androidjni++ is licensed under BSD license.
63 |
64 | ```
65 | Copyright (c) 2016 NAVER Corp.
66 |
67 | Redistribution and use in source and binary forms, with or without
68 | modification, are permitted provided that the following conditions are met:
69 |
70 | 1. Redistributions of source code must retain the above copyright notice,
71 | this list of conditions and the following disclaimer.
72 |
73 | 2. Redistributions in binary form must reproduce the above copyright notice,
74 | this list of conditions and the following disclaimer in the documentation
75 | and/or other materials provided with the distribution.
76 |
77 | 3. Neither the name of the copyright holder nor the names of its contributors
78 | may be used to endorse or promote products derived from this software
79 | without specific prior written permission.
80 |
81 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
82 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
83 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
84 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
85 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
86 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
87 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
88 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
89 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
90 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
91 | POSSIBILITY OF SUCH DAMAGE.
92 | ```
--------------------------------------------------------------------------------
/androidjni/platforms/generic/ReferenceFunctions.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Naver Labs. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * * Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * * Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | */
25 |
26 | #include
27 |
28 | #include "ObjectReference.h"
29 |
30 | namespace JNI {
31 |
32 | ref_t refLocal(ref_t ref)
33 | {
34 | if (!ref)
35 | return 0;
36 |
37 | ObjectReference* bind = reinterpret_cast(ref);
38 | return bind->refLocal();
39 | }
40 |
41 | void derefLocal(ref_t ref)
42 | {
43 | if (!ref)
44 | return;
45 |
46 | ObjectReference* bind = reinterpret_cast(ref);
47 | bind->derefLocal(bind);
48 | }
49 |
50 | ref_t refGlobal(ref_t ref)
51 | {
52 | if (!ref)
53 | return 0;
54 |
55 | ObjectReference* bind = reinterpret_cast(ref);
56 | return bind->refGlobal();
57 | }
58 |
59 | void derefGlobal(ref_t ref)
60 | {
61 | if (!ref)
62 | return;
63 |
64 | ObjectReference* bind = reinterpret_cast(ref);
65 | bind->derefGlobal(bind);
66 | }
67 |
68 | bool isExpiredWeakGlobal(weak_t ref)
69 | {
70 | // FIXME: Implement weak reference functionality.
71 | if (!ref)
72 | return false;
73 |
74 | ObjectReference* bind = reinterpret_cast