[macruby-changes] [2000] MacRuby/branches/experimental
source_changes at macosforge.org
source_changes at macosforge.org
Tue Jul 7 19:18:09 PDT 2009
Revision: 2000
http://trac.macosforge.org/projects/ruby/changeset/2000
Author: lsansonetti at apple.com
Date: 2009-07-07 19:18:07 -0700 (Tue, 07 Jul 2009)
Log Message:
-----------
move macruby_main() to C++ land so that it can catch exceptions
Modified Paths:
--------------
MacRuby/branches/experimental/objc.m
MacRuby/branches/experimental/vm.cpp
Modified: MacRuby/branches/experimental/objc.m
===================================================================
--- MacRuby/branches/experimental/objc.m 2009-07-07 15:48:51 UTC (rev 1999)
+++ MacRuby/branches/experimental/objc.m 2009-07-08 02:18:07 UTC (rev 2000)
@@ -411,64 +411,8 @@
return Qtrue;
}
-static const char *
-resources_path(char *path, size_t len)
-{
- CFBundleRef bundle;
- CFURLRef url;
-
- bundle = CFBundleGetMainBundle();
- assert(bundle != NULL);
-
- url = CFBundleCopyResourcesDirectoryURL(bundle);
- *path = '-';
- *(path+1) = 'I';
- assert(CFURLGetFileSystemRepresentation(
- url, true, (UInt8 *)&path[2], len - 2));
- CFRelease(url);
-
- return path;
-}
-
void rb_vm_init_compiler(void);
-int
-macruby_main(const char *path, int argc, char **argv)
-{
- char **newargv;
- char *p1, *p2;
- int n, i;
-
- newargv = (char **)malloc(sizeof(char *) * (argc + 2));
- for (i = n = 0; i < argc; i++) {
- if (!strncmp(argv[i], "-psn_", 5) == 0) {
- newargv[n++] = argv[i];
- }
- }
-
- p1 = (char *)malloc(PATH_MAX);
- newargv[n++] = (char *)resources_path(p1, PATH_MAX);
-
- p2 = (char *)malloc(PATH_MAX);
- snprintf(p2, PATH_MAX, "%s/%s", (path[0] != '/') ? &p1[2] : "", path);
- newargv[n++] = p2;
-
- argv = newargv;
- argc = n;
-
- ruby_sysinit(&argc, &argv);
- {
- void *tree;
- ruby_init();
- tree = ruby_options(argc, argv);
- rb_vm_init_compiler();
- free(newargv);
- free(p1);
- free(p2);
- return ruby_run_node(tree);
- }
-}
-
static void
rb_objc_kvo_setter_imp(void *recv, SEL sel, void *value)
{
Modified: MacRuby/branches/experimental/vm.cpp
===================================================================
--- MacRuby/branches/experimental/vm.cpp 2009-07-07 15:48:51 UTC (rev 1999)
+++ MacRuby/branches/experimental/vm.cpp 2009-07-08 02:18:07 UTC (rev 2000)
@@ -4719,7 +4719,67 @@
return rb_str_new2("main");
}
+static const char *
+resources_path(char *path, size_t len)
+{
+ CFBundleRef bundle;
+ CFURLRef url;
+
+ bundle = CFBundleGetMainBundle();
+ assert(bundle != NULL);
+
+ url = CFBundleCopyResourcesDirectoryURL(bundle);
+ *path = '-';
+ *(path+1) = 'I';
+ assert(CFURLGetFileSystemRepresentation(
+ url, true, (UInt8 *)&path[2], len - 2));
+ CFRelease(url);
+
+ return path;
+}
+
extern "C"
+int
+macruby_main(const char *path, int argc, char **argv)
+{
+ char **newargv;
+ char *p1, *p2;
+ int n, i;
+
+ newargv = (char **)malloc(sizeof(char *) * (argc + 2));
+ for (i = n = 0; i < argc; i++) {
+ if (!strncmp(argv[i], "-psn_", 5) == 0) {
+ newargv[n++] = argv[i];
+ }
+ }
+
+ p1 = (char *)malloc(PATH_MAX);
+ newargv[n++] = (char *)resources_path(p1, PATH_MAX);
+
+ p2 = (char *)malloc(PATH_MAX);
+ snprintf(p2, PATH_MAX, "%s/%s", (path[0] != '/') ? &p1[2] : "", path);
+ newargv[n++] = p2;
+
+ argv = newargv;
+ argc = n;
+
+ try {
+ ruby_sysinit(&argc, &argv);
+ ruby_init();
+ void *tree = ruby_options(argc, argv);
+ rb_vm_init_compiler();
+ free(newargv);
+ free(p1);
+ free(p2);
+ return ruby_run_node(tree);
+ }
+ catch (...) {
+ rb_vm_print_current_exception();
+ exit(1);
+ }
+}
+
+extern "C"
void
Init_VM(void)
{
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090707/a5a50cf0/attachment.html>
More information about the macruby-changes
mailing list