Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Prepare for C parsing

  • Loading branch information...
commit cbeb43ecf80cb1842d6e5a9880c212544d1eedc5 1 parent 7f6c150
@meh authored
View
1  .gitignore
@@ -0,0 +1 @@
+Makefile
View
4 clj.gemspec
@@ -6,8 +6,8 @@ Gem::Specification.new {|s|
s.homepage = 'http://github.com/meh/ruby-clj'
s.platform = Gem::Platform::RUBY
s.summary = 'Like json, but with clojure sexps.'
- s.files = Dir.glob('lib/**/*.rb')
- s.require_path = 'lib'
+ s.files = Dir['ext/**/*.{c,h,rb}'] + Dir['lib/**/*.rb']
+ s.extensions = 'ext/clj/extconf.rb'
s.add_development_dependency 'rake'
s.add_development_dependency 'rspec'
View
15 ext/clj/extconf.rb
@@ -0,0 +1,15 @@
+require 'mkmf'
+
+unless $CFLAGS.gsub!(/ -O[\dsz]?/, ' -O3')
+ $CFLAGS << ' -O3'
+end
+
+if CONFIG['CC'] =~ /gcc/
+ $CFLAGS << ' -Wall'
+
+ if $DEBUG && !$CFLAGS.gsub!(/ -O[\dsz]?/, ' -O0 -ggdb')
+ $CFLAGS << ' -O0 -ggdb'
+ end
+end
+
+create_makefile 'clj/parser_ext'
View
7 ext/clj/parser.c
@@ -0,0 +1,7 @@
+#include "ruby.h"
+
+void
+Init_parser_ext (void)
+{
+
+}
View
11 extconf.rb
@@ -0,0 +1,11 @@
+# Loads mkmf which is used to make makefiles for Ruby extensions
+require 'mkmf'
+
+# Give it a name
+extension_name = 'parser_ext'
+
+# The destination
+dir_config(parser_ext)
+
+# Do the work
+create_makefile(parser_ext)
View
7 lib/clj.rb
@@ -11,7 +11,12 @@
require 'date'
require 'bigdecimal'
-require 'clj/parser'
+if RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
+ require 'clj/parser_ext'
+else
+ require 'clj/parser'
+end
+
require 'clj/types'
class Clojure
Please sign in to comment.
Something went wrong with that request. Please try again.