Exemplo n.º 1
0
VALUE wkhtml_topdf_converter_convert(VALUE self) {
  wkhtmltopdf_converter* converter;

  //TODO QApplication is initialized on whatever thread `wkhtmltopdf_init` is called, otherwise events are
  //not sent properly
  if(rb_thread_main() != rb_thread_current()) {
    rb_raise(rb_eRuntimeError, "Yuck!  You must be on the main thread for wkhtmltopdf to work");
  }

  //Checks
  if(rb_ivar_get(self, idReady) != Qtrue) rb_raise(rb_eRuntimeError, "Object must be added first");
  rb_check_frozen(self);

  Data_Get_Struct(self, wkhtmltopdf_converter, converter);

  if(wkhtmltopdf_convert(converter)) {
    OBJ_FREEZE(self);

    return Qtrue;
  }
  else {
    return Qfalse;
  }
}
Exemplo n.º 2
0
/**
 * Push an image onto the end of the imagelist.
 *
 * No Ruby usage (internal function)
 *
 * @param imagelist the imagelist
 * @param image the image
 */
static void
imagelist_push(VALUE imagelist, VALUE image)
{
    rb_check_frozen(imagelist);
    (void) rb_funcall(imagelist, rm_ID_push, 1, image);
}
Exemplo n.º 3
0
/*
 * call-seq:
 *   image.blur_vertical(radius) -> WX::Image
 *
 * blur the image according to the specified pixel radius
 * ===Arguments
 * * radius Integer
 * ===Return value
 * WX::Image
*/
DLL_LOCAL VALUE _BlurVertical_self(VALUE self, VALUE radius)
{
	rb_check_frozen(self);
	_self->Paste(_self->BlurVertical(RB_NUM2INT(radius)), 0, 0);
	return self;
}
Exemplo n.º 4
0
static void
rb_struct_modify(VALUE s)
{
    rb_check_frozen(s);
    rb_check_trusted(s);
}
Exemplo n.º 5
0
void
rb_enc_set_index(VALUE obj, int idx)
{
    rb_check_frozen(obj);
    enc_set_index(obj, idx);
}
Exemplo n.º 6
0
static VALUE object_spec_rb_check_frozen(VALUE self, VALUE obj) {
  rb_check_frozen(obj);
  return Qnil;
}
Exemplo n.º 7
0
/*
 * @overload image=(img)
 *   Sets the image this object will draw on
 *   @param [Ray::Image] img New image to draw on
 */
VALUE ray_image_target_set_image(VALUE self, VALUE img) {
    rb_check_frozen(self);
    say_image_target_set_image(ray_rb2image_target(self), ray_rb2image(img));
    rb_iv_set(self, "@image", img);
    return img;
}
Exemplo n.º 8
0
/*
 * @overload resize(size)
 *   @param [Integere] size New size
 *
 *   Resizes the buffer, alsos causing it to be updated.
 */
static
VALUE ray_gl_buffer_resize(VALUE self, VALUE size) {
  rb_check_frozen(self);
  say_buffer_resize(ray_rb2buffer(self), NUM2ULONG(size));
  return self;
}
Exemplo n.º 9
0
/*
 *  @overload attenuation=(attenuation)
 *    Sets the attenuation of a sound
 *
 *    When set to 0, the sound will not be attenuated at all. 100 makes
 *    attenuation very quick.
 *
 *    @param [Float] atenuation New attenuation factor of the sound
 */
