Home
Testing 1,2,3... - February 11th, 2005 [entries|archive|friends|userinfo]
djberg96

[ website | Sapphire ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Links
[Links:| Ruby Home RubyForge RAA comp.lang.ruby Ruby Documentation ]

February 11th, 2005

have_enum_member, will travel [Feb. 11th, 2005|09:53 am]
Here's a patch that solves the problem I mentioned in my last journal entry. It will test for the presence of a enum member, and give you a HAVE_ENUM_XXX preprocessor constant you can then use in your extension. I've submitted it for official approval. We'll see what happens. In the meantime, enjoy.

--- mkmf.bak Fri Feb 11 08:30:47 2005
+++ mkmf.rb Fri Feb 11 09:33:47 2005
@@ -552,6 +552,23 @@
end
end

+def have_enum_member(type, member, header = nil, &b)
+ checking_for "#{type}.#{member}" do
+ if try_compile(<<"SRC", &b)
+#{COMMON_HEADERS}
+#{cpp_include(header)}
+/*top*/
+static #{type} t;
+int s = #{member};
+SRC
+ $defs.push(format("-DHAVE_ENUM_%s", member.upcase))
+ true
+ else
+ false
+ end
+ end
+end
+
def have_type(type, header = nil, opt = "", &b)
checking_for type do
header = cpp_include(header)
link2 comments|post comment

If you play with matches [Feb. 11th, 2005|02:49 pm]
I like to create little test scripts when I'm developing code. I don't mean unit tests (although I write those, too). I mean little code snippets where I can just sorta futz around at a whim and see what happens.

A few minutes ago I ran this gem:
require "proc/wait3"

trap("INT"){
   puts "Caught INT"
   exit
}

pid = fork{
   sleep 20
   exit
}

Process.sigsend(Process::P_ALL,pid,"INT")

Can anyone see what's going to happen here? (Hint: nothing good)

Let's just say I'm glad it's Friday and I was about to turn the machine off anyway. ;)
linkpost comment

navigation
[ viewing | February 11th, 2005 ]
[ go | Previous Day|Next Day ]

Advertisement