Sha256: d40cd0e952b95bde19659d702f4f62ab01cb50b4fe785ceebd3f30d881b95aa7

Contents?: true

Size: 1.02 KB

Versions: 11

Compression:

Stored size: 1.02 KB

Contents

#include <ruby.h>
#include "internal/node/ruby_internal_node.h"
#include "block.h"

#ifdef RUBY_VM
#include "vm_core.h"
#endif

/*
 * call-seq:
 *   binding.body => Binding
 *
 * Given a Binding, returns the Node for that Binding's body.
 *
 * On YARV, this will returning the Binding's instruction sequence.
 */
static VALUE binding_body(VALUE self)
{
#ifdef RUBY_VM
  rb_binding_t * binding;
  rb_env_t * env;
  GetBindingPtr(self, binding);
  GetEnvPtr(binding->env, env);
  return env->block.iseq->self;
#else
  struct BLOCK * b;
  if(rb_safe_level() >= 4)
  {
    /* no access to potentially sensitive data from the sandbox */
    rb_raise(rb_eSecurityError, "Insecure: can't get binding body");
  }
  Data_Get_Struct(self, struct BLOCK, b);
  return wrap_node(b->body);
#endif
}

void Init_binding(void)
{
  rb_require("internal/node");

  /* For rdoc: rb_cBinding = rb_define_class("Binding", rb_cObject) */
  VALUE rb_cBinding = rb_const_get(rb_cObject, rb_intern("Binding"));
  rb_define_method(rb_cBinding, "body", binding_body, 0);
}

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ruby-internal-0.8.5 ext/internal/binding/binding.c
ruby-internal-0.8.4 ext/internal/binding/binding.c
ruby-internal-0.8.3 ext/internal/binding/binding.c
ruby-internal-0.8.2 ext/internal/binding/binding.c
ruby-internal-0.8.1 ext/internal/binding/binding.c
ruby-internal-0.8.0 ext/internal/binding/binding.c
ruby-internal-0.7.3 ext/internal/binding/binding.c
ruby-internal-0.7.2 ext/internal/binding/binding.c
ruby-internal-0.7.1 ext/internal/binding/binding.c
ruby-internal-0.7.0 ext/internal/binding/binding.c
ruby-internal-0.6.0 ext/internal/binding/binding.c