summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Freeman <saurik@saurik.com>2008-03-11 03:37:55 +0000
committerJay Freeman <saurik@saurik.com>2008-03-11 03:37:55 +0000
commit090e74f70d3bc182719fd1d28ea45312bcdbc9f4 (patch)
treea3124e30ca575514519dbe568dfd84ec52d3fddd
parent2048c0f0d9fba74a699399e19b1ed99147d6cea4 (diff)
Various mergings from the JocStrap project.
git-svn-id: http://svn.telesphoreo.org/trunk@185 514c082c-b64e-11dc-b46d-3d985efe055d
-rwxr-xr-xdata/iphone-java/HelloJava.app/HelloJava3
-rw-r--r--data/iphone-java/HelloJava.app/HelloJava.java117
-rwxr-xr-xdata/iphone-java/HelloScript.app/HelloScript3
-rw-r--r--data/iphone-java/HelloScript.app/HelloScript.js130
-rw-r--r--data/iphone-java/_metadata/version2
-rw-r--r--data/iphone-java/make.sh2
-rw-r--r--data/jocstrap/_metadata/version2
-rw-r--r--data/jocstrap/jocstrap.jarbin1497766 -> 1501899 bytes
-rwxr-xr-xdata/jocstrap/libjocstrap.jnilibbin74852 -> 79564 bytes
-rw-r--r--data/uicaboodle/_metadata/version2
-rwxr-xr-xdata/uicaboodle/libuicaboodle.jnilibbin18308 -> 18308 bytes
-rw-r--r--data/uicaboodle/uicaboodle.jarbin4775 -> 5127 bytes
12 files changed, 132 insertions, 129 deletions
diff --git a/data/iphone-java/HelloJava.app/HelloJava b/data/iphone-java/HelloJava.app/HelloJava
index 88d801cdb..97019aea5 100755
--- a/data/iphone-java/HelloJava.app/HelloJava
+++ b/data/iphone-java/HelloJava.app/HelloJava
@@ -1,4 +1,3 @@
#!/bin/bash
-# XXX: -Xbootclasspath is used as JamVM runs 3x faster
# XXX: Java is symlink'd to here so the home button works
-exec "$(dirname "$0")"/Java -Xmx8M -Xss256K -Xbootclasspath/p:/usr/share/java/sqlite.jar:/usr/share/java/jocstrap.jar -cp /usr/share/java/uicaboodle.jar:"$(dirname "$0")" com.saurik.uicaboodle.Main HelloJava "$@"
+exec "$(dirname "$0")"/Java -Xmx8M -Xss256K -cp /usr/share/java/sqlite.jar:/usr/share/java/jocstrap.jar:/usr/share/java/uicaboodle.jar:"$(dirname "$0")" com.saurik.uicaboodle.Main HelloJava "$@"
diff --git a/data/iphone-java/HelloJava.app/HelloJava.java b/data/iphone-java/HelloJava.app/HelloJava.java
index b33f9b64c..4face9dd7 100644
--- a/data/iphone-java/HelloJava.app/HelloJava.java
+++ b/data/iphone-java/HelloJava.app/HelloJava.java
@@ -18,12 +18,10 @@ private UIWindow window;
private static class Contact {
public String first;
public String last;
- public UITableCell cell;
public Contact(String first, String last) {
this.first = first;
this.last = last;
- this.cell = null;
}
public String getName() {
@@ -44,39 +42,77 @@ public static class Section {
}
}
-private ArrayList<Contact> contacts_ = new ArrayList<Contact>();
-private ArrayList<Section> sections_ = new ArrayList<Section>();
+private ArrayList<Contact> contacts_;
+private ArrayList<Section> sections_;
+
+@Message int numberOfSectionsInSectionList$(UISectionList list) {
+ return sections_.size();
+}
+
+@Message String sectionList$titleForSection$(UISectionList list, int section) {
+ return sections_.get(section).title;
+}
+
+@Message int sectionList$rowForSection$(UISectionList list, int section) {
+ return sections_.get(section).row;
+}
+
+@Message int numberOfRowsInTable$(UITable table) {
+ return contacts_.size();
+}
+
+@Message UITableCell table$cellForRow$column$reusing$(UITable table, int row, UITableColumn col, UITableCell reusing) {
+ Contact contact = contacts_.get(row);
+
+ UIImageAndTextTableCell cell;
+ if (reusing != null)
+ cell = (UIImageAndTextTableCell) reusing;
+ else
+ cell = (UIImageAndTextTableCell) new UIImageAndTextTableCell().init();
+
+ cell.setTitle$(contact.getName());
+ return cell;
+}
+
+@Message public byte table$canSelectRow$(UITable table, int row) {
+ return NO;
+}
@Message public void applicationDidFinishLaunching$(Object unused)
throws Exception
{
+ contacts_ = new ArrayList<Contact>();
+ sections_ = new ArrayList<Section>();
+
SQLite.Database ab = new SQLite.Database();
ab.open(userHomeDirectory().toString() + "/Library/AddressBook/AddressBook.sqlitedb", 0666); try {
SQLite.Stmt st = ab.prepare("select first, last from ABPerson where first is not null order by first"); try {
while (st.step())
- contacts_.add(new Contact(st.column_string(0), st.column_string(1)));
+ contacts_.add(new Contact(
+ st.column_string(0),
+ st.column_string(1)
+ ));
} finally { st.close(); }
} finally { ab.close(); }
CGRect outer = UIHardware.fullScreenApplicationContentRect();
- CGRect inner = outer.clone();
- inner.origin.x = inner.origin.y = 0;
+ window = new UIWindow().initWithContentRect$(outer);
- window = new UIWindow().initWithContentRect$(inner);
window.orderFront$(this);
window.makeKey$(this);
window._setHidden$(NO);
+ CGRect inner = window.bounds();
CGSize navsize = UINavigationBar.defaultSize();
- UINavigationBar navbar = new UINavigationBar().initWithFrame$(new CGRect(0, 0, inner.size.width, navsize.height));
- navbar.setBarStyle$(1);
- navbar.showButtonsWithLeftTitle$rightTitle$leftBack$("Run GC", null, YES);
+ CGRect navrect = new CGRect(0, 0, inner.size.width, navsize.height);
- navbar.setDelegate$(new NSObject() {
- @Message void navigationBar$buttonClicked$(UINavigationBar navbar, int button) {
- navbar.showButtonsWithLeftTitle$rightTitle$leftBack$("I was clicked!", null, YES);
- }
- }.init());
+ UIView view = new UIView().initWithFrame$(inner);
+ window.setContentView$(view);
+
+ UINavigationBar navbar = new UINavigationBar().initWithFrame$(navrect);
+ view.addSubview$(navbar);
+
+ navbar.setBarStyle$(1);
UINavigationItem navitem = new UINavigationItem().initWithTitle$("Contact List");
navbar.pushNavigationItem$(navitem);
@@ -88,54 +124,25 @@ private ArrayList<Section> sections_ = new ArrayList<Section>();
if (letter != now) {
letter = now;
sections_.add(new Section(
- i, new String(new char[] {now})
+ i,
+ new String(new char[] {now})
));
}
}
- UISectionList seclist = new UISectionList().initWithFrame$(new CGRect(0, navsize.height, inner.size.width, inner.size.height - navsize.height));
-
- seclist.setDataSource$(new NSObject() {
- @Message int numberOfSectionsInSectionList$(UISectionList list) {
- return sections_.size();
- }
+ CGRect lower = new CGRect(0, navsize.height, inner.size.width, inner.size.height - navsize.height);
+ UISectionList list = new UISectionList().initWithFrame$(lower);
+ view.addSubview$(list);
- @Message String sectionList$titleForSection$(UISectionList list, int section) {
- return sections_.get(section).title;
- }
+ UITableColumn col = new UITableColumn().initWithTitle$identifier$width$("Name", "name", 320);
- @Message int sectionList$rowForSection$(UISectionList list, int section) {
- return sections_.get(section).row;
- }
-
- @Message int numberOfRowsInTable$(UITable table) {
- return contacts_.size();
- }
-
- @Message UITableCell table$cellForRow$column$(UITable table, int row, UITableColumn col) {
- Contact contact = contacts_.get(row);
- if (contact.cell != null)
- return contact.cell;
- UIImageAndTextTableCell cell = (UIImageAndTextTableCell) new UIImageAndTextTableCell().init();
- cell.setTitle$(contact.getName());
- contact.cell = cell;
- return cell;
- }
- }.init());
-
- seclist.reloadData();
-
- UITableColumn col = new UITableColumn().initWithTitle$identifier$width$("Name", "name", 320.0f);
-
- UITable table = (UITable) seclist.table();
+ UITable table = (UITable) list.table();
table.setSeparatorStyle$(1);
table.addTableColumn$(col);
+ table.setReusesTableCells$(YES);
- UIView view = new UIView().initWithFrame$(inner);
- view.addSubview$(navbar);
- view.addSubview$(seclist);
-
- window.setContentView$(view);
+ list.setDataSource$(this);
+ list.reloadData();
AVController controller = new AVController().init();
CharSequence wavfile = (CharSequence) ((NSBundle) NSBundle.mainBundle()).pathForResource$ofType$("start", "wav");
diff --git a/data/iphone-java/HelloScript.app/HelloScript b/data/iphone-java/HelloScript.app/HelloScript
index 2b4460d41..6b6f58340 100755
--- a/data/iphone-java/HelloScript.app/HelloScript
+++ b/data/iphone-java/HelloScript.app/HelloScript
@@ -1,5 +1,4 @@
#!/bin/bash
-# XXX: -Xbootclasspath is used as JamVM runs 3x faster
# XXX: Java is symlink'd to here so the home button works
cd "$(dirname "$0")"
-exec "$(dirname "$0")"/Java -Xmx8M -Xss256K -Xbootclasspath/p:/usr/share/java/jocstrap.jar:/usr/share/java/js.jar -cp /usr/share/java/sqlite.jar:/usr/share/java/uicaboodle.jar com.saurik.uicaboodle.Main com.saurik.uicaboodle.ScriptApplication HelloScript.js "$@"
+exec "$(dirname "$0")"/Java -Xmx8M -Xss256K -cp /usr/share/java/jocstrap.jar:/usr/share/java/js.jar:/usr/share/java/sqlite.jar:/usr/share/java/uicaboodle.jar com.saurik.uicaboodle.Main com.saurik.uicaboodle.ScriptApplication "$@" -- HelloScript.js
diff --git a/data/iphone-java/HelloScript.app/HelloScript.js b/data/iphone-java/HelloScript.app/HelloScript.js
index 18d45240a..a8c14a445 100644
--- a/data/iphone-java/HelloScript.app/HelloScript.js
+++ b/data/iphone-java/HelloScript.app/HelloScript.js
@@ -1,110 +1,108 @@
var println = function(s) { java.lang.System.out.println(s); }
var sql = Packages.SQLite;
-var contacts = [];
-var sections = [];
+function getName(contact) {
+ var name = contact.first;
+ if (contact.last != null)
+ name += " " + contact.last;
+ return name;
+}
+
+function numberOfSectionsInSectionList$(list) {
+ return sections_.length;
+}
+
+function sectionList$titleForSection$(list, section) {
+ return sections_[section].title;
+}
+
+function sectionList$rowForSection$(list, section) {
+ return sections_[section].row;
+}
+
+function numberOfRowsInTable$(table) {
+ return contacts_.length;
+}
+
+function table$cellForRow$column$reusing$(table, row, col, reusing) {
+ var contact = contacts_[row];
+
+ var cell;
+ if (reusing != null)
+ cell = reusing;
+ else
+ cell = new obc.UIImageAndTextTableCell().init();
+
+ cell.setTitle$(getName(contact));
+ return cell;
+}
+
+function table$canSelectRow$(table, row) {
+ return NO;
+}
+
+var contacts_ = [];
+var sections_ = [];
var ab = new sql.Database();
ab.open(application.userHomeDirectory().toString() + "/Library/AddressBook/AddressBook.sqlitedb", 0666); try {
var st = ab.prepare("select first, last from ABPerson where first is not null order by first"); try {
while (st.step())
- contacts.push({
+ contacts_.push({
first: st.column_string(0),
- last: st.column_string(1),
- cell: null
+ last: st.column_string(1)
});
} finally { st.close(); }
} finally { ab.close(); }
-function getName(contact) {
- var name = contact.first;
- if (contact.last != null)
- name += " " + contact.last;
- return name;
-}
-
var outer = obc.UIHardware.fullScreenApplicationContentRect();
-var inner = outer.clone();
-inner.origin.x = inner.origin.y = 0;
+var window = new obc.UIWindow().initWithContentRect$(outer);
-var window = new obc.UIWindow().initWithContentRect$(inner);
window.orderFront$(application);
window.makeKey$(application);
window._setHidden$(NO);
+var inner = window.bounds();
var navsize = obc.UINavigationBar().defaultSize();
-var navbar = new obc.UINavigationBar().initWithFrame$(new obc.CGRect(0, 0, inner.size.width, navsize.height));
-navbar.setBarStyle$(1);
-navbar.showButtonsWithLeftTitle$rightTitle$leftBack$("Run GC", null, YES);
+var navrect = new obc.CGRect(0, 0, inner.size.width, navsize.height);
-navbar.setDelegate$({
- navigationBar$buttonClicked$: function(navbar, button) {
- Packages.java.lang.Runtime.getRuntime().gc();
- }
-});
+var view = new obc.UIView().initWithFrame$(inner);
+window.setContentView$(view);
+
+var navbar = new obc.UINavigationBar().initWithFrame$(navrect);
+view.addSubview$(navbar);
+
+navbar.setBarStyle$(1);
var navitem = new obc.UINavigationItem().initWithTitle$("Contact List");
navbar.pushNavigationItem$(navitem);
var letter = null;
-for (var i = 0; i != contacts.length; ++i) {
- var name = getName(contacts[i]);
+for (var i = 0; i != contacts_.length; ++i) {
+ var name = getName(contacts_[i]);
var now = name[0].toUpperCase();
if (letter != now) {
letter = now;
- sections.push({
+ sections_.push({
row: i,
title: now
});
}
}
-var seclist = new obc.UISectionList().initWithFrame$(new obc.CGRect(0, navsize.height, inner.size.width, inner.size.height - navsize.height));
-
-seclist.setDataSource$({
- numberOfSectionsInSectionList$: function(list) {
- return sections.length;
- },
-
- sectionList$titleForSection$: function(list, section) {
- return sections[section].title;
- },
-
- sectionList$rowForSection$: function(list, section) {
- return sections[section].row;
- },
-
- numberOfRowsInTable$: function(table) {
- return contacts.length;
- },
-
- table$cellForRow$column$: function(table, row, col) {
- var contact = contacts[row];
- if (contact.cell != null)
- return contact.cell;
- var cell = new obc.UIImageAndTextTableCell().init();
- cell.setTitle$(getName(contact));
- contact.cell = cell;
- return cell;
- }
-});
-
-seclist.reloadData();
+var lower = new obc.CGRect(0, navsize.height, inner.size.width, inner.size.height - navsize.height);
+var list = new obc.UISectionList().initWithFrame$(lower);
+view.addSubview$(list);
var col = new obc.UITableColumn().initWithTitle$identifier$width$("Name", "name", 320);
-var table = seclist.table();
+var table = list.table();
table.setSeparatorStyle$(1);
table.addTableColumn$(col);
+table.setReusesTableCells$(YES);
-var view = new obc.UIView().initWithFrame$(inner);
-view.addSubview$(navbar);
-view.addSubview$(seclist);
-
-window.setContentView$(view);
-
-/* XXX: this works around a VM bug and will be removed */
-java.lang.Class.forName("osx.Celestial");
+list.setDataSource$(this);
+list.reloadData();
var controller = new obc.AVController().init();
var wavfile = obc.NSBundle().mainBundle().pathForResource$ofType$("start", "wav")
diff --git a/data/iphone-java/_metadata/version b/data/iphone-java/_metadata/version
index d0f8e9054..c6756badb 100644
--- a/data/iphone-java/_metadata/version
+++ b/data/iphone-java/_metadata/version
@@ -1 +1 @@
-1.0.2334
+1.0.2357
diff --git a/data/iphone-java/make.sh b/data/iphone-java/make.sh
index 9d8493ded..001923dfb 100644
--- a/data/iphone-java/make.sh
+++ b/data/iphone-java/make.sh
@@ -1,5 +1,5 @@
pkg: mkdir /Applications
-javac -source 1.5 -d . -cp "$(PKG_DATA_ jocstrap)/jocstrap.jar:$(PKG_WORK_ javasqlite)/javasqlite-20071108/sqlite.jar" "${PKG_DATA}/HelloJava.app/HelloJava.java"
+javac -source 1.5 -d . -cp "$(PKG_DATA_ jocstrap)/jocstrap.jar:$(PKG_WORK_ javasqlite)/javasqlite-20080130/sqlite.jar" "${PKG_DATA}/HelloJava.app/HelloJava.java"
pkg: cp -a %/Hello{Java,Script}.app /Applications
cp -a *.class "${PKG_DEST}/Applications/HelloJava.app"
pkg: find / -name '.svn' -prune -exec rm -rfv {} \;
diff --git a/data/jocstrap/_metadata/version b/data/jocstrap/_metadata/version
index 1ada67b39..3a8c7189a 100644
--- a/data/jocstrap/_metadata/version
+++ b/data/jocstrap/_metadata/version
@@ -1 +1 @@
-1.0.2306
+1.0.2358
diff --git a/data/jocstrap/jocstrap.jar b/data/jocstrap/jocstrap.jar
index d6930e106..75c32aafc 100644
--- a/data/jocstrap/jocstrap.jar
+++ b/data/jocstrap/jocstrap.jar
Binary files differ
diff --git a/data/jocstrap/libjocstrap.jnilib b/data/jocstrap/libjocstrap.jnilib
index cc868d987..7b063c2da 100755
--- a/data/jocstrap/libjocstrap.jnilib
+++ b/data/jocstrap/libjocstrap.jnilib
Binary files differ
diff --git a/data/uicaboodle/_metadata/version b/data/uicaboodle/_metadata/version
index fa9491111..6ff86d092 100644
--- a/data/uicaboodle/_metadata/version
+++ b/data/uicaboodle/_metadata/version
@@ -1 +1 @@
-1.0.2343
+1.0.2359
diff --git a/data/uicaboodle/libuicaboodle.jnilib b/data/uicaboodle/libuicaboodle.jnilib
index 2e692c2b9..fcd2f1cb8 100755
--- a/data/uicaboodle/libuicaboodle.jnilib
+++ b/data/uicaboodle/libuicaboodle.jnilib
Binary files differ
diff --git a/data/uicaboodle/uicaboodle.jar b/data/uicaboodle/uicaboodle.jar
index 4769b254f..3c56ceec3 100644
--- a/data/uicaboodle/uicaboodle.jar
+++ b/data/uicaboodle/uicaboodle.jar
Binary files differ