diff --git a/Examples/android/extend/AndroidManifest.xml b/Examples/android/extend/AndroidManifest.xml
new file mode 100644
index 000000000..66d2469fa
--- /dev/null
+++ b/Examples/android/extend/AndroidManifest.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/android/extend/Makefile b/Examples/android/extend/Makefile
new file mode 100644
index 000000000..98a0372dd
--- /dev/null
+++ b/Examples/android/extend/Makefile
@@ -0,0 +1,29 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+TARGET = example
+INTERFACE = example.i
+PACKAGEDIR = src/org/swig
+PACKAGENAME= org.swig.extendexample
+SWIGOPT = -package $(PACKAGENAME) -outdir $(PACKAGEDIR)/extendexample
+PROJECTNAME= SwigExtend
+TARGETID = 1
+
+all:: android
+
+android::
+ android update project --target $(TARGETID) --name $(PROJECTNAME) --path .
+ $(SWIG) -c++ -java $(SWIGOPT) -o jni/$(TARGET)_wrap.cpp jni/$(INTERFACE)
+ ndk-build
+ ant debug
+
+install::
+ -adb uninstall $(PACKAGENAME)
+ adb install bin/$(PROJECTNAME)-debug.apk
+
+clean::
+ ant clean
+ rm -f jni/$(TARGET)_wrap.cpp
+ rm -f `find $(PACKAGEDIR) -name \*.java | grep -v $(PROJECTNAME).java`
+
+
+check: all
diff --git a/Examples/android/extend/ant.properties b/Examples/android/extend/ant.properties
new file mode 100644
index 000000000..ee52d86d9
--- /dev/null
+++ b/Examples/android/extend/ant.properties
@@ -0,0 +1,17 @@
+# This file is used to override default values used by the Ant build system.
+#
+# This file must be checked in Version Control Systems, as it is
+# integral to the build system of your project.
+
+# This file is only used by the Ant script.
+
+# You can use this to override default values such as
+# 'source.dir' for the location of your java source folder and
+# 'out.dir' for the location of your output folder.
+
+# You can also use it define how the release builds are signed by declaring
+# the following properties:
+# 'key.store' for the location of your keystore and
+# 'key.alias' for the name of the key to use.
+# The password will be asked during the build when you use the 'release' target.
+
diff --git a/Examples/android/extend/build.xml b/Examples/android/extend/build.xml
new file mode 100644
index 000000000..94fe847b7
--- /dev/null
+++ b/Examples/android/extend/build.xml
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/android/extend/jni/Android.mk b/Examples/android/extend/jni/Android.mk
new file mode 100644
index 000000000..25d42b541
--- /dev/null
+++ b/Examples/android/extend/jni/Android.mk
@@ -0,0 +1,10 @@
+# File: Android.mk
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := example
+LOCAL_SRC_FILES := example_wrap.cpp example.cpp
+LOCAL_CFLAGS := -frtti
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/Examples/android/extend/jni/Application.mk b/Examples/android/extend/jni/Application.mk
new file mode 100644
index 000000000..87124dd88
--- /dev/null
+++ b/Examples/android/extend/jni/Application.mk
@@ -0,0 +1 @@
+APP_STL := gnustl_static
diff --git a/Examples/android/extend/jni/example.cpp b/Examples/android/extend/jni/example.cpp
new file mode 100644
index 000000000..450d75608
--- /dev/null
+++ b/Examples/android/extend/jni/example.cpp
@@ -0,0 +1,4 @@
+/* File : example.cxx */
+
+#include "example.h"
+
diff --git a/Examples/android/extend/jni/example.h b/Examples/android/extend/jni/example.h
new file mode 100644
index 000000000..b27ab9711
--- /dev/null
+++ b/Examples/android/extend/jni/example.h
@@ -0,0 +1,56 @@
+/* File : example.h */
+
+#include
+#include
+#include
+#include
+#include
+
+class Employee {
+private:
+ std::string name;
+public:
+ Employee(const char* n): name(n) {}
+ virtual std::string getTitle() { return getPosition() + " " + getName(); }
+ virtual std::string getName() { return name; }
+ virtual std::string getPosition() const { return "Employee"; }
+ virtual ~Employee() { printf("~Employee() @ %p\n", this); }
+};
+
+
+class Manager: public Employee {
+public:
+ Manager(const char* n): Employee(n) {}
+ virtual std::string getPosition() const { return "Manager"; }
+};
+
+
+class EmployeeList {
+ std::vector list;
+public:
+ EmployeeList() {
+ list.push_back(new Employee("Bob"));
+ list.push_back(new Employee("Jane"));
+ list.push_back(new Manager("Ted"));
+ }
+ void addEmployee(Employee *p) {
+ list.push_back(p);
+ std::cout << "New employee added. Current employees are:" << std::endl;
+ std::vector::iterator i;
+ for (i=list.begin(); i!=list.end(); i++) {
+ std::cout << " " << (*i)->getTitle() << std::endl;
+ }
+ }
+ const Employee *get_item(int i) {
+ return list[i];
+ }
+ ~EmployeeList() {
+ std::vector::iterator i;
+ std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl;
+ for (i=list.begin(); i!=list.end(); i++) {
+ delete *i;
+ }
+ std::cout << "~EmployeeList empty." << std::endl;
+ }
+};
+
diff --git a/Examples/android/extend/jni/example.i b/Examples/android/extend/jni/example.i
new file mode 100644
index 000000000..c8ec32e09
--- /dev/null
+++ b/Examples/android/extend/jni/example.i
@@ -0,0 +1,15 @@
+/* File : example.i */
+%module(directors="1") example
+%{
+#include "example.h"
+%}
+
+%include "std_vector.i"
+%include "std_string.i"
+
+/* turn on director wrapping for Manager */
+%feature("director") Employee;
+%feature("director") Manager;
+
+%include "example.h"
+
diff --git a/Examples/android/extend/local.properties b/Examples/android/extend/local.properties
new file mode 100644
index 000000000..14b8d63b4
--- /dev/null
+++ b/Examples/android/extend/local.properties
@@ -0,0 +1,10 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must *NOT* be checked in Version Control Systems,
+# as it contains information specific to your local configuration.
+
+# location of the SDK. This is only used by Ant
+# For customization when using a Version Control System, please read the
+# header note.
+sdk.dir=/home/william/android/android-sdk-linux_x86
diff --git a/Examples/android/extend/proguard.cfg b/Examples/android/extend/proguard.cfg
new file mode 100644
index 000000000..b1cdf17b5
--- /dev/null
+++ b/Examples/android/extend/proguard.cfg
@@ -0,0 +1,40 @@
+-optimizationpasses 5
+-dontusemixedcaseclassnames
+-dontskipnonpubliclibraryclasses
+-dontpreverify
+-verbose
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class com.android.vending.licensing.ILicensingService
+
+-keepclasseswithmembernames class * {
+ native ;
+}
+
+-keepclasseswithmembers class * {
+ public (android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+ public (android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers class * extends android.app.Activity {
+ public void *(android.view.View);
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+ public static final android.os.Parcelable$Creator *;
+}
diff --git a/Examples/android/extend/project.properties b/Examples/android/extend/project.properties
new file mode 100644
index 000000000..ea89160e0
--- /dev/null
+++ b/Examples/android/extend/project.properties
@@ -0,0 +1,11 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-8
diff --git a/Examples/android/extend/res/layout/main.xml b/Examples/android/extend/res/layout/main.xml
new file mode 100644
index 000000000..d4e5d7fe8
--- /dev/null
+++ b/Examples/android/extend/res/layout/main.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
diff --git a/Examples/android/extend/res/values/strings.xml b/Examples/android/extend/res/values/strings.xml
new file mode 100644
index 000000000..63fcbf02a
--- /dev/null
+++ b/Examples/android/extend/res/values/strings.xml
@@ -0,0 +1,4 @@
+
+
+ SwigExtend
+
diff --git a/Examples/android/extend/src/org/swig/extendexample/SwigExtend.java b/Examples/android/extend/src/org/swig/extendexample/SwigExtend.java
new file mode 100644
index 000000000..847b60892
--- /dev/null
+++ b/Examples/android/extend/src/org/swig/extendexample/SwigExtend.java
@@ -0,0 +1,108 @@
+package org.swig.extendexample;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.ScrollView;
+import android.text.method.ScrollingMovementMethod;
+
+public class SwigExtend extends Activity
+{
+ TextView outputText = null;
+ ScrollView scroller = null;
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ outputText = (TextView)findViewById(R.id.OutputText);
+ outputText.setText("Press 'Run' to start...\n");
+ outputText.setMovementMethod(new ScrollingMovementMethod());
+
+ scroller = (ScrollView)findViewById(R.id.Scroller);
+ }
+
+ public void onRunButtonClick(View view)
+ {
+ outputText.append("Started...\n");
+ nativeCall();
+ outputText.append("Finished!\n");
+
+ // Ensure scroll to end of text
+ scroller.post(new Runnable() {
+ public void run() {
+ scroller.fullScroll(ScrollView.FOCUS_DOWN);
+ }
+ });
+ }
+
+ /** Calls into C/C++ code */
+ public void nativeCall()
+ {
+ /*
+ // ----- Object creation -----
+
+ outputText.append( "Creating some objects:\n" );
+ Circle c = new Circle(10);
+ outputText.append( " Created circle " + c + "\n");
+ Square s = new Square(10);
+ outputText.append( " Created square " + s + "\n");
+
+ // ----- Access a static member -----
+
+ outputText.append( "\nA total of " + Shape.getNshapes() + " shapes were created\n" );
+
+ // ----- Member data access -----
+
+ // Notice how we can do this using functions specific to
+ // the 'Circle' class.
+ c.setX(20);
+ c.setY(30);
+
+ // Now use the same functions in the base class
+ Shape shape = s;
+ shape.setX(-10);
+ shape.setY(5);
+
+ outputText.append( "\nHere is their current position:\n" );
+ outputText.append( " Circle = (" + c.getX() + " " + c.getY() + ")\n" );
+ outputText.append( " Square = (" + s.getX() + " " + s.getY() + ")\n" );
+
+ // ----- Call some methods -----
+
+ outputText.append( "\nHere are some properties of the shapes:\n" );
+ Shape[] shapes = {c,s};
+ for (int i=0; i