Module: Renjin::RBSexp
Overview
Module to wrapp every Renjin SEXP.
Instance Attribute Summary collapse
-
#attr ⇒ Object
readonly
Returns the value of attribute attr.
-
#rvar ⇒ Object
readonly
Returns the value of attribute rvar.
-
#scope ⇒ Object
Returns the value of attribute scope.
-
#sexp ⇒ Object
readonly
Returns the value of attribute sexp.
Instance Method Summary collapse
-
#destroy ⇒ Object
—————————————————————————————-.
-
#pp ⇒ Object
—————————————————————————————-.
-
#print ⇒ Object
—————————————————————————————-.
-
#r ⇒ Object
—————————————————————————————- Push the object into the R evaluator.
-
#rclass ⇒ Object
—————————————————————————————-.
-
#sexp? ⇒ Boolean
—————————————————————————————- * @return true if this RubySexp already points to a sexp in R environment —————————————————————————————-.
-
#typeof ⇒ Object
—————————————————————————————-.
-
#unbind ⇒ Object
—————————————————————————————- Scope is used for accessing attribute values for an R object.
Instance Attribute Details
#attr ⇒ Object (readonly)
Returns the value of attribute attr.
42 43 44 |
# File 'lib/JRubyR/rbsexp.rb', line 42 def attr @attr end |
#rvar ⇒ Object (readonly)
Returns the value of attribute rvar.
41 42 43 |
# File 'lib/JRubyR/rbsexp.rb', line 41 def rvar @rvar end |
#scope ⇒ Object
Returns the value of attribute scope.
43 44 45 |
# File 'lib/JRubyR/rbsexp.rb', line 43 def scope @scope end |
#sexp ⇒ Object (readonly)
Returns the value of attribute sexp.
40 41 42 |
# File 'lib/JRubyR/rbsexp.rb', line 40 def sexp @sexp end |
Instance Method Details
#destroy ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/JRubyR/rbsexp.rb', line 49 def destroy if (@rvar != nil) @sexp = R.direct_eval("#{@rvar}") # change value in the scope if (@scope) R.direct_eval("#{scope[0]}(#{scope[1].r}, \"#{scope[2]}\") = #{@rvar}") # @scope = nil end R.direct_eval("rm('#{@rvar}')") @rvar = nil end end |
#pp ⇒ Object
137 138 139 |
# File 'lib/JRubyR/rbsexp.rb', line 137 def pp print end |
#print ⇒ Object
128 129 130 131 |
# File 'lib/JRubyR/rbsexp.rb', line 128 def print # Kernel.print(Java::OrgRenjinPrimitives::Print.doPrint(sexp)) R.eval("print(#{r})") end |
#r ⇒ Object
Push the object into the R evaluator. Check to see if this object already has an R value (rvar). The rvar is just a string of the form sc_xxxxxxxx. This string will be an R variable that holds the SEXP.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/JRubyR/rbsexp.rb', line 71 def r if (@rvar == nil) # create a new variable name to hold this object inside R @rvar = "sc_#{SecureRandom.hex(8)}" # if this object already has a sexp value then assign to @rvar the existing sexp, # otherwise, assign itself to @rvar. (@sexp == nil)? R.assign(@rvar, self) : R.assign(@rvar, @sexp) # Whenever a variable is injected in Renjin, it is also added to the Renjin stack. # After eval, every injected variable is removed from Renjin making sure that we # do not have memory leak. Renjin.stack << self end @rvar end |
#rclass ⇒ Object
120 121 122 |
# File 'lib/JRubyR/rbsexp.rb', line 120 def rclass R.rclass(R.eval("#{r}")) end |
#sexp? ⇒ Boolean
-
@return true if this RubySexp already points to a sexp in R environment
96 97 98 |
# File 'lib/JRubyR/rbsexp.rb', line 96 def sexp? sexp != nil end |
#typeof ⇒ Object
112 113 114 |
# File 'lib/JRubyR/rbsexp.rb', line 112 def typeof R.typeof(R.eval("#{r}")) end |
#unbind ⇒ Object
Scope is used for accessing attribute values for an R object.
104 105 106 |
# File 'lib/JRubyR/rbsexp.rb', line 104 def unbind @scope = nil end |