[macruby-changes] [665] MacRuby/branches/macruby64
source_changes at macosforge.org
source_changes at macosforge.org
Sat Oct 18 23:14:48 PDT 2008
Revision: 665
http://trac.macosforge.org/projects/ruby/changeset/665
Author: lsansonetti at apple.com
Date: 2008-10-18 23:14:48 -0700 (Sat, 18 Oct 2008)
Log Message:
-----------
apply first 64-bit work patch
Modified Paths:
--------------
MacRuby/branches/macruby64/Rakefile
MacRuby/branches/macruby64/bs.c
MacRuby/branches/macruby64/class.c
MacRuby/branches/macruby64/encoding.c
MacRuby/branches/macruby64/include/ruby/defines.h
MacRuby/branches/macruby64/include/ruby/ruby.h
MacRuby/branches/macruby64/marshal.c
MacRuby/branches/macruby64/objc.m
MacRuby/branches/macruby64/object.c
MacRuby/branches/macruby64/regexec.c
MacRuby/branches/macruby64/thread.c
MacRuby/branches/macruby64/variable.c
MacRuby/branches/macruby64/version.h
MacRuby/branches/macruby64/vm_insnhelper.c
Modified: MacRuby/branches/macruby64/Rakefile
===================================================================
--- MacRuby/branches/macruby64/Rakefile 2008-10-19 05:52:49 UTC (rev 664)
+++ MacRuby/branches/macruby64/Rakefile 2008-10-19 06:14:48 UTC (rev 665)
@@ -1,4 +1,6 @@
# User customizable variables.
+# These variables can be set from the command line. Example:
+# $ rake build_as_embeddable=true
def do_option(name, default)
val = ENV[name]
@@ -15,7 +17,7 @@
RUBY_INSTALL_NAME = do_option('ruby_install_name', 'macruby')
RUBY_SO_NAME = do_option('ruby_so_name', RUBY_INSTALL_NAME)
-ARCHS = do_option('archs', %w{ppc i386}) { |x| x.split(',') }
+ARCHS = do_option('archs', `arch`.include?('ppc') ? 'ppc' : %w{i386 x86_64}) { |x| x.split(',') }
FRAMEWORK_NAME = do_option('framework_name', 'MacRuby')
FRAMEWORK_INSTDIR = do_option('framework_instdir', '/Library/Frameworks')
NO_WARN_BUILD = !do_option('allow_build_warnings', false)
@@ -25,8 +27,17 @@
# TODO: we should find a way to document these options in rake's --help
-# Everything below this comment should *not* be customized.
+# Everything below this comment should *not* be modified.
+if `sw_vers -productVersion`.strip.to_f < 10.5
+ $stderr.puts "Sorry, your environment is not supported. MacRuby requires Mac OS X 10.5 or higher."
+ exit 1
+end
+
+if `arch`.strip.match(/^(i386|x86_64)$/).nil?
+ $stderr.puts "Warning: your appear to use a PowerPC machine. MacRuby's PPC support is very basic and may be dropped in a near future. Supported architectures are Intel 32-bit and 64-bit (i386 and x86_64)."
+end
+
version_h = File.read('version.h')
NEW_RUBY_VERSION = version_h.scan(/#\s*define\s+RUBY_VERSION\s+\"([^"]+)\"/)[0][0]
MACRUBY_VERSION = version_h.scan(/#\s*define\s+MACRUBY_VERSION\s+(.*)/)[0][0]
Modified: MacRuby/branches/macruby64/bs.c
===================================================================
--- MacRuby/branches/macruby64/bs.c 2008-10-19 05:52:49 UTC (rev 664)
+++ MacRuby/branches/macruby64/bs.c 2008-10-19 06:14:48 UTC (rev 665)
@@ -252,7 +252,7 @@
p_src = pos + 1;
pos = strchr(p_src, '"');
if (pos == NULL) {
- fprintf(stderr, "Can't find the end of field delimiter starting at %d\n", p_src - src);
+ fprintf(stderr, "Can't find the end of field delimiter starting at %d\n", (int)(p_src - src));
goto bails;
}
if (field != NULL) {
@@ -307,7 +307,7 @@
}
if (ok == false) {
- fprintf(stderr, "Can't find the field encoding starting at %d\n", p_src - src);
+ fprintf(stderr, "Can't find the field encoding starting at %d\n", (int)(p_src - src));
goto bails;
}
Modified: MacRuby/branches/macruby64/class.c
===================================================================
--- MacRuby/branches/macruby64/class.c 2008-10-19 05:52:49 UTC (rev 664)
+++ MacRuby/branches/macruby64/class.c 2008-10-19 06:14:48 UTC (rev 665)
@@ -153,7 +153,7 @@
version_flag |= RCLASS_IS_OBJECT_SUBCLASS;
}
- class_setVersion(ocklass, version_flag);
+ RCLASS_SET_VERSION(ocklass, version_flag);
DLOG("DEFC", "%s < %s (version=%d)", ocname, class_getName(class_getSuperclass((Class)ocklass)), version_flag);
@@ -230,13 +230,14 @@
else {
super = RCLASS_SUPER(orig);
}
- RCLASS_SUPER(clone) = super;
+ RCLASS_SET_SUPER(clone, super);
version_flag = RCLASS_IS_RUBY_CLASS;
- if ((RCLASS_VERSION(super) & RCLASS_IS_OBJECT_SUBCLASS) == RCLASS_IS_OBJECT_SUBCLASS)
+ if ((RCLASS_VERSION(super) & RCLASS_IS_OBJECT_SUBCLASS) == RCLASS_IS_OBJECT_SUBCLASS) {
version_flag |= RCLASS_IS_OBJECT_SUBCLASS;
+ }
- class_setVersion((Class)clone, version_flag);
+ RCLASS_SET_VERSION(clone, version_flag);
}
#if 0 // TODO
if (RCLASS_IV_TBL(orig)) {
@@ -315,7 +316,8 @@
rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)clone);
if (RCLASS_SUPER(clone) == rb_cNSObject) {
- RCLASS_VERSION(clone) ^= RCLASS_IS_OBJECT_SUBCLASS;
+ long v = RCLASS_VERSION(clone) ^ RCLASS_IS_OBJECT_SUBCLASS;
+ RCLASS_SET_VERSION(clone, v);
}
RCLASS_SET_VERSION_FLAG(clone, RCLASS_IS_SINGLETON);
@@ -347,7 +349,8 @@
klass = rb_class_boot(super);
RBASIC(obj)->klass = klass;
if (super == rb_cNSObject) {
- RCLASS_VERSION(klass) ^= RCLASS_IS_OBJECT_SUBCLASS;
+ long v = RCLASS_VERSION(klass) ^ RCLASS_IS_OBJECT_SUBCLASS;
+ RCLASS_SET_VERSION(klass, v);
}
RCLASS_SET_VERSION_FLAG(klass, RCLASS_IS_SINGLETON);
@@ -447,11 +450,13 @@
mdl = rb_objc_alloc_class(id == 0 ? NULL : rb_id2name(id), rb_cObject, T_MODULE, rb_cModule);
objc_registerClassPair((Class)mdl);
+#if 0
if (rb_mKernel != 0) {
/* because Module#initialize can accept a block */
extern VALUE rb_mod_initialize(VALUE);
rb_define_method(*(VALUE *)mdl, "initialize", rb_mod_initialize, 0);
}
+#endif
return mdl;
}
@@ -498,18 +503,18 @@
}
void
-rb_include_module(VALUE klass, VALUE module)
+rb_include_module2(VALUE klass, VALUE module, int check, int add_methods)
{
- Method *methods;
- unsigned int i, methods_count;
VALUE ary;
- rb_frozen_class_p(klass);
+ if (check) {
+ rb_frozen_class_p(klass);
- if (!OBJ_TAINTED(klass))
- rb_secure(4);
+ if (!OBJ_TAINTED(klass))
+ rb_secure(4);
- Check_Type(module, T_MODULE);
+ Check_Type(module, T_MODULE);
+ }
ary = rb_attr_get(klass, idIncludedModules);
if (ary == Qnil) {
@@ -520,6 +525,9 @@
return;
rb_ary_insert(ary, 0, module);
+ long v = RCLASS_VERSION(module) | RCLASS_IS_INCLUDED;
+ RCLASS_SET_VERSION(module, v);
+
ary = rb_attr_get(module, idIncludedInClasses);
if (ary == Qnil) {
ary = rb_ary_new();
@@ -529,27 +537,39 @@
DLOG("INCM", "%s <- %s", class_getName((Class)klass), class_getName((Class)module));
- methods = class_copyMethodList((Class)module, &methods_count);
- if (methods != NULL) {
- for (i = 0; i < methods_count; i++) {
- Method method = methods[i], method2;
- DLOG("DEFI", "-[%s %s]", class_getName((Class)klass), (char *)method_getName(method));
-
- method2 = class_getInstanceMethod((Class)klass, method_getName(method));
- if (method2 != NULL && method2 != class_getInstanceMethod((Class)RCLASS_SUPER(klass), method_getName(method))) {
- method_setImplementation(method2, method_getImplementation(method));
+ if (add_methods) {
+ Method *methods;
+ unsigned int i, methods_count;
+
+ methods = class_copyMethodList((Class)module, &methods_count);
+ if (methods != NULL) {
+ for (i = 0; i < methods_count; i++) {
+ Method method = methods[i], method2;
+ DLOG("DEFI", "-[%s %s]", class_getName((Class)klass), (char *)method_getName(method));
+
+ method2 = class_getInstanceMethod((Class)klass, method_getName(method));
+ if (method2 != NULL && method2 != class_getInstanceMethod((Class)RCLASS_SUPER(klass), method_getName(method))) {
+ method_setImplementation(method2, method_getImplementation(method));
+ }
+ else {
+ assert(class_addMethod((Class)klass,
+ method_getName(method),
+ method_getImplementation(method),
+ method_getTypeEncoding(method)));
+ }
}
- else {
- assert(class_addMethod((Class)klass,
- method_getName(method),
- method_getImplementation(method),
- method_getTypeEncoding(method)));
- }
+ free(methods);
}
- free(methods);
}
}
+void
+rb_include_module(VALUE klass, VALUE module)
+{
+ rb_include_module2(klass, module, 1, 1);
+}
+
+
/*
* call-seq:
* mod.included_modules -> array
@@ -673,31 +693,31 @@
}
static int
-ins_methods_i(VALUE name, long type, VALUE ary)
+ins_methods_i(VALUE name, ID type, VALUE ary)
{
return ins_methods_push(name, type, ary, -1); /* everything but private */
}
static int
-ins_methods_prot_i(VALUE name, long type, VALUE ary)
+ins_methods_prot_i(VALUE name, ID type, VALUE ary)
{
return ins_methods_push(name, type, ary, NOEX_PROTECTED);
}
static int
-ins_methods_priv_i(VALUE name, long type, VALUE ary)
+ins_methods_priv_i(VALUE name, ID type, VALUE ary)
{
return ins_methods_push(name, type, ary, NOEX_PRIVATE);
}
static int
-ins_methods_pub_i(VALUE name, long type, VALUE ary)
+ins_methods_pub_i(VALUE name, ID type, VALUE ary)
{
return ins_methods_push(name, type, ary, NOEX_PUBLIC);
}
static void
-rb_objc_push_methods(VALUE ary, VALUE mod, VALUE objc_methods, int (*func) (VALUE, long, VALUE))
+rb_objc_push_methods(VALUE ary, VALUE mod, VALUE objc_methods, int (*func) (VALUE, ID, VALUE))
{
Method *methods;
unsigned int i, count;
@@ -798,7 +818,7 @@
}
static VALUE
-class_instance_method_list(int argc, VALUE *argv, VALUE mod, int (*func) (ID, long, VALUE))
+class_instance_method_list(int argc, VALUE *argv, VALUE mod, int (*func) (VALUE, ID, VALUE))
{
VALUE ary;
VALUE recur, objc_methods;
Modified: MacRuby/branches/macruby64/encoding.c
===================================================================
--- MacRuby/branches/macruby64/encoding.c 2008-10-19 05:52:49 UTC (rev 664)
+++ MacRuby/branches/macruby64/encoding.c 2008-10-19 06:14:48 UTC (rev 665)
@@ -68,7 +68,7 @@
}
rb_define_const(rb_cEncoding, name, encoding);
}
- CFDictionarySetValue(__encodings, (const void *)(*e),
+ CFDictionarySetValue(__encodings, (const void *)iana,
(const void *)encoding);
e++;
}
@@ -79,10 +79,12 @@
static VALUE
enc_make(const CFStringEncoding *enc)
{
- VALUE v;
+ VALUE iana, v;
+
assert(enc != NULL);
- v = (VALUE)CFDictionaryGetValue( (CFDictionaryRef)__encodings,
- (const void *)(*enc));
+ iana = (VALUE)CFStringConvertEncodingToIANACharSetName(*enc);
+ v = (VALUE)CFDictionaryGetValue((CFDictionaryRef)__encodings,
+ (const void *)iana);
assert(v != 0);
return v;
}
Modified: MacRuby/branches/macruby64/include/ruby/defines.h
===================================================================
--- MacRuby/branches/macruby64/include/ruby/defines.h 2008-10-19 05:52:49 UTC (rev 664)
+++ MacRuby/branches/macruby64/include/ruby/defines.h 2008-10-19 06:14:48 UTC (rev 665)
@@ -295,7 +295,17 @@
# define ASSERT_NO_OBJC() (assert(1 == 0))
void rb_objc_wb(void *dst, void *newval);
void rb_objc_root(void *addr);
-# define GC_WB(dst, newval) (SPECIAL_CONST_P(newval) ? *(void **)dst = (void *)newval : rb_objc_wb((void *)dst, (void *)newval))
+# define GC_WB(dst, newval) \
+ do { \
+ void *nv = (void *)newval; \
+ if (SPECIAL_CONST_P(nv)) { \
+ *(void **)dst = nv; \
+ } \
+ else { \
+ rb_objc_wb((void *)dst, (void *)newval); \
+ } \
+ } \
+ while (0)
# define GC_ROOT(dst) (rb_objc_root((void *)dst))
# define GC_WEAK(dst) (rb_objc_weak((void *)dst))
#else
Modified: MacRuby/branches/macruby64/include/ruby/ruby.h
===================================================================
--- MacRuby/branches/macruby64/include/ruby/ruby.h 2008-10-19 05:52:49 UTC (rev 664)
+++ MacRuby/branches/macruby64/include/ruby/ruby.h 2008-10-19 06:14:48 UTC (rev 665)
@@ -92,7 +92,11 @@
#if SIZEOF_LONG == SIZEOF_VOIDP
typedef unsigned long VALUE;
+#if WITH_OBJC
+#define ID unsigned long
+#else
typedef unsigned long ID;
+#endif
# define SIGNED_VALUE long
# define SIZEOF_VALUE SIZEOF_LONG
# define PRIdVALUE "ld"
@@ -505,15 +509,20 @@
# define RCLASS_IS_STRING_SUBCLASS 0x10000 /* class is a subclass of NSCFString */
# define RCLASS_IS_ARRAY_SUBCLASS 0x20000 /* class is a subclass of NSCFArray */
# define RCLASS_IS_HASH_SUBCLASS 0x40000 /* class is a subclass of NSCFDictionary */
-# if __OBJC2__
+# define RCLASS_IS_INCLUDED 0x80000 /* module is included */
+# if defined(__LP64__)
# define RCLASS_VERSION(m) (class_getVersion((Class)m))
+# define RCLASS_SET_VERSION(m,f) (class_setVersion((Class)m, f))
# define RCLASS_SET_VERSION_FLAG(m,f) (class_setVersion((Class)m, (RCLASS_VERSION(m) | f)))
-# define RCLASS_SUPER(m) (class_getSuperclass((Class)m))
-# define RCLASS_META(m) (class_isMetaclass((Class)m))
+# define RCLASS_SUPER(m) (*(VALUE *)((void *)m + (sizeof(void *) * 1)))
+# define RCLASS_SET_SUPER(m, s) (class_setSuperclass((Class)m, (Class)s))
+# define RCLASS_META(m) (class_isMetaClass((Class)m))
# else
# define RCLASS_VERSION(m) (*(long *)((void *)m + (sizeof(void *) * 3)))
+# define RCLASS_SET_VERSION(m,f) do { RCLASS_VERSION(m) = f; } while (0)
# define RCLASS_SET_VERSION_FLAG(m,f) (RCLASS_VERSION(m) |= f)
# define RCLASS_SUPER(m) (*(VALUE *)((void *)m + (sizeof(void *) * 1)))
+# define RCLASS_SET_SUPER(m, s) (RCLASS_SUPER(m) = s)
# define _RCLASS_INFO(m) (*(long *)((void *)m + (sizeof(void *) * 4)))
# define RCLASS_META(m) (_RCLASS_INFO(m) & CLS_META)
# endif
@@ -816,7 +825,7 @@
#define FL_REVERSE(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags ^= (f);} while (0)
#if WITH_OBJC
-# define OBJ_TAINTED(x) (SPECIAL_CONST_P(x) || NATIVE(x) ? rb_obj_tainted((VALUE)x) : FL_TEST((x), FL_TAINT))
+# define OBJ_TAINTED(x) (int)(SPECIAL_CONST_P(x) || NATIVE(x) ? rb_obj_tainted((VALUE)x) == Qtrue : FL_TEST((x), FL_TAINT))
# define OBJ_TAINT(x) (rb_obj_taint((VALUE)x))
#else
# define OBJ_TAINTED(x) FL_TEST((x), FL_TAINT)
@@ -826,7 +835,7 @@
#define OBJ_INFECT(x,s) do {if (FL_ABLE(x) && FL_ABLE(s)) RBASIC(x)->flags |= RBASIC(s)->flags & FL_TAINT;} while (0)
#if WITH_OBJC
-# define OBJ_FROZEN(x) (SPECIAL_CONST_P(x) || NATIVE(x) ? rb_obj_frozen_p((VALUE)x) : FL_TEST((x), FL_FREEZE))
+# define OBJ_FROZEN(x) (int)(SPECIAL_CONST_P(x) || NATIVE(x) ? rb_obj_frozen_p((VALUE)x) == Qtrue : FL_TEST((x), FL_FREEZE))
# define OBJ_FREEZE(x) (rb_obj_freeze((VALUE)x))
#else
# define OBJ_FROZEN(x) FL_TEST((x), FL_FREEZE)
Modified: MacRuby/branches/macruby64/marshal.c
===================================================================
--- MacRuby/branches/macruby64/marshal.c 2008-10-19 05:52:49 UTC (rev 664)
+++ MacRuby/branches/macruby64/marshal.c 2008-10-19 06:14:48 UTC (rev 665)
@@ -1095,7 +1095,7 @@
ID id;
long num = r_long(arg);
- if (st_lookup(arg->symbols, num, &id)) {
+ if (st_lookup(arg->symbols, num, (st_data_t *)&id)) {
return id;
}
rb_raise(rb_eArgError, "bad symbol");
Modified: MacRuby/branches/macruby64/objc.m
===================================================================
--- MacRuby/branches/macruby64/objc.m 2008-10-19 05:52:49 UTC (rev 664)
+++ MacRuby/branches/macruby64/objc.m 2008-10-19 06:14:48 UTC (rev 665)
@@ -26,6 +26,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <Foundation/Foundation.h>
#include "ruby/ruby.h"
#include "ruby/node.h"
#include "ruby/encoding.h"
@@ -33,7 +34,7 @@
#include <unistd.h>
#include <dlfcn.h>
#include <mach-o/dyld.h>
-#include <Foundation/Foundation.h>
+#include <sys/mman.h>
#if HAVE_BRIDGESUPPORT_FRAMEWORK
# include <BridgeSupport/BridgeSupport.h>
#else
@@ -367,7 +368,7 @@
bs_boxed->ffi_type->alignment = 0;
bs_boxed->ffi_type->type = FFI_TYPE_STRUCT;
bs_boxed->ffi_type->elements = malloc(
- (bs_struct->fields_count) * sizeof(ffi_type *));
+ (bs_struct->fields_count + 1) * sizeof(ffi_type *));
for (i = 0; i < bs_struct->fields_count; i++) {
bs_element_struct_field_t *field = &bs_struct->fields[i];
@@ -1174,7 +1175,11 @@
if (klass == RCLASS_SUPER(*(Class *)ocrcv)) {
struct objc_super s;
s.receiver = ocrcv;
+#if defined(__LP64__)
+ s.super_class = (Class)klass;
+#else
s.class = (Class)klass;
+#endif
ffi_ret = objc_msgSendSuper(&s, sel);
}
else {
@@ -1397,7 +1402,8 @@
name_sel = sel_registerName(name_str);
def_sel = sel_registerName(def_str);
- included_in_classes = RCLASS_MODULE(klass) ? rb_attr_get(klass, idIncludedInClasses) : Qnil;
+ included_in_classes = RCLASS_VERSION(klass) & RCLASS_IS_INCLUDED
+ ? rb_attr_get(klass, idIncludedInClasses) : Qnil;
method = class_getInstanceMethod((Class)klass, def_sel);
if (method == NULL) {
@@ -1472,7 +1478,9 @@
redo = true;
goto alias_method;
}
- }
+ }
+
+#undef forward_method_definition
}
static VALUE
@@ -1541,8 +1549,8 @@
NODE *body, *node;
bs_element_method_t *bs_method;
- rcv = (*(id **)args)[0];
- sel = (*(SEL **)args)[1];
+ rcv = *(id *)args[0];
+ sel = *(SEL *)args[1];
body = (NODE *)userdata;
node = body->nd_body;
@@ -1651,10 +1659,18 @@
rb_fatal("can't prepare ruby to objc cif");
closure = (ffi_closure *)malloc(sizeof(ffi_closure));
+
+ if ((closure = mmap(NULL, sizeof(ffi_closure), PROT_READ | PROT_WRITE,
+ MAP_ANON | MAP_PRIVATE, -1, 0)) == (void *)-1)
+ rb_fatal("can't allocate ruby to objc closure");
+
if (ffi_prep_closure(closure, cif, rb_ruby_to_objc_closure_handler, node)
!= FFI_OK)
rb_fatal("can't prepare ruby to objc closure");
+ if (mprotect(closure, sizeof(closure), PROT_READ | PROT_EXEC) == -1)
+ rb_fatal("can't mprotect the ruby to objc closure");
+
rb_objc_retain(node);
return closure;
@@ -1807,7 +1823,8 @@
}
}
- included_in_classes = RCLASS_MODULE(mod) ? rb_attr_get(mod, idIncludedInClasses) : Qnil;
+ included_in_classes = RCLASS_VERSION(mod) & RCLASS_IS_INCLUDED
+ ? rb_attr_get(mod, idIncludedInClasses) : Qnil;
direct_override = false;
method = class_getInstanceMethod((Class)mod, sel);
@@ -2295,11 +2312,15 @@
&ffi_type_pointer, args) != FFI_OK)
rb_fatal("can't prepare struct_reader_cif");
}
- closure = (ffi_closure *)malloc(sizeof(ffi_closure));
+ if ((closure = mmap(NULL, sizeof(ffi_closure), PROT_READ | PROT_WRITE,
+ MAP_ANON | MAP_PRIVATE, -1, 0)) == (void *)-1)
+ rb_fatal("can't allocate struct reader closure");
if (ffi_prep_closure(closure, struct_reader_cif,
rb_struct_reader_closure_handler, ctx)
!= FFI_OK)
rb_fatal("can't prepare struct reader closure");
+ if (mprotect(closure, sizeof(closure), PROT_READ | PROT_EXEC) == -1)
+ rb_fatal("can't mprotect struct reader closure");
rb_define_method(klass, field->name, (VALUE(*)(ANYARGS))closure, 0);
@@ -2314,11 +2335,15 @@
&ffi_type_pointer, args) != FFI_OK)
rb_fatal("can't prepare struct_writer_cif");
}
- closure = (ffi_closure *)malloc(sizeof(ffi_closure));
+ if ((closure = mmap(NULL, sizeof(ffi_closure), PROT_READ | PROT_WRITE,
+ MAP_ANON | MAP_PRIVATE, -1, 0)) == (void *)-1)
+ rb_fatal("can't allocate struct writer closure");
if (ffi_prep_closure(closure, struct_writer_cif,
rb_struct_writer_closure_handler, ctx)
!= FFI_OK)
rb_fatal("can't prepare struct writer closure");
+ if (mprotect(closure, sizeof(closure), PROT_READ | PROT_EXEC) == -1)
+ rb_fatal("can't mprotect struct writer closure");
snprintf(buf, sizeof buf, "%s=", field->name);
rb_define_method(klass, buf, (VALUE(*)(ANYARGS))closure, 1);
@@ -3154,8 +3179,8 @@
return fmt;
types = (char **)alloca(sizeof(char *) * argc);
- ffi_argtypes = (ffi_type **)alloca(sizeof(ffi_type *) * argc + 4);
- ffi_args = (void **)alloca(sizeof(void *) * argc + 4);
+ ffi_argtypes = (ffi_type **)alloca(sizeof(ffi_type *) * (argc + 4));
+ ffi_args = (void **)alloca(sizeof(void *) * (argc + 4));
null = NULL;
new_fmt = NULL;
@@ -3234,11 +3259,12 @@
rb_obj_imp_isaForAutonotifying(void *rcv, SEL sel)
{
Class ret;
+ long ret_version;
#define KVO_CHECK_DONE 0x100000
ret = ((Class (*)(void *, SEL)) old_imp_isaForAutonotifying)(rcv, sel);
- if (ret != NULL && (RCLASS_VERSION(ret) & KVO_CHECK_DONE) == 0) {
+ if (ret != NULL && ((ret_version = RCLASS_VERSION(ret)) & KVO_CHECK_DONE) == 0) {
const char *name = class_getName(ret);
if (strncmp(name, "NSKVONotifying_", 15) == 0) {
Class ret_orig;
@@ -3246,10 +3272,11 @@
ret_orig = objc_getClass(name);
if (ret_orig != NULL && RCLASS_VERSION(ret_orig) & RCLASS_IS_OBJECT_SUBCLASS) {
DLOG("XXX", "marking KVO generated klass %p (%s) as RObject", ret, class_getName(ret));
- RCLASS_VERSION(ret) |= RCLASS_IS_OBJECT_SUBCLASS;
+ ret_version |= RCLASS_IS_OBJECT_SUBCLASS;
}
}
- RCLASS_VERSION(ret) |= KVO_CHECK_DONE;
+ ret_version |= KVO_CHECK_DONE;
+ RCLASS_SET_VERSION(ret, ret_version);
}
return ret;
}
@@ -3301,6 +3328,7 @@
// for debug in gdb
int __rb_type(VALUE v) { return TYPE(v); }
+int __rb_native(VALUE v) { return NATIVE(v); }
@interface Protocol
@end
Modified: MacRuby/branches/macruby64/object.c
===================================================================
--- MacRuby/branches/macruby64/object.c 2008-10-19 05:52:49 UTC (rev 664)
+++ MacRuby/branches/macruby64/object.c 2008-10-19 06:14:48 UTC (rev 665)
@@ -1464,9 +1464,10 @@
rb_scan_args(argc, argv, "01", &super);
rb_check_inheritable(super);
}
- RCLASS_SUPER(klass) = super;
+ RCLASS_SET_SUPER(klass, super);
if ((RCLASS_VERSION(super) & RCLASS_IS_OBJECT_SUBCLASS) != RCLASS_IS_OBJECT_SUBCLASS) {
- RCLASS_VERSION(klass) ^= RCLASS_IS_OBJECT_SUBCLASS;
+ long v = RCLASS_VERSION(klass) ^ RCLASS_IS_OBJECT_SUBCLASS;
+ RCLASS_SET_VERSION(klass, v);
}
rb_objc_install_primitives((Class)klass, (Class)super);
if (super == rb_cObject)
@@ -2464,10 +2465,14 @@
rb_const_set(rb_cObject, rb_intern("Object"), rb_cNSObject);
rb_set_class_path(rb_cObject, rb_cObject, "NSObject");
rb_cBasicObject = (VALUE)objc_duplicateClass((Class)rb_cObject, "BasicObject", 0);
- rb_cModule = boot_defclass("Module", rb_cObject);
+ rb_cModule = boot_defclass("Module", rb_cNSObject);
rb_cClass = boot_defclass("Class", rb_cModule);
- RCLASS_SUPER(*(Class *)rb_cNSObject) = rb_cClass;
+ void rb_include_module2(VALUE klass, VALUE module, int check, int add_methods);
+
+ rb_include_module2(*(VALUE *)rb_cNSObject, rb_cClass, 0, 0);
+ rb_include_module2(*(VALUE *)rb_cNSObject, rb_cModule, 0, 0);
+
rb_define_private_method(rb_cNSObject, "initialize", rb_obj_dummy, 0);
rb_define_method(rb_cNSObject, "==", rb_obj_equal, 1);
rb_define_method(rb_cNSObject, "equal?", rb_obj_equal, 1);
@@ -2603,7 +2608,7 @@
rb_define_method(rb_cModule, "class_variable_defined?", rb_mod_cvar_defined, 1);
rb_define_method(rb_cClass, "allocate", rb_obj_alloc, 0);
- rb_define_method(rb_cClass, "new", rb_class_new_instance, -1);
+ /*rb_define_method(rb_cClass, "new", rb_class_new_instance, -1);*/
rb_define_method(rb_cClass, "initialize_copy", rb_class_init_copy, 1); /* in class.c */
rb_define_alloc_func(rb_cClass, rb_class_s_alloc);
rb_undef_method(rb_cClass, "extend_object");
Modified: MacRuby/branches/macruby64/regexec.c
===================================================================
--- MacRuby/branches/macruby64/regexec.c 2008-10-19 05:52:49 UTC (rev 664)
+++ MacRuby/branches/macruby64/regexec.c 2008-10-19 06:14:48 UTC (rev 665)
@@ -272,8 +272,8 @@
onig_region_resize(to, from->num_regs);
for (i = 0; i < from->num_regs; i++) {
- GC_WB(&to->beg[i], from->beg[i]);
- GC_WB(&to->end[i], from->end[i]);
+ to->beg[i] = from->beg[i];
+ to->end[i] = from->end[i];
}
to->num_regs = from->num_regs;
Modified: MacRuby/branches/macruby64/thread.c
===================================================================
--- MacRuby/branches/macruby64/thread.c 2008-10-19 05:52:49 UTC (rev 664)
+++ MacRuby/branches/macruby64/thread.c 2008-10-19 06:14:48 UTC (rev 665)
@@ -1886,6 +1886,10 @@
int result, lerrno;
fd_set orig_read, orig_write, orig_except;
+ bzero(&orig_read, sizeof(fd_set));
+ bzero(&orig_write, sizeof(fd_set));
+ bzero(&orig_except, sizeof(fd_set));
+
#ifndef linux
double limit = 0;
struct timeval wait_rest;
Modified: MacRuby/branches/macruby64/variable.c
===================================================================
--- MacRuby/branches/macruby64/variable.c 2008-10-19 05:52:49 UTC (rev 664)
+++ MacRuby/branches/macruby64/variable.c 2008-10-19 06:14:48 UTC (rev 665)
@@ -349,7 +349,7 @@
}
if (!rb_const_defined(c, id)) {
undefined_class:
- rb_raise(rb_eArgError, "undefined class/module %.*s", p-path, path);
+ rb_raise(rb_eArgError, "undefined class/module %.*s", (int)(p-path), path);
}
c = rb_const_get_at(c, id);
switch (TYPE(c)) {
Modified: MacRuby/branches/macruby64/version.h
===================================================================
--- MacRuby/branches/macruby64/version.h 2008-10-19 05:52:49 UTC (rev 664)
+++ MacRuby/branches/macruby64/version.h 2008-10-19 06:14:48 UTC (rev 665)
@@ -53,11 +53,24 @@
#if WITH_OBJC
# define MACRUBY_VERSION 0.4
+# if defined(__LP64__)
+# if BYTE_ORDER == BIG_ENDIAN
+# define RUBY_ARCH "ppc64"
+# else
+# define RUBY_ARCH "x86_64"
+# endif
+# else
+# if BYTE_ORDER == BIG_ENDIAN
+# define RUBY_ARCH "ppc"
+# else
+# define RUBY_ARCH "i386"
+# endif
+# endif
# define RUBY_DESCRIPTION \
"MacRuby version " STRINGIZE(MACRUBY_VERSION) \
" (ruby "RUBY_VERSION \
" "RUBY_RELEASE_DATE")" \
- " ["RUBY_PLATFORM"]"
+ " ["RUBY_PLATFORM", "RUBY_ARCH"]"
#else
# define RUBY_DESCRIPTION \
"ruby "RUBY_VERSION \
Modified: MacRuby/branches/macruby64/vm_insnhelper.c
===================================================================
--- MacRuby/branches/macruby64/vm_insnhelper.c 2008-10-19 05:52:49 UTC (rev 664)
+++ MacRuby/branches/macruby64/vm_insnhelper.c 2008-10-19 06:14:48 UTC (rev 665)
@@ -1491,9 +1491,9 @@
imod = RARRAY_AT(ary, i);
saved_imod_super = RCLASS_SUPER(imod);
- RCLASS_SUPER(imod) = 0;
+ RCLASS_SET_SUPER(imod, 0);
mn = rb_objc_method_node(imod, mid, &imp, &sel);
- RCLASS_SUPER(imod) = saved_imod_super;
+ RCLASS_SET_SUPER(imod, saved_imod_super);
if (imp != NULL) {
rb_ivar_set(imod, idPreviousKlass, klass);
*mnp = mn;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20081018/a8b5dd16/attachment-0001.html
More information about the macruby-changes
mailing list