Commit 0163e625 authored by Scott Lembcke's avatar Scott Lembcke Committed by Scott Lembcke

Style fixes. Swapped stdlib functions for glib ones.

2006-07-10  Scott Lembcke <lemb0029@gnome.org>

        * ext/*.c: Style fixes. Swapped stdlib functions for glib ones.
parent b98cc29a
2006-07-10 Scott Lembcke <lemb0029@gnome.org>
* ext/*.c: Style fixes. Swapped stdlib functions for glib ones.
2006-07-08 Scott Lembcke <lemb0029@gnome.org>
* Added plug-in/test.rb.
......
......@@ -33,7 +33,7 @@ gimp_array2rb(const GimpParam *params,
gchar **stringarr;
int i;
switch(param->type)
switch (param->type)
{
case GIMP_PDB_INT32ARRAY:
int32arr = param->data.d_int32array;
......@@ -67,8 +67,8 @@ gimp_array2rb(const GimpParam *params,
}
static VALUE
int8array2str(const GimpParam *params,
int index)
int8array2str (const GimpParam *params,
int index)
{
gint32 size = get_arr_size(params, index);
char *ptr = (char *)params[index].data.d_int8array;
......@@ -192,15 +192,15 @@ GimpParams2rb (const GimpParam *params,
int i;
for(i=0; i<count; i++)
for (i=0; i<count; i++)
rb_ary_push(ary, GimpParam2rb(params, i));
return ary;
}
static gpointer
rb2gimp_array(GimpPDBArgType type,
VALUE rbarr)
rb2gimp_array (GimpPDBArgType type,
VALUE rbarr)
{
rbarr = rb_check_array_type(rbarr);
int count = RARRAY(rbarr)->len;
......@@ -212,7 +212,7 @@ rb2gimp_array(GimpPDBArgType type,
gdouble *floatarr;
gchar **stringarr;
switch(type)
switch (type)
{
case GIMP_PDB_INT32ARRAY:
int32arr = g_new(gint32, count);
......@@ -239,7 +239,7 @@ rb2gimp_array(GimpPDBArgType type,
}
static guint8 *
str2gint8(VALUE rb_str)
str2gint8 (VALUE rb_str)
{
Check_Type(rb_str, T_STRING);
struct RString *str = RSTRING(rb_str);
......@@ -250,7 +250,7 @@ str2gint8(VALUE rb_str)
GimpParam
rb2GimpParam (VALUE rbparam)
{
if(!rb_obj_is_kind_of(rbparam, sGimpParam))
if (!rb_obj_is_kind_of(rbparam, sGimpParam))
rb_raise(rb_eTypeError, "Parameter is not a Gimp::Param");
int type = NUM2INT(rb_struct_aref(rbparam, ID2SYM(id_type)));
......@@ -259,7 +259,7 @@ rb2GimpParam (VALUE rbparam)
GimpParam result;
result.type = (GimpPDBArgType)type;
switch(type)
switch (type)
{
case GIMP_PDB_INT32:
result.data.d_int32 = (gint32)NUM2INT(rbdata);
......@@ -369,10 +369,10 @@ rb2GimpParams (VALUE rbparams,
int num = RARRAY(rbparams)->len;
VALUE *arr = RARRAY(rbparams)->ptr;
GimpParam *params = calloc(num, sizeof(GimpParam));
GimpParam *params = g_new(GimpParam, num);
int i;
for(i=0; i<num; i++)
for (i=0; i<num; i++)
params[i] = rb2GimpParam(arr[i]);
*count = (gint)num;
......@@ -390,13 +390,13 @@ GimpParamDef2rb (GimpParamDef paramdef)
}
VALUE
GimpParamDefs2rb(GimpParamDef *paramdefs,
int count)
GimpParamDefs2rb (GimpParamDef *paramdefs,
int count)
{
volatile VALUE rbparamdefs = rb_ary_new();
int i;
for(i=0; i<count; i++)
for (i=0; i<count; i++)
rb_ary_push(rbparamdefs, GimpParamDef2rb(paramdefs[i]));
return rbparamdefs;
......@@ -405,7 +405,7 @@ GimpParamDefs2rb(GimpParamDef *paramdefs,
GimpParamDef
rb2GimpParamDef (VALUE param)
{
if(!rb_obj_is_kind_of(param, sGimpParamDef))
if (!rb_obj_is_kind_of(param, sGimpParamDef))
rb_raise(rb_eArgError, "Parameters must be of type Gimp::ParamDef");
VALUE type = rb_struct_aref(param, ID2SYM(id_type));
......@@ -425,7 +425,7 @@ GimpParamDef *
rb2GimpParamDefs (VALUE rbparamdefs,
gint *count)
{
if(rbparamdefs == Qnil)
if (rbparamdefs == Qnil)
{
*count = 0;
return NULL;
......@@ -437,7 +437,7 @@ rb2GimpParamDefs (VALUE rbparamdefs,
int num = RARRAY(rbparamdefs)->len;
VALUE *arr = RARRAY(rbparamdefs)->ptr;
GimpParamDef *gimpparamdefs = calloc(num, sizeof(GimpParamDef));
GimpParamDef *gimpparamdefs = g_new(GimpParamDef, num);
int i;
for(i=0; i<num; i++)
......@@ -453,7 +453,7 @@ rb2GimpParamDefs (VALUE rbparamdefs,
VALUE
GimpRGB2rb (const GimpRGB *color)
{
GimpRGB *tmp = malloc(sizeof(GimpRGB));
GimpRGB *tmp = ALLOC(GimpRGB);
*tmp = *color;
return Data_Wrap_Struct(cGimpRGB, NULL, free, tmp);
}
......@@ -461,7 +461,7 @@ GimpRGB2rb (const GimpRGB *color)
GimpRGB *
rb2GimpRGBPtr (VALUE color)
{
if(!rb_obj_is_kind_of(color, cGimpRGB))
if (!rb_obj_is_kind_of(color, cGimpRGB))
rb_raise(rb_eTypeError, "Object %s is not a Gimp::RGB", StringValuePtr(color));
GimpRGB *tmp;
......@@ -486,7 +486,7 @@ GimpHSV2rb (const GimpHSV *color)
GimpHSV *
rb2GimpHSVPtr (VALUE color)
{
if(!rb_obj_is_kind_of(color, cGimpHSV))
if (!rb_obj_is_kind_of(color, cGimpHSV))
rb_raise(rb_eTypeError, "Object %s is not a Gimp::HSV", StringValuePtr(color));
GimpHSV *tmp;
......@@ -511,7 +511,7 @@ GimpCMYK2rb (const GimpCMYK *color)
GimpCMYK *
rb2GimpCMYKPtr (VALUE color)
{
if(!rb_obj_is_kind_of(color, cGimpCMYK))
if (!rb_obj_is_kind_of(color, cGimpCMYK))
rb_raise(rb_eTypeError, "Object %s is not a Gimp::CMYK", StringValuePtr(color));
GimpCMYK *tmp;
......
......@@ -110,7 +110,8 @@ rb_gimp_get_progname(VALUE self)
return rb_str_new2(name);
}
void Init_gimpext(void)
void
Init_gimpext (void)
{
mGimp = rb_define_module("Gimp");
rb_define_module_function(mGimp, "getpid", rb_gimp_getpid, 0);
......
......@@ -348,8 +348,8 @@ rb_gimp_rgb_list_names (VALUE self)
for(i=0; i<num; i++)
rb_ary_push(rbcolors, GimpRGB2rb(&colors[i]));
free(names);
free(colors);
g_free(names);
g_free(colors);
return rb_ary_new3(2, rbnames, rbcolors);
}
......
......@@ -39,7 +39,8 @@ void register_enums(void)
}
}
void Init_gimpconstants(void)
void
Init_gimpconstants (void)
{
register_enums();
......
......@@ -39,12 +39,9 @@ handle_exception (char *message)
rbmessage = rb_eval_string("\"\nA #{$!.class} has occured: #{$!.message}\n#{$@.join(\"\n\")}\"");
char *str = StringValuePtr(rbmessage);
int len = strlen(message) + strlen(str);
char result[len + 1];
strcpy(result, message);
strcat(result, str);
gchar *result = g_strconcat(message, str, NULL);
gimp_message(result);
g_free(result);
gimp_quit();
}
......@@ -55,9 +52,9 @@ static VALUE
init_protect (VALUE unused)
{
VALUE cback = plug_in_callbacks[0];
if(cback == Qnil) return Qnil;
if (cback == Qnil) return Qnil;
if(!rb_respond_to(cback, id_call))
if (!rb_respond_to(cback, id_call))
rb_raise(rb_eTypeError, "The init callback does not respond to #call");
rb_funcall(cback, id_call, 0);
......@@ -70,7 +67,7 @@ init_callback (void)
int err;
rb_protect(init_protect, Qnil, &err);
if(err)
if (err)
handle_exception("An exception has occurred while running the init callback.");
}
......@@ -78,9 +75,9 @@ static VALUE
quit_protect (VALUE unused)
{
VALUE cback = plug_in_callbacks[1];
if(cback == Qnil) return Qnil;
if (cback == Qnil) return Qnil;
if(!rb_respond_to(cback, id_call))
if (!rb_respond_to(cback, id_call))
rb_raise(rb_eTypeError, "The quit callback does not respond to #call");
rb_funcall(cback, id_call, 0);
......@@ -93,7 +90,7 @@ quit_callback (void)
int err;
rb_protect(quit_protect, Qnil, &err);
if(err)
if (err)
handle_exception("An exception has occurred while running the quit callback.");
}
......@@ -101,7 +98,7 @@ static VALUE
query_protect (VALUE unused)
{
VALUE cback = plug_in_callbacks[2];
if(!rb_respond_to(cback, id_call))
if (!rb_respond_to(cback, id_call))
rb_raise(rb_eTypeError, "The query callback does not respond to #call");
rb_funcall(cback, id_call, 0);
......@@ -114,7 +111,7 @@ query_callback (void)
int err;
rb_protect(query_protect, Qnil, &err);
if(err)
if (err)
handle_exception("An exception has occurred while running the query callback");
}
......@@ -122,7 +119,7 @@ static VALUE
run_protect (VALUE args)
{
VALUE cback = plug_in_callbacks[3];
if(rb_respond_to(cback, id_call))
if (rb_respond_to(cback, id_call))
{
volatile VALUE rbreturn_vals;
rbreturn_vals = rb_apply(cback, id_call, args);
......@@ -149,7 +146,7 @@ run_callback (const gchar *name,
volatile VALUE rbreturn_vals;
rbreturn_vals = rb_protect(run_protect, args, &err);
if(err)
if (err)
handle_exception("An exception has occured while running the run callback");
/*FIXME rb2GimpParams can raise exceptions*/
......@@ -182,7 +179,7 @@ rb_gimp_main (VALUE self,
argv[0] = StringValuePtr(name);
int i;
for(i=0; i<argc; i++)
for (i=0; i<argc; i++)
argv[i + 1] = StringValuePtr(arr[i]);
/*call gimp_main*/
......@@ -191,7 +188,7 @@ rb_gimp_main (VALUE self,
}
static VALUE
rb_gimp_quit(VALUE self)
rb_gimp_quit (VALUE self)
{
gimp_quit();
return Qnil;
......@@ -233,8 +230,8 @@ rb_gimp_install_procedure (VALUE self,
paramdefs,
returndefs);
free(paramdefs); /*FIXME: should be using gimp_destroy_paramdefs here.*/
free(returndefs); /*make sure that I'm not giving away Ruby ptrs in my paramdefs*/
g_free(paramdefs);
g_free(returndefs);
return Qnil;
}
......@@ -266,7 +263,8 @@ rb_gimp_run_procedure (VALUE self,
return rbreturn_vals;
}
void Init_gimpmain(void)
void
Init_gimpmain (void)
{
gc_array = rb_ary_new();
rb_gc_register_address(&gc_array);
......
......@@ -37,7 +37,7 @@ rb_gimp_procedural_db_proc_info (VALUE self,
&args,
&return_vals);
if(success)
if (success)
{
volatile VALUE ary = rb_ary_new();
if(blurb) rb_ary_push(ary, rb_str_new2(blurb));
......@@ -123,7 +123,7 @@ rb_gimp_procedural_db_query (VALUE self,
&num_matches,
&procedure_names);
if(success)
if (success)
{
volatile VALUE ary = rb_ary_new();
......@@ -154,7 +154,7 @@ rb_gimp_procedural_db_proc_arg (VALUE self,
&arg_name,
&arg_desc);
if(success)
if (success)
{
return rb_struct_new(sGimpParamDef,
INT2NUM(arg_type),
......@@ -183,7 +183,7 @@ rb_gimp_procedural_db_proc_val (VALUE self,
&val_name,
&val_desc);
if(success)
if (success)
{
return rb_struct_new(sGimpParamDef,
INT2NUM(val_type),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment