Permalink
Browse files

Add binding for Compatibility-v4 library.

  • Loading branch information...
1 parent 7c8f243 commit 830f93d8c5f91848219b1e5e85a6b981ebb1d3de @jonpryor jonpryor committed Jan 26, 2012
View
2 Compatibility-v4/bindings/.gitignore
@@ -0,0 +1,2 @@
+bin
+obj
View
53 Compatibility-v4/bindings/Makefile
@@ -0,0 +1,53 @@
+MONO_ANDROID_PATH := /Developer/MonoAndroid/usr
+ANDROID_SDK_PATH := /opt/android/sdk
+API_LEVELS := 8
+BUILDDIR := bin
+topdir := ../..
+
+MCW_GEN := $(MONO_ANDROID_PATH)/bin/mcw-gen
+
+platforms_dir := $(BUILDDIR)/platforms
+
+ASSEMBLIES = $(API_LEVELS:%=$(platforms_dir)/android-%/Mono.Android.Compatibility.v4.dll)
+DOCS = $(API_LEVELS:%=$(platforms_dir)/android-%/Mono.Android.Compatibility.v4.xml)
+JAR = $(ANDROID_SDK_PATH)/extras/android/support/v4/android-support-v4.jar
+
+all:: $(JARS) $(ASSEMBLIES) $(DOCS)
+
+clean::
+ $(RM) -r $(ASSEMBLIES) obj
+
+SOURCES = \
+ $(topdir)/src/Android.Support.V4.Content/CursorLoader.cs \
+ src/AssemblyInfo.cs
+
+$(ASSEMBLIES): $(platforms_dir)/android-%/Mono.Android.Compatibility.v4.dll: map.csv methodmap.csv metadata $(SOURCES) $(MCW_GEN)
+ -mkdir -p $(platforms_dir)/android-$*
+ -mkdir -p obj/platform-$*
+ $(MCW_GEN) \
+ -sdk-dir="$(ANDROID_SDK_PATH)" \
+ -sdk-platform=$* \
+ -jar=$(JAR) \
+ -dll="$(platforms_dir)/android-$*/Mono.Android.Compatibility.v4.dll" \
+ -use-variable-csv-format \
+ -fixup=metadata \
+ -enumfields=map.csv -enummethods=methodmap.csv -global -v \
+ -o obj/platform-$* \
+ -cscopt -debug+ -cscopt -nowarn:0109,0108 \
+ $(SOURCES:%=-cscopt "%")
+
+$(DOCS): $(platforms_dir)/android-%/Mono.Android.Compatibility.v4.xml: $(platforms_dir)/android-%/Mono.Android.Compatibility.v4.dll map.csv metadata
+ $(RM) -R obj/platform-$*/docs
+ -mkdir -p obj/platform-$*/docs
+ -cp -R Documentation/en obj/platform-$*/docs
+ mdoc update -o obj/platform-$*/docs $< -L $(MONO_ANDROID_PATH)/lib/mandroid/platforms/android-$*
+ mdoc export-msxdoc -o $@ obj/platform-$*/docs
+
+$(MCW_GEN):
+ @echo "Building bindings requires Mono for Android 4.2 or later."
+ exit 1
+
+$(JAR):
+ @echo "Please install the \"Android Support package\"."
+ exit 1
+
View
3 Compatibility-v4/bindings/map.csv
@@ -0,0 +1,3 @@
+0, Android\Support\V4\App\FragmentTagType, Id, android/support/v4/app/FragmentActivity$FragmentTag.Fragment_id, 1
+0, Android\Support\V4\App\FragmentTagType, Name, android/support/v4/app/FragmentActivity$FragmentTag.Fragment_name, 0
+0, Android\Support\V4\App\FragmentTagType, Tag, android/support/v4/app/FragmentActivity$FragmentTag.Fragment_tag, 2
View
18 Compatibility-v4/bindings/metadata
@@ -0,0 +1,18 @@
+<metadata>
+ <remove-node path="/api/package[@name='android.support.v4.widget']/class[@name='CursorAdapter']/implements[@name='android.support.v4.widget.CursorFilter.CursorFilterClient']" />
+ <remove-node path="/api/package[@name='android.support.v4.widget']/class[@name='CursorAdapter']/field[@name='mCursorFilter']" />
+
+ <remove-node path="/api/package[@name='android.support.v4.content']/class[@name='AsyncTaskLoader.LoadTask']" />
+ <!-- FIXME:
+ This method is an override of another method in the base types.
+ The base method expects JLO, but this method returns Cursor.
+ So we somehow have to fill the gap between them.
+ -->
+ <remove-node path="/api/package[@name='android.support.v4.content']/class[@name='CursorLoader']/method[@name='loadInBackground']" />
+
+ <remove-node path="/api/package[@name='android.support.v4.view.accessibility']/class[@name='AccessibilityNodeInfoCompat.AccessibilityNodeInfoIcsImpl']" />
+ <remove-node path="/api/package[@name='android.support.v4.widget']/class[@name='CursorAdapter']" />
+ <remove-node path="/api/package[@name='android.support.v4.widget']/class[@name='CursorAdapter.ChangeObserver']" />
+ <remove-node path="/api/package[@name='android.support.v4.view.accessibility']/class[@name='AccessibilityNodeInfoCompat.AccessibilityNodeInfoStubImpl']" />
+ <remove-node path="/api/package[@name='android.support.v4.view']/interface[@name='ViewPager.OnAdapterChangeListener']" />
+</metadata>
View
5 Compatibility-v4/bindings/methodmap.csv
@@ -0,0 +1,5 @@
+0,android.support.v4.app,BackStackState,writeToParcel,p1, Android.OS.ParcelableWriteFlags
+0,android.support.v4.app,FragmentState,writeToParcel,p1, Android.OS.ParcelableWriteFlags
+0,android.support.v4.app,FragmentManagerState,writeToParcel,p1, Android.OS.ParcelableWriteFlags
+0,android.support.v4.app,Fragment.SavedState,writeToParcel,p1, Android.OS.ParcelableWriteFlags
+0,android.support.v4.view.accessibility,AccessibilityNodeInfoCompat.AccessibilityNodeInfoIcsImpl,getChild,return, Java.Lang.Object
View
1 Compatibility-v4/bindings/src/AssemblyInfo.cs
@@ -0,0 +1 @@
+
View
22 src/Android.Support.V4.Content/CursorLoader.cs
@@ -0,0 +1,22 @@
+using System;
+using Android.Runtime;
+
+namespace Android.Support.V4.Content {
+
+ public partial class CursorLoader {
+
+ static IntPtr id_loadInBackground;
+ [Register ("loadInBackground", "()Landroid/database/Cursor;", "GetLoadInBackgroundHandler")]
+ public override Java.Lang.Object LoadInBackground ()
+ {
+ if (id_loadInBackground == IntPtr.Zero)
+ id_loadInBackground = JNIEnv.GetMethodID (class_ref, "loadInBackground", "()Landroid/database/Cursor;");
+
+ if (GetType () == ThresholdType)
+ return (Java.Lang.Object) Java.Lang.Object.GetObject<Android.Database.ICursor> (JNIEnv.CallObjectMethod (Handle, id_loadInBackground), JniHandleOwnership.TransferLocalRef);
+ else
+ return (Java.Lang.Object) Java.Lang.Object.GetObject<Android.Database.ICursor> (JNIEnv.CallNonvirtualObjectMethod (Handle, ThresholdClass, id_loadInBackground), JniHandleOwnership.TransferLocalRef);
+ }
+ }
+}
+

0 comments on commit 830f93d

Please sign in to comment.