diff --git a/examples/AndroidMath/AndroidManifest.xml b/examples/AndroidMath/AndroidManifest.xml
new file mode 100644
index 000000000..9f9f5d098
--- /dev/null
+++ b/examples/AndroidMath/AndroidManifest.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/AndroidMath/AndroidMath.cpp b/examples/AndroidMath/AndroidMath.cpp
new file mode 100644
index 000000000..4a4a1d88c
--- /dev/null
+++ b/examples/AndroidMath/AndroidMath.cpp
@@ -0,0 +1,23 @@
+#include
+#include
+
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Class: org_upp_AndroidMath_AndroidMath
+ * Method: power
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_upp_AndroidMath_AndroidMath_power
+ (JNIEnv *, jclass, jint number, jint n)
+{
+ return AndroidMathUtility::Power(number, n);
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/examples/AndroidMath/AndroidMath.java b/examples/AndroidMath/AndroidMath.java
new file mode 100644
index 000000000..9317d0cd8
--- /dev/null
+++ b/examples/AndroidMath/AndroidMath.java
@@ -0,0 +1,15 @@
+package org.upp.AndroidMath;
+
+public class AndroidMath
+{
+ private AndroidMath() {}
+
+ // Native stuff - C/C++
+ public static native int power(int number, int n);
+
+ static {
+ // In this place we are loading native libraries.
+ // Native library always has upp package name!
+ System.loadLibrary("AndroidMath");
+ }
+}
diff --git a/examples/AndroidMath/AndroidMath.upp b/examples/AndroidMath/AndroidMath.upp
new file mode 100644
index 000000000..7aebdfea6
--- /dev/null
+++ b/examples/AndroidMath/AndroidMath.upp
@@ -0,0 +1,21 @@
+description "Android builder juicy example\377";
+
+uses
+ AndroidMathUtility;
+
+file
+ MemoryManager readonly separator,
+ MemoryManager.h,
+ Native readonly separator,
+ AndroidMath.cpp,
+ Vector.cpp,
+ Math readonly separator,
+ Vector.java,
+ Runtime readonly separator,
+ AndroidManifest.xml,
+ AndroidMath.java,
+ AndroidMathActivity.java;
+
+mainconfig
+ "" = "";
+
diff --git a/examples/AndroidMath/AndroidMathActivity.java b/examples/AndroidMath/AndroidMathActivity.java
new file mode 100644
index 000000000..9b493aa84
--- /dev/null
+++ b/examples/AndroidMath/AndroidMathActivity.java
@@ -0,0 +1,48 @@
+package org.upp.AndroidMath;
+
+import android.app.Activity;
+import android.widget.TextView;
+import android.widget.ScrollView;
+import android.os.Bundle;
+
+public class AndroidMathActivity extends Activity
+{
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+
+ ScrollView scroller = new ScrollView(this);
+ TextView tv = new TextView(this);
+
+ calculatePowerOperations(tv, 20);
+ calculateVectorOperations(tv);
+
+ scroller.addView(tv);
+ setContentView(scroller);
+ }
+
+ private void calculatePowerOperations(TextView tv, int maxPower)
+ {
+ String text = "Power:\n";
+ int maxNumber = maxPower;
+ for(int i = 1; i <= maxNumber; i++) {
+ int pow = AndroidMath.power(i, 2);
+ text += Integer.toString(i) + "^2 = " + Integer.toString(pow) + "\n";
+ }
+
+ tv.append(text);
+ }
+
+ private void calculateVectorOperations(TextView tv)
+ {
+ String text = "Vector operations:\n";
+
+ Vector vec1 = new Vector(3);
+
+ text += "Vec1 Size: " + Integer.toString(vec1.getSize()) + "\n";
+ text += "Vec1: " + vec1.toString() + "\n";
+
+ tv.append(text);
+ }
+}
diff --git a/examples/AndroidMath/MemoryManager.h b/examples/AndroidMath/MemoryManager.h
new file mode 100644
index 000000000..665022119
--- /dev/null
+++ b/examples/AndroidMath/MemoryManager.h
@@ -0,0 +1,71 @@
+#ifndef _JniMath_MemoryManager_h_
+#define _JniMath_MemoryManager_h_
+
+#include
+#include
+#include
+#include
+
+/**
+ * Java "HashCode()" object memory manager.
+ */
+template
+class MemoryManager {
+public:
+ void Insert(JNIEnv *env, jobject jobj, const T& obj)
+ {
+ std::string hashCode = GetJobjectHasCode(env, jobj);
+ if(!hashCode.empty()) {
+ hashCodes.push_back(hashCode);
+ values.push_back(obj);
+ }
+ }
+
+ void Erase(JNIEnv *env, jobject jobj)
+ {
+ int idx = FindIdx(env, jobj);
+ if(idx >= 0) {
+ hashCodes.erase(hashCodes.begin() + idx);
+ values.erase(values.begin() + idx);
+ }
+ }
+
+ T* Get(JNIEnv *env, jobject jobj)
+ {
+ int idx = FindIdx(env, jobj);
+ return idx != -1 ? &values[idx] : NULL;
+ }
+
+private:
+ int FindIdx(JNIEnv *env, jobject jobj)
+ {
+ std::string hashCode = GetJobjectHasCode(env, jobj);
+ for(int i = 0; i < hashCodes.size(); i++) {
+ if(hashCode == hashCodes[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ std::string GetJobjectHasCode(JNIEnv *env, jobject jobj)
+ {
+ jclass cls = env->GetObjectClass(jobj);
+ jmethodID mid = env->GetMethodID(cls, "hashCode", "()I");
+ if(mid == 0) {
+ return "";
+ }
+ int ret = env->CallIntMethod(jobj, mid);
+
+ std::stringstream ss;
+ ss << ret;
+
+ return ss.str();
+ }
+
+private:
+ std::vector hashCodes;
+ std::vector values;
+};
+
+#endif
diff --git a/examples/AndroidMath/Vector.cpp b/examples/AndroidMath/Vector.cpp
new file mode 100644
index 000000000..bb197b8e5
--- /dev/null
+++ b/examples/AndroidMath/Vector.cpp
@@ -0,0 +1,96 @@
+#ifndef _Included_org_upp_AndroidMath_Vector
+#define _Included_org_upp_AndroidMath_Vector
+
+#include
+#include