[google-sgnodemapper] r223 committed - Fix debug logging during init.

0 views
Skip to first unread message

codesite...@google.com

unread,
Mar 18, 2010, 2:44:37 PM3/18/10
to sgnodemapp...@googlegroups.com
Revision: 223
Author: br...@danga.com
Date: Thu Mar 18 11:43:41 2010
Log: Fix debug logging during init.
http://code.google.com/p/google-sgnodemapper/source/detail?r=223

Modified:
/trunk/embedding/perl/lib/SocialGraph/NodeMapper.pm

=======================================
--- /trunk/embedding/perl/lib/SocialGraph/NodeMapper.pm Sun Jun 7 19:52:45
2009
+++ /trunk/embedding/perl/lib/SocialGraph/NodeMapper.pm Thu Mar 18 11:43:41
2010
@@ -56,8 +56,10 @@
select($wtr); $| = 1; select(STDOUT);
my ($tmp_fh, $tmp_filename) = tempfile();
my $js = _slurp($js_file);
- print $tmp_fh $js, "\n";
+ # Note: register the debug function first, so debug during init
+ # is printed as well.
print $tmp_fh "debug = function(msg) { print(\"# \" + msg); };\n";
+ print $tmp_fh $js, "\n";
print $tmp_fh "while (true) { var expr = readline();
print(eval(expr) + \"\\n.\"); }\n";
close($tmp_fh);
my $pid = open3($wtr, $rdr, $err, $SMJS, $tmp_filename);
@@ -155,11 +157,15 @@
my $expr = "$func(" .
join(", ", map { _json_encode($_) } @args) .
")";
+
+ # In-process JavaScript::Spidermonkey case:
if ($self->{js}) {
my $js = "_set_return_value($expr);";
$self->{js}->eval($js) or die $@;
return $self->{_last_return_value};
}
+
+ # Child-process smjs case:
syswrite($self->{wtr}, "$expr\n");
my $ret;
my $fh = $self->{rdr};

Reply all
Reply to author
Forward
0 new messages