Skip to content

Instantly share code, notes, and snippets.

# YARR!
class Event
def self.[](*attributes)
c = Class.new(Event)
unless attributes.empty?
attributes.each do |attribute|
c.send(:attr_accessor, attribute)
end
@mvr
mvr / gist:214034
Created October 20, 2009 06:03
cpp quine
# ifndef P
# define Q(x, y) x ## y
# define P P
# include __FILE__
# undef Q
# define Q(x, y) Q(x, y)
# endif
Q(#,) ifndef P
Q(# define Q(x, y) x ## y,)
From 50376df951f065a3d462b43a0fd6131eed5c1a0f Mon Sep 17 00:00:00 2001
From: Mitchell Riley <mitchell.v.riley@gmail.com>
Date: Wed, 8 Jul 2009 14:10:34 +1000
Subject: [PATCH] Some fixes for GCC 4.3
---
vm/llvm/inline.cpp | 4 ++--
vm/llvm/inline_primitive.cpp | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/vm/llvm/inline.cpp b/vm/llvm/inline.cpp
index 39174f6..e4eabd7 100644
--- a/vm/llvm/inline.cpp
+++ b/vm/llvm/inline.cpp
@@ -148,12 +148,12 @@ namespace rubinius {
case InstructionSequence::insn_push_int:
val = ops_.constant(Fixnum::from(stream[1]));
break;
- case InstructionSequence::insn_push_literal:
+ case InstructionSequence::insn_push_literal: {
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/mitchell/dev/rubinius/bin/rbx
[Thread debugging using libthread_db enabled]
[New Thread 0xb7d706d0 (LWP 20642)]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb7d706d0 (LWP 20642)]
diff --git a/rakelib/vm.rake b/rakelib/vm.rake
index 0deff79..73e3641 100644
--- a/rakelib/vm.rake
+++ b/rakelib/vm.rake
@@ -665,7 +665,7 @@ file dep_file => EXTERNALS + srcs + hdrs + vm_srcs + generated + %w[vm/gen/instr
includes = INCLUDES.join ' '
flags = FLAGS.join ' '
- flags << " -D__STDC_LIMIT_MACROS"
+ flags << " -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS"
class Class
attr_reader :conditional_methods
def defined_when(name, condition, &method)
@conditional_methods ||= {}
@conditional_methods[name.to_sym] = condition
define_method(name) do
if self.instance_eval(&condition)
self.instance_eval(&method)
#define rb_jgParticleWrap(particle) \
Data_Wrap_Struct(c_jgParticle, NULL, NULL, (particle))
VALUE rb_jgAreaWrap(jgArea *area)
{
VALUE wrappedArea = Data_Wrap_Struct(c_jgArea, NULL, NULL, area);
VALUE *particles = malloc(area->particles->length * sizeof(VALUE));
for(int i = 0; i < area->particles->length; i++)
particles[i] = rb_jgParticleWrap(area->particles->arr[i]);
Running 686 tests.................
In TestBignum::test_from_int:
./vm/test/test_bignum.hpp:31: Error: Expected (2147483647 == obj->to_native()), found (2147483647 != -1879048193)
..
In TestBignum::test_from_long:
./vm/test/test_bignum.hpp:47: Error: Expected (2147483647L == obj->to_long()), found (2147483647 != -1879048193)
In TestBignum::test_from_long_negative:
./vm/test/test_bignum.hpp:53: Error: Expected ((long)0x80000000L == obj->to_long()), found (-? != 0)
In TestBignum::test_from_unsigned_long:
./vm/test/test_bignum.hpp:58: Error: Expected (4294967295LU == obj->to_ulong()), found (4294967295 != 2415919103)
class String
@@words = File.open("dictionary").read.split
def self.words
@@words
end
def is_word?
@@words.include? self
end