static
VALUE ray_audio_source_set_attenuation(VALUE self, VALUE att) {
  rb_check_frozen(self);
  say_audio_source_set_attenuation(ray_rb2audio_source(self), NUM2DBL(att));
  return att;
}
Exemplo n.º 10
0
void rbColor::SetAlpha( VALUE aColor, VALUE aValue )
{
    rb_check_frozen( aColor );
    rb_iv_set( aColor, "@a", aValue );
}
Exemplo n.º 11
0
void rbColor::SetBlue( VALUE aColor, VALUE aValue )
{
    rb_check_frozen( aColor );
    rb_iv_set( aColor, "@b", aValue );
}
Exemplo n.º 12
0
void rbColor::SetGreen( VALUE aColor, VALUE aValue )
{
    rb_check_frozen( aColor );
    rb_iv_set( aColor, "@g", aValue );
}
Exemplo n.º 13
0
static rb_method_entry_t *
rb_method_entry_make(VALUE klass, ID mid, rb_method_type_t type,
		     rb_method_definition_t *def, rb_method_flag_t noex)
{
    rb_method_entry_t *me;
    st_table *mtbl;
    st_data_t data;

    if (NIL_P(klass)) {
	klass = rb_cObject;
    }
    if (rb_safe_level() >= 4 &&
	(klass == rb_cObject || !OBJ_UNTRUSTED(klass))) {
	rb_raise(rb_eSecurityError, "Insecure: can't define method");
    }
    if (!FL_TEST(klass, FL_SINGLETON) &&
	type != VM_METHOD_TYPE_NOTIMPLEMENTED &&
	type != VM_METHOD_TYPE_ZSUPER &&
	(mid == rb_intern("initialize") || mid == rb_intern("initialize_copy"))) {
	noex = NOEX_PRIVATE | noex;
    }
    else if (FL_TEST(klass, FL_SINGLETON) &&
	     type == VM_METHOD_TYPE_CFUNC &&
	     mid == rb_intern("allocate")) {
	rb_warn("defining %s.allocate is deprecated; use rb_define_alloc_func()",
		rb_class2name(rb_ivar_get(klass, attached)));
	mid = ID_ALLOCATOR;
    }

    rb_check_frozen(klass);
    mtbl = RCLASS_M_TBL(klass);

    /* check re-definition */
    if (st_lookup(mtbl, mid, &data)) {
	rb_method_entry_t *old_me = (rb_method_entry_t *)data;
	rb_method_definition_t *old_def = old_me->def;

	if (rb_method_definition_eq(old_def, def)) return old_me;
	rb_vm_check_redefinition_opt_method(old_me, klass);

	if (RTEST(ruby_verbose) &&
	    type != VM_METHOD_TYPE_UNDEF &&
	    old_def->alias_count == 0 &&
	    old_def->type != VM_METHOD_TYPE_UNDEF &&
	    old_def->type != VM_METHOD_TYPE_ZSUPER) {
	    rb_iseq_t *iseq = 0;

	    rb_warning("method redefined; discarding old %s", rb_id2name(mid));
	    switch (old_def->type) {
	      case VM_METHOD_TYPE_ISEQ:
		iseq = old_def->body.iseq;
		break;
	      case VM_METHOD_TYPE_BMETHOD:
		iseq = rb_proc_get_iseq(old_def->body.proc, 0);
		break;
	      default:
		break;
	    }
	    if (iseq && !NIL_P(iseq->filename)) {
		int line = iseq->line_info_table ? rb_iseq_first_lineno(iseq) : 0;
		rb_compile_warning(RSTRING_PTR(iseq->filename), line,
				   "previous definition of %s was here",
				   rb_id2name(old_def->original_id));
	    }
	}

	rb_unlink_method_entry(old_me);
    }

    me = ALLOC(rb_method_entry_t);

    rb_clear_cache_by_id(mid);

    me->flag = NOEX_WITH_SAFE(noex);
    me->mark = 0;
    me->called_id = mid;
    me->klass = klass;
    me->def = def;
    if (def) def->alias_count++;

    /* check mid */
    if (klass == rb_cObject && mid == idInitialize) {
	rb_warn("redefining Object#initialize may cause infinite loop");
    }
    /* check mid */
    if (mid == object_id || mid == id__send__) {
	if (type == VM_METHOD_TYPE_ISEQ) {
	    rb_warn("redefining `%s' may cause serious problems", rb_id2name(mid));
	}
    }

    st_insert(mtbl, mid, (st_data_t) me);

    return me;
}
Exemplo n.º 14
0
DLL_LOCAL VALUE _setAttribute(VALUE self,VALUE name,VALUE val)
{
    rb_check_frozen(self);
    _self->SetAttribute(unwrap<wxString>(name),unwrapVariant(val,_self->GetAttribute(unwrap<wxString>(name)).GetType()));
    return val;
}
Exemplo n.º 15
0
VALUE
subextViewClients(VALUE self)
{
  int i, nclients = 0;
  Window *clients = NULL;
  VALUE id = Qnil, klass = Qnil, meth = Qnil, array = Qnil, client = Qnil;
  unsigned long *view_tags = NULL;

  /* Check ruby object */
  rb_check_frozen(self);
  GET_ATTR(self, "@id", id);

  subextSubtlextConnect(NULL); ///< Implicit open connection

  /* Fetch data */
  klass     = rb_const_get(mod, rb_intern("Client"));
  meth      = rb_intern("new");
  array     = rb_ary_new();
  clients   = subextSubtlextWindowList("_NET_CLIENT_LIST", &nclients);
  view_tags = (unsigned long *)subSharedPropertyGet(display,
    DefaultRootWindow(display), XA_CARDINAL,
    XInternAtom(display, "SUBTLE_VIEW_TAGS", False), NULL);

  /* Check results */
  if(clients && view_tags)
    {
      for(i = 0; i < nclients; i++)
        {
          unsigned long *client_tags = NULL, *flags = NULL;

          /* Fetch window data */
          client_tags = (unsigned long *)subSharedPropertyGet(display,
            clients[i], XA_CARDINAL,
            XInternAtom(display, "SUBTLE_CLIENT_TAGS", False), NULL);
          flags       = (unsigned long *)subSharedPropertyGet(display,
            clients[i], XA_CARDINAL,
            XInternAtom(display, "SUBTLE_CLIENT_FLAGS", False), NULL);

          /* Check if there are common tags or window is stick */
          if((client_tags && view_tags[FIX2INT(id)] & *client_tags) ||
              (flags && *flags & SUB_EWMH_STICK))
            {
              if(RTEST(client = rb_funcall(klass, meth,
                  1, LONG2NUM(clients[i]))))
                {
                  subextClientUpdate(client);

                  rb_ary_push(array, client);
                }
            }

          if(client_tags) free(client_tags);
          if(flags)       free(flags);
        }
    }

  if(clients)   free(clients);
  if(view_tags) free(view_tags);

  return array;
} /* }}} */
Exemplo n.º 16
0
DLL_LOCAL VALUE _setVisible(VALUE self,VALUE val)
{
    rb_check_frozen(self);
    _self->Hide(!RTEST(val));
    return val;
}
Exemplo n.º 17
0
VALUE
subGravityUpdate(VALUE self)
{
  int id = -1;
  XRectangle geom = { 0 };
  char *name = NULL;
  VALUE match = Qnil;

  /* Check ruby object */
  rb_check_frozen(self);
  GET_ATTR(self, "@name", match);

  /* Find gravity */
  if(-1 == (id = GravityFindId(RSTRING_PTR(match), &name, &geom)))
    {
      SubMessageData data = { { 0, 0, 0, 0, 0 } };
      VALUE geometry = rb_iv_get(self, "@geometry");

      if(NIL_P(geometry = rb_iv_get(self, "@geometry")))
        rb_raise(rb_eStandardError, "No geometry given");

      subGeometryToRect(geometry, &geom); ///< Get values

      /* Create new gravity */
      snprintf(data.b, sizeof(data.b), "%hdx%hd+%hd+%hd#%s",
        geom.x, geom.y, geom.width, geom.height, RSTRING_PTR(match));
      subSharedMessage(display, DefaultRootWindow(display),
        "SUBTLE_GRAVITY_NEW", data, 8, True);

      id = GravityFindId(RSTRING_PTR(match), NULL, NULL);
    }
  else ///< Update gravity
    {
      VALUE geometry = Qnil;

      geometry = subGeometryInstantiate(geom.x, geom.y,
        geom.width, geom.height);

      rb_iv_set(self, "@name",    rb_str_new2(name));
      rb_iv_set(self, "@gravity", geometry);

      free(name);
    }

  /* Guess gravity id */
  if(-1 == id)
    {
      int ngravities = 0;
      char **gravities = NULL;

      gravities = subSharedPropertyGetStrings(display, DefaultRootWindow(display),
        XInternAtom(display, "SUBTLE_GRAVITY_LIST", False), &ngravities);

      id = ngravities; ///< New id should be last

      XFreeStringList(gravities);
    }

  rb_iv_set(self, "@id", INT2FIX(id));

  return Qnil;
} /* }}} */