@@ -29,8 +29,13 @@ def initialize(module_name = nil, &block)
29
29
##
30
30
# @private
31
31
def method_missing ( method_name , *args , &block )
32
- method_name = method_name . to_s . gsub ( '_' , '-' ) . to_sym
33
- super # TODO: invoke the corresponding Lisp function
32
+ function_name = method_name . to_s . gsub ( '_' , '-' ) . to_sym
33
+ result = call_lisp_ ( function_name , args ) ;
34
+ if block_given?
35
+ block . call ( result )
36
+ else
37
+ result
38
+ end
34
39
end
35
40
36
41
##
@@ -44,29 +49,34 @@ def method_missing(method_name, *args, &block)
44
49
#
45
50
# @param [String] function
46
51
# @param [Array] arguments
47
- def call_lisp ( function , *arguments )
48
- # the BERTRPC interface is not symmetric, but that's the way it is.
49
- message = encode_ruby_request ( BERT ::Tuple [ :call , @module_name , function , arguments ] )
50
- pid , stdin , stdout , stderr = Open4 . popen4 ( LISP )
51
- stdin . write ( message )
52
- stdin . flush . close
53
- _ , status = Process . waitpid2 ( pid )
54
- if ( status . exitstatus . zero? )
52
+ def call_lisp ( function , *arguments )
53
+ call_lisp_ ( function , arguments )
54
+ end
55
+
56
+
57
+ def call_lisp_ ( function , arguments )
58
+ # the BERTRPC interface is not symmetric, but that's the way it is.
59
+ message = encode_ruby_request ( BERT ::Tuple [ :call , @module_name , function , arguments ] )
60
+ pid , stdin , stdout , stderr = Open4 . popen4 ( LISP )
61
+ stdin . write ( message )
62
+ stdin . flush . close
63
+ _ , status = Process . waitpid2 ( pid )
64
+ if ( status . exitstatus . zero? )
55
65
# decode the response directly from the stream w/o a length header
56
- dc = BERT ::Decode . new ( stdout ) ;
57
- response = dc . read_any
58
- case response [ 0 ]
59
- when :reply
60
- response [ 1 ]
61
- when :error
62
- error ( response [ 1 ] )
63
- else
64
- raise
66
+ dc = BERT ::Decode . new ( stdout ) ;
67
+ response = dc . read_any
68
+ case response [ 0 ]
69
+ when :reply
70
+ response [ 1 ]
71
+ when :error
72
+ error ( response [ 1 ] )
73
+ else
74
+ raise
75
+ end
76
+ else
77
+ raise ( StandardError , stderr . read ( ) )
65
78
end
66
- else
67
- raise ( StandardError , stderr . read ( ) )
68
79
end
69
- end
70
80
71
81
end
72
82
@@ -111,9 +121,11 @@ def self.execute(code)
111
121
p RSpec ::Lisp . evaluate ( %q((* 6 (+ 3 4))) ) #=> 42
112
122
end
113
123
114
-
124
+ ## RSpec::Lisp::Proxy.new("CL").call_lisp("lisp-implementation-type")
115
125
## RSpec::Lisp::Proxy.new("CL").call_lisp("round", 7, 3)
116
126
## RSpec::Lisp::Proxy.new("keyword").call_lisp("rspec.succeed")
117
127
## RSpec::Lisp::Proxy.new("keyword").call_lisp("rspec.fail")
118
128
## RSpec::Lisp::Proxy.new("keyword").call_lisp("rspec.error")
119
129
130
+ ## RSpec::Lisp::Proxy.new("CL").lisp_implementation_type
131
+
0 commit comments