OLD | NEW |
1 /* Copyright 2009 The Native Client Authors. All rights reserved. | 1 /* Copyright 2009 The Native Client Authors. All rights reserved. |
2 * Use of this source code is governed by a BSD-style license that can | 2 * Use of this source code is governed by a BSD-style license that can |
3 * be found in the LICENSE file. */ | 3 * be found in the LICENSE file. */ |
4 | 4 |
5 #include <stdio.h> | 5 #include <stdio.h> |
6 #include <string.h> | 6 #include <string.h> |
7 #include <nacl/nacl_srpc.h> | 7 #include <nacl/nacl_srpc.h> |
8 #include "ruby-1.8.6-p368/ruby.h" | 8 #include "ruby-1.8.6-p368/ruby.h" |
9 | 9 |
10 int initialized = 0; | 10 int initialized = 0; |
(...skipping 27 matching lines...) Expand all Loading... |
38 NaClSrpcArg **in_args, | 38 NaClSrpcArg **in_args, |
39 NaClSrpcArg **out_args, | 39 NaClSrpcArg **out_args, |
40 NaClSrpcClosure *done) { | 40 NaClSrpcClosure *done) { |
41 | 41 |
42 /* TODO(krasin): MAKE IT THREAD-SAFE */ | 42 /* TODO(krasin): MAKE IT THREAD-SAFE */ |
43 if (!initialized) { | 43 if (!initialized) { |
44 ruby_init(); | 44 ruby_init(); |
45 rb_eval_string(INIT_RUBY_SCRIPT); | 45 rb_eval_string(INIT_RUBY_SCRIPT); |
46 initialized = 1; | 46 initialized = 1; |
47 } | 47 } |
48 rb_eval_string(in_args[0]->u.sval); | 48 rb_eval_string(in_args[0]->arrays.str); |
49 VALUE result = rb_eval_string("$stdout_logger.get_string()"); | 49 VALUE result = rb_eval_string("$stdout_logger.get_string()"); |
50 | 50 |
51 /* | 51 /* |
52 * Strdup must be used because the SRPC layer frees the string passed to it. | 52 * Strdup must be used because the SRPC layer frees the string passed to it. |
53 */ | 53 */ |
54 out_args[0]->u.sval = strdup(StringValuePtr(result)); | 54 out_args[0]->arrays.str = strdup(StringValuePtr(result)); |
55 | 55 |
56 rpc->result = NACL_SRPC_RESULT_OK; | 56 rpc->result = NACL_SRPC_RESULT_OK; |
57 done->Run(done); | 57 done->Run(done); |
58 } | 58 } |
59 | 59 |
60 /* | 60 /* |
61 * Export the method as taking no arguments and returning one integer. | 61 * Export the method as taking no arguments and returning one integer. |
62 */ | 62 */ |
63 NACL_SRPC_METHOD("rubyEval:s:s", RubyEval); | 63 NACL_SRPC_METHOD("rubyEval:s:s", RubyEval); |
OLD | NEW |