Permalink
Browse files

Merge branch 'master' into prototype

  • Loading branch information...
2 parents 5407d8a + a802d10 commit 83c9a339e45a0a5f7f0999261f5ce2dcde3bde56 @jbarnette committed Feb 1, 2009
View
@@ -1,3 +1,4 @@
+.autotest
CHANGELOG
MANIFEST
MINGW32.mk
@@ -69,7 +70,9 @@ lib/johnson/visitors/dot_visitor.rb
lib/johnson/visitors/ecma_visitor.rb
lib/johnson/visitors/enumerating_visitor.rb
lib/johnson/visitors/sexp_visitor.rb
+lib/johnson/visitors/visitor.rb
lib/rails/init.rb
+srcs/xmlparser-0.6.8.tar
test/assets/index.html
test/assets/jquery_test.html
test/helper.rb
@@ -100,6 +103,7 @@ test/johnson/nodes/function_test.rb
test/johnson/nodes/if_test.rb
test/johnson/nodes/import_test.rb
test/johnson/nodes/label_test.rb
+test/johnson/nodes/let_test.rb
test/johnson/nodes/object_literal_test.rb
test/johnson/nodes/return_test.rb
test/johnson/nodes/semi_test.rb
@@ -123,6 +127,7 @@ test/johnson/version_test.rb
test/johnson/visitors/dot_visitor_test.rb
test/johnson/visitors/enumerating_visitor_test.rb
test/johnson_test.rb
+test/jquery_units/simple.js
test/jquery_units/test.js
test/jquery_units/test_helper.js
test/jquery_units/units/ajax.js
@@ -279,7 +284,6 @@ vendor/spidermonkey/js.c
vendor/spidermonkey/js.mak
vendor/spidermonkey/js.mdp
vendor/spidermonkey/js.msg
-vendor/spidermonkey/js.pkg
vendor/spidermonkey/js3240.rc
vendor/spidermonkey/jsOS240.def
vendor/spidermonkey/jsapi.c
View
@@ -3,6 +3,8 @@ require "erb"
require "./lib/hoe.rb"
require "./lib/johnson/version.rb"
+abort "Need Ruby version 1.8.x!" unless RUBY_VERSION > "1.8"
+
# what sort of extension are we building?
kind = Config::CONFIG["DLEXT"]
@@ -35,6 +37,7 @@ end
namespace :gem do
task :spec do
File.open("#{HOE.name}.gemspec", "w") do |f|
+ HOE.spec.version = "#{HOE.version}.#{Time.now.strftime("%Y%m%d%H%M%S")}"
f.puts(HOE.spec.to_ruby)
end
end
@@ -55,6 +58,14 @@ namespace :test do
Johnson::Runtime.new.load(file)
end
end
+
+ task :jquery => :extensions do
+ $LOAD_PATH << File.expand_path(File.dirname(__FILE__) + "/lib")
+ $LOAD_PATH << File.expand_path(File.dirname(__FILE__) + "/../taka/lib")
+ Johnson.send(:remove_const, :VERSION)
+ require 'johnson'
+ Johnson::Runtime.new.load('test/jquery_units/test.js')
+ end
end
# make sure the C bits are up-to-date when testing
@@ -63,8 +74,19 @@ Rake::Task["test:todo"].prerequisites << :extensions
Rake::Task[:check_manifest].prerequisites << GENERATED_NODE
+task :install_expat do
+ Dir.chdir("./srcs") do
+ `tar -xf xmlparser-0.6.8.tar`
+ Dir.chdir("xmlparser") do
+ puts `#{Gem.ruby} extconf.rb`
+ puts `make`
+ puts `sudo make install`
+ end
+ end
+end
+
task :build => :extensions
-task :extension => :build
+task :extension => :build # FIXME: why is this here?
task :extensions => ["lib/johnson/spidermonkey.#{kind}"]
@@ -161,3 +183,56 @@ file GENERATED_NODE => ["ext/spidermonkey/immutable_node.c.erb", "vendor/spiderm
f.write template.result(binding)
}
end
+
+def test_suite_cmdline
+ require 'find'
+ files = []
+ Find.find("test") do |f|
+ files << f if File.basename(f) =~ /.*test.*\.rb$/
+ end
+ cmdline = "ruby -w -I.:lib:ext:test -rtest/unit -e '%w[#{files.join(' ')}].each {|f| require f}'"
+end
+
+namespace :test do
+ # partial-loads-ok and undef-value-errors necessary to ignore
+ # spurious (and eminently ignorable) warnings from the ruby
+ # interpreter
+ VALGRIND_BASIC_OPTS = "--num-callers=50 --error-limit=no --partial-loads-ok=yes --undef-value-errors=no"
+
+ desc "run test suite under valgrind with basic ruby options"
+ task :valgrind => :build do
+ cmdline = "valgrind #{VALGRIND_BASIC_OPTS} #{test_suite_cmdline}"
+ puts cmdline
+ system cmdline
+ end
+
+ desc "run test suite under valgrind with memory-fill ruby options"
+ task :valgrind_mem => :build do
+ # fill malloced memory with "m" and freed memory with "f"
+ cmdline = "valgrind #{VALGRIND_BASIC_OPTS} --freelist-vol=100000000 --malloc-fill=6D --free-fill=66 #{test_suite_cmdline}"
+ puts cmdline
+ system cmdline
+ end
+
+ desc "run test suite under valgrind with memory-zero ruby options"
+ task :valgrind_mem0 => :build do
+ # fill malloced and freed memory with 0
+ cmdline = "valgrind #{VALGRIND_BASIC_OPTS} --freelist-vol=100000000 --malloc-fill=00 --free-fill=00 #{test_suite_cmdline}"
+ puts cmdline
+ system cmdline
+ end
+
+ desc "run test suite under gdb"
+ task :gdb => :build do
+ cmdline = "gdb --args #{test_suite_cmdline}"
+ puts cmdline
+ system cmdline
+ end
+end
+
+# Evil evil hack. Do not run tests when gem installs
+if ENV['RUBYARCHDIR']
+ prereqs = Rake::Task[:default].prerequisites
+ prereqs.clear
+ prereqs << :build
+end
View
@@ -89,18 +89,10 @@ initialize_native(VALUE self, VALUE rb_runtime, VALUE UNUSED(options))
//// INFRASTRUCTURE BELOW HERE ////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
-static void deallocate(JohnsonContext *context) {
- JS_SetContextPrivate(context->js, 0);
- /*
- JS_DestroyContext(context->js);
- free(context);
- */
-}
-
static VALUE allocate(VALUE klass)
{
JohnsonContext* context = calloc(1L, sizeof(JohnsonContext));
- return Data_Wrap_Struct(klass, 0, deallocate, context);
+ return Data_Wrap_Struct(klass, 0, 0, context);
}
void init_Johnson_SpiderMonkey_Context(VALUE spidermonkey)
@@ -88,6 +88,34 @@ JSBool convert_to_js(JohnsonRuntime* runtime, VALUE ruby, jsval* retval)
PREPARE_JROOTS(context, 0);
switch(TYPE(ruby))
{
+ case T_NONE:
+ JERROR("I don't know how to handle T_NONE.");
+ JRETURN;
+
+ case T_ICLASS:
+ JERROR("I don't know how to handle T_ICLASS.");
+ JRETURN;
+
+ case T_MATCH:
+ JERROR("I don't know how to handle T_MATCH.");
+ JRETURN;
+
+ case T_BLKTAG:
+ JERROR("I don't know how to handle T_BLKTAG.");
+ JRETURN;
+
+ case T_NODE:
+ JERROR("I don't know how to handle T_NODE | T_MASK.");
+ JRETURN;
+
+ case T_UNDEF:
+ JERROR("I don't know how to handle T_UNDEF.");
+ JRETURN;
+
+ case T_VARMAP:
+ JERROR("I don't know how to handle T_VARMAP.");
+ JRETURN;
+
case T_NIL:
*retval = JSVAL_NULL;
JRETURN;
Oops, something went wrong.

0 comments on commit 83c9a33

Please sign in to comment.