diff -r -u luacairo-1.10.2.0-src\src\lcairo-context.c luacairo\src\lcairo-context.c --- luacairo-1.10.2.0-src\src\lcairo-context.c Tue Oct 19 11:10:20 2010 +++ luacairo\src\lcairo-context.c Sat Nov 05 14:03:47 2011 @@ -329,19 +329,21 @@ } break; case LUA_TTABLE: { // Borrowed from Chris Osgood's binding + int i; + double offset ; int num_dashes = (int)lua_objlen(L, 2); double *dashes = malloc(num_dashes * sizeof(double)); if (dashes == NULL) luaL_error(L, "memory error"); - int i; + for (i = 0; i < num_dashes; i++) { lua_rawgeti(L, 2, i+1); dashes[i] = lua_tonumber(L, -1); lua_pop(L, 1); } - double offset = luaL_checknumber(L, 4); + offset = luaL_checknumber(L, 4); cairo_set_dash(cr, dashes, num_dashes, offset); free(dashes); } @@ -1265,9 +1267,11 @@ // cairo_status_to_string (cairo_status_t status); static int l_cairo_status_to_string(lua_State* L) { + cairo_status_t status; + const char *v; remove_Context(L, 1); // if called via Context userdata - cairo_status_t status = (cairo_status_t) luaL_checkinteger(L, 1); - const char *v = cairo_status_to_string(status); + status = (cairo_status_t) luaL_checkinteger(L, 1); + v = cairo_status_to_string(status); lua_pushstring(L, v); return 1; } diff -r -u luacairo-1.10.2.0-src\src\lcairo-path.c luacairo\src\lcairo-path.c --- luacairo-1.10.2.0-src\src\lcairo-path.c Fri Oct 22 12:40:16 2010 +++ luacairo\src\lcairo-path.c Sat Nov 05 14:06:01 2011 @@ -243,8 +243,9 @@ // cairo_path_destroy (cairo_path_t *path); static int l_cairo_path_destroy(lua_State* L) { + cairo_path_t *path; remove_Context(L, 1); // if called via Context userdata - cairo_path_t *path = get_cairo_path_t (L, 1); + path = get_cairo_path_t (L, 1); cairo_path_destroy (path); return 0; } @@ -313,6 +314,8 @@ { cairo_path_t *path = get_cairo_path_t (L, 1); int i = luaL_checkinteger(L, 2); + cairo_path_data_t* data; + cairo_path_data_type_t t; int num_data = path->num_data; if (i < 0 || i >= num_data) @@ -321,8 +324,8 @@ return 0; } - cairo_path_data_t* data = &path->data[i]; - cairo_path_data_type_t t = data->header.type; + data = &path->data[i]; + t = data->header.type; lua_pushinteger(L, t); return 1; @@ -333,6 +336,8 @@ { cairo_path_t *path = get_cairo_path_t (L, 1); int i = luaL_checkinteger(L, 2); + cairo_path_data_t* data; + int length; int num_data = path->num_data; if (i < 0 || i >= num_data) @@ -341,8 +346,8 @@ return 0; } - cairo_path_data_t* data = &path->data[i]; - int length = data->header.length; + data = &path->data[i]; + length = data->header.length; lua_pushinteger(L, length); return 1; @@ -354,6 +359,9 @@ cairo_path_t *path = get_cairo_path_t (L, 1); int i = luaL_checkinteger(L, 2); int pi = luaL_checkinteger(L, 3); + cairo_path_data_t* data; + double x; + double y; int num_data = path->num_data; if (i < 0 || i >= num_data) @@ -362,7 +370,7 @@ return 0; } - cairo_path_data_t* data = &path->data[i]; + data = &path->data[i]; /* * As of cairo 1.4, cairo does not mind if there are more elements in @@ -393,8 +401,8 @@ // return 0; // } - double x = data[pi].point.x; - double y = data[pi].point.y; + x = data[pi].point.x; + y = data[pi].point.y; lua_pushnumber(L, x); lua_pushnumber(L, y); diff -r -u luacairo-1.10.2.0-src\src\lcairo-private.c luacairo\src\lcairo-private.c --- luacairo-1.10.2.0-src\src\lcairo-private.c Fri Oct 22 13:59:24 2010 +++ luacairo\src\lcairo-private.c Sat Nov 05 14:02:39 2011 @@ -157,8 +157,9 @@ static double get_numfield(lua_State* L, const char* key) { + double value; lua_getfield(L, -1, key); - double value = luaL_optnumber(L, -1, 0.0); + value = luaL_optnumber(L, -1, 0.0); lua_pop(L, 1); /* remove value */ return value; } diff -r -u luacairo-1.10.2.0-src\src\lcairo-ud-context.c luacairo\src\lcairo-ud-context.c --- luacairo-1.10.2.0-src\src\lcairo-ud-context.c Fri Sep 17 17:41:14 2010 +++ luacairo\src\lcairo-ud-context.c Sat Nov 05 14:13:11 2011 @@ -29,13 +29,17 @@ static int new_Context (lua_State *L) { + cairo_surface_t* target; + cairo_t *cr; + Context *o; + lua_remove(L, 1); // remove cairo.Context //{"create", l_cairo_create}, - cairo_surface_t* target = get_cairo_surface_t (L, 1); - cairo_t *cr = cairo_create(target); + target = get_cairo_surface_t (L, 1); + cr = cairo_create(target); - Context *o = (Context *) lua_newuserdata(L, sizeof(Context)); + o = (Context *) lua_newuserdata(L, sizeof(Context)); o->cr_ = cr; o->havecr_ = 1; diff -r -u luacairo-1.10.2.0-src\src\lcairo-ud-device.c luacairo\src\lcairo-ud-device.c --- luacairo-1.10.2.0-src\src\lcairo-ud-device.c Fri Sep 17 16:51:42 2010 +++ luacairo\src\lcairo-ud-device.c Sat Nov 05 14:13:49 2011 @@ -30,14 +30,18 @@ static int new_Device (lua_State *L) { - lua_remove(L, 1); // remove cairo.Device + cairo_surface_t *surface; + cairo_device_t *dev; + Device *o; + + lua_remove(L, 1); // remove cairo.Device // cairo_public cairo_device_t * // cairo_surface_get_device (cairo_surface_t *surface); - cairo_surface_t *surface = get_cairo_surface_t (L, 1); - cairo_device_t *dev = cairo_surface_get_device (surface); + surface = get_cairo_surface_t (L, 1); + dev = cairo_surface_get_device (surface); - Device *o = (Device *) lua_newuserdata(L, sizeof(Device)); + o = (Device *) lua_newuserdata(L, sizeof(Device)); o->dev_ = dev; o->havedev_ = 1; diff -r -u luacairo-1.10.2.0-src\src\lcairo-ud-font-extents.c luacairo\src\lcairo-ud-font-extents.c --- luacairo-1.10.2.0-src\src\lcairo-ud-font-extents.c Thu Sep 16 09:41:44 2010 +++ luacairo\src\lcairo-ud-font-extents.c Sat Nov 05 14:10:14 2011 @@ -21,10 +21,12 @@ static cairo_font_extents_t check_FontExtents (lua_State* L, int idx) { - luaL_checktype(L, idx, LUA_TTABLE); + cairo_font_extents_t extents; + + luaL_checktype(L, idx, LUA_TTABLE); lua_pushvalue(L, idx); // copy table to top - cairo_font_extents_t extents; +\ extents.ascent = get_numfield(L, "ascent"); extents.descent = get_numfield(L, "descent"); extents.height = get_numfield(L, "height"); @@ -37,11 +39,12 @@ static int new_FontExtents (lua_State *L) { + cairo_font_extents_t *fe; cairo_font_extents_t fein = {0, 0, 0, 0, 0}; int top = lua_gettop(L); if (top > 1) fein = check_FontExtents (L, 2); - cairo_font_extents_t *fe = (cairo_font_extents_t *) lua_newuserdata(L, sizeof(cairo_font_extents_t)); + fe = (cairo_font_extents_t *) lua_newuserdata(L, sizeof(cairo_font_extents_t)); *fe = fein; luaL_getmetatable(L, LUACAIRO ".FontExtents.mt"); @@ -68,7 +71,7 @@ {NULL, NULL} }; -static const Xet_reg_pre FontExtents_getters[] = { +static Xet_reg_pre FontExtents_getters[] = { {"ascent", Xet_get_number, offsetof(cairo_font_extents_t, ascent) }, {"descent", Xet_get_number, offsetof(cairo_font_extents_t, descent) }, {"height", Xet_get_number, offsetof(cairo_font_extents_t, height) }, @@ -77,7 +80,7 @@ {0, 0, 0} }; -static const Xet_reg_pre FontExtents_setters[] = { +static Xet_reg_pre FontExtents_setters[] = { {"ascent", Xet_set_number, offsetof(cairo_font_extents_t, ascent) }, {"descent", Xet_set_number, offsetof(cairo_font_extents_t, descent) }, {"height", Xet_set_number, offsetof(cairo_font_extents_t, height) }, diff -r -u luacairo-1.10.2.0-src\src\lcairo-ud-font-options.c luacairo\src\lcairo-ud-font-options.c --- luacairo-1.10.2.0-src\src\lcairo-ud-font-options.c Wed Sep 15 19:31:48 2010 +++ luacairo\src\lcairo-ud-font-options.c Sat Nov 05 14:14:19 2011 @@ -29,12 +29,15 @@ static int new_FontOptions (lua_State *L) { + cairo_font_options_t *fo; + FontOptions *o; + lua_remove(L, 1); // remove cairo.FontOptions //{"create", l_cairo_font_options_create}, - cairo_font_options_t *fo = cairo_font_options_create(); + fo = cairo_font_options_create(); - FontOptions *o = (FontOptions *) lua_newuserdata(L, sizeof(FontOptions)); + o = (FontOptions *) lua_newuserdata(L, sizeof(FontOptions)); o->fo_ = fo; o->havefo_ = 1; diff -r -u luacairo-1.10.2.0-src\src\lcairo-ud-image-surface.c luacairo\src\lcairo-ud-image-surface.c --- luacairo-1.10.2.0-src\src\lcairo-ud-image-surface.c Fri Sep 17 15:37:12 2010 +++ luacairo\src\lcairo-ud-image-surface.c Sat Nov 05 14:14:59 2011 @@ -21,6 +21,11 @@ static int new_ImageSurface (lua_State *L) { + cairo_format_t format; + int width; + int height; + cairo_surface_t *cs; + lua_remove(L, 1); // remove cairo.ImageSurface //FIXME @@ -29,10 +34,10 @@ //{"create_from_png_stream", l_cairo_image_surface_create_from_png_stream}, //{"create", l_cairo_image_surface_create}, - cairo_format_t format = (cairo_format_t) luaL_checkinteger(L, 1); - int width = luaL_checkinteger(L, 2); - int height = luaL_checkinteger(L, 3); - cairo_surface_t *cs = cairo_image_surface_create (format, width, height); + format = (cairo_format_t) luaL_checkinteger(L, 1); + width = luaL_checkinteger(L, 2); + height = luaL_checkinteger(L, 3); + cs = cairo_image_surface_create (format, width, height); return new_Surface(L, LUACAIRO ".ImageSurface.mt", cs, CAIRO_SURFACE_TYPE_IMAGE, 1); } diff -r -u luacairo-1.10.2.0-src\src\lcairo-ud-linear-gradient-pattern.c luacairo\src\lcairo-ud-linear-gradient-pattern.c --- luacairo-1.10.2.0-src\src\lcairo-ud-linear-gradient-pattern.c Wed Sep 15 18:47:16 2010 +++ luacairo\src\lcairo-ud-linear-gradient-pattern.c Sat Nov 05 14:08:15 2011 @@ -21,14 +21,17 @@ static int new_LinearGradient (lua_State *L) { + double x0,y0,x1,y1; + cairo_pattern_t *cp; + lua_remove(L, 1); // remove cairo.LinearGradient //{"create_linear", l_cairo_pattern_create_linear}, - double x0 = luaL_checknumber(L, 1); - double y0 = luaL_checknumber(L, 2); - double x1 = luaL_checknumber(L, 3); - double y1 = luaL_checknumber(L, 4); - cairo_pattern_t *cp = cairo_pattern_create_linear(x0, y0, x1, y1); + x0 = luaL_checknumber(L, 1); + y0 = luaL_checknumber(L, 2); + x1 = luaL_checknumber(L, 3); + y1 = luaL_checknumber(L, 4); + cp = cairo_pattern_create_linear(x0, y0, x1, y1); return new_Pattern(L, LUACAIRO ".LinearGradient.mt", cp, CAIRO_PATTERN_TYPE_LINEAR, 1); } diff -r -u luacairo-1.10.2.0-src\src\lcairo-ud-matrix.c luacairo\src\lcairo-ud-matrix.c --- luacairo-1.10.2.0-src\src\lcairo-ud-matrix.c Thu Sep 16 09:35:00 2010 +++ luacairo\src\lcairo-ud-matrix.c Sat Nov 05 14:10:50 2011 @@ -20,10 +20,11 @@ static cairo_matrix_t check_Matrix(lua_State* L, int idx) { - luaL_checktype(L, idx, LUA_TTABLE); + cairo_matrix_t matrix; + + luaL_checktype(L, idx, LUA_TTABLE); lua_pushvalue(L, idx); // copy table to top - cairo_matrix_t matrix; matrix.xx = get_numfield(L, "xx"); matrix.yx = get_numfield(L, "yx"); matrix.xy = get_numfield(L, "xy"); @@ -37,11 +38,13 @@ static int new_Matrix (lua_State *L) { + cairo_matrix_t *m; + cairo_matrix_t mtin = {0, 0, 0, 0, 0, 0}; int top = lua_gettop(L); if (top > 1) mtin = check_Matrix(L, 2); - cairo_matrix_t *m = (cairo_matrix_t *) lua_newuserdata(L, sizeof(cairo_matrix_t)); + m = (cairo_matrix_t *) lua_newuserdata(L, sizeof(cairo_matrix_t)); *m = mtin; luaL_getmetatable(L, LUACAIRO ".Matrix.mt"); @@ -80,7 +83,7 @@ {NULL, NULL} }; -static const Xet_reg_pre Matrix_getters[] = { +static Xet_reg_pre Matrix_getters[] = { {"xx", Xet_get_number, offsetof(cairo_matrix_t, xx) }, {"yx", Xet_get_number, offsetof(cairo_matrix_t, yx) }, {"xy", Xet_get_number, offsetof(cairo_matrix_t, xy) }, @@ -90,7 +93,7 @@ {0, 0, 0} }; -static const Xet_reg_pre Matrix_setters[] = { +static Xet_reg_pre Matrix_setters[] = { {"xx", Xet_set_number, offsetof(cairo_matrix_t, xx) }, {"yx", Xet_set_number, offsetof(cairo_matrix_t, yx) }, {"xy", Xet_set_number, offsetof(cairo_matrix_t, xy) }, diff -r -u luacairo-1.10.2.0-src\src\lcairo-ud-path.c luacairo\src\lcairo-ud-path.c --- luacairo-1.10.2.0-src\src\lcairo-ud-path.c Fri Oct 22 16:52:42 2010 +++ luacairo\src\lcairo-ud-path.c Sat Nov 05 14:15:52 2011 @@ -29,6 +29,10 @@ static int new_Path (lua_State *L) { + cairo_t *cr; + cairo_path_t *path; + Path *o; + lua_remove(L, 1); // remove cairo.Path // cairo_public cairo_path_t * @@ -37,10 +41,10 @@ // cairo_public cairo_path_t * // cairo_copy_path_flat (cairo_t *cr); - cairo_t *cr = get_cairo_t (L, 1); - cairo_path_t *path = cairo_copy_path (cr); + cr = get_cairo_t (L, 1); + path = cairo_copy_path (cr); - Path *o = (Path *) lua_newuserdata(L, sizeof(Path)); + o = (Path *) lua_newuserdata(L, sizeof(Path)); o->path_ = path; o->havepath_ = 1; diff -r -u luacairo-1.10.2.0-src\src\lcairo-ud-pdf-surface.c luacairo\src\lcairo-ud-pdf-surface.c --- luacairo-1.10.2.0-src\src\lcairo-ud-pdf-surface.c Fri Sep 17 15:38:00 2010 +++ luacairo\src\lcairo-ud-pdf-surface.c Sat Nov 05 14:16:30 2011 @@ -21,16 +21,21 @@ static int new_PdfSurface (lua_State *L) { + const char *filename; + double width_in_points; + double height_in_points; + cairo_surface_t *cs; + lua_remove(L, 1); // remove cairo.PdfSurface //FIXME //{"create_for_stream", l_cairo_pdf_surface_create_for_stream}, //{"create", l_cairo_pdf_surface_create}, - const char *filename = luaL_checkstring(L, 1); - double width_in_points = luaL_checknumber(L, 2); - double height_in_points = luaL_checknumber(L, 3); - cairo_surface_t *cs = cairo_pdf_surface_create(filename, width_in_points, height_in_points); + filename = luaL_checkstring(L, 1); + width_in_points = luaL_checknumber(L, 2); + height_in_points = luaL_checknumber(L, 3); + cs = cairo_pdf_surface_create(filename, width_in_points, height_in_points); return new_Surface(L, LUACAIRO ".PdfSurface.mt", cs, CAIRO_SURFACE_TYPE_PDF, 1); } diff -r -u luacairo-1.10.2.0-src\src\lcairo-ud-ps-surface.c luacairo\src\lcairo-ud-ps-surface.c --- luacairo-1.10.2.0-src\src\lcairo-ud-ps-surface.c Fri Sep 17 15:38:16 2010 +++ luacairo\src\lcairo-ud-ps-surface.c Sat Nov 05 14:09:07 2011 @@ -21,16 +21,21 @@ static int new_PsSurface (lua_State *L) { + const char *filename; + double width_in_points; + double height_in_points; + cairo_surface_t *cs; + lua_remove(L, 1); // remove cairo.PsSurface //FIXME //{"create_for_stream", l_cairo_ps_surface_create_for_stream}, //{"create", l_cairo_ps_surface_create}, - const char *filename = luaL_checkstring(L, 1); - double width_in_points = luaL_checknumber(L, 2); - double height_in_points = luaL_checknumber(L, 3); - cairo_surface_t *cs = cairo_ps_surface_create(filename, width_in_points, height_in_points); + filename = luaL_checkstring(L, 1); + width_in_points = luaL_checknumber(L, 2); + height_in_points = luaL_checknumber(L, 3); + cs = cairo_ps_surface_create(filename, width_in_points, height_in_points); return new_Surface(L, LUACAIRO ".PsSurface.mt", cs, CAIRO_SURFACE_TYPE_PS, 1); } diff -r -u luacairo-1.10.2.0-src\src\lcairo-ud-radial-gradient-pattern.c luacairo\src\lcairo-ud-radial-gradient-pattern.c --- luacairo-1.10.2.0-src\src\lcairo-ud-radial-gradient-pattern.c Wed Sep 15 18:50:08 2010 +++ luacairo\src\lcairo-ud-radial-gradient-pattern.c Sat Nov 05 14:17:16 2011 @@ -22,16 +22,19 @@ static int new_RadialGradient (lua_State *L) { + double cx0,cy0,radius0, cx1,cy1,radius1; + cairo_pattern_t *cp; + lua_remove(L, 1); // remove cairo.RadialGradient //{"create_radial", l_cairo_pattern_create_radial}, - double cx0 = luaL_checknumber(L, 1); - double cy0 = luaL_checknumber(L, 2); - double radius0 = luaL_checknumber(L, 3); - double cx1 = luaL_checknumber(L, 4); - double cy1 = luaL_checknumber(L, 5); - double radius1 = luaL_checknumber(L, 6); - cairo_pattern_t *cp = cairo_pattern_create_radial(cx0, cy0, radius0, cx1, cy1, radius1); + cx0 = luaL_checknumber(L, 1); + cy0 = luaL_checknumber(L, 2); + radius0 = luaL_checknumber(L, 3); + cx1 = luaL_checknumber(L, 4); + cy1 = luaL_checknumber(L, 5); + radius1 = luaL_checknumber(L, 6); + cp = cairo_pattern_create_radial(cx0, cy0, radius0, cx1, cy1, radius1); return new_Pattern(L, LUACAIRO ".RadialGradient.mt", cp, CAIRO_PATTERN_TYPE_RADIAL, 1); } diff -r -u luacairo-1.10.2.0-src\src\lcairo-ud-rectangle-int.c luacairo\src\lcairo-ud-rectangle-int.c --- luacairo-1.10.2.0-src\src\lcairo-ud-rectangle-int.c Fri Sep 17 13:30:22 2010 +++ luacairo\src\lcairo-ud-rectangle-int.c Sat Nov 05 14:11:47 2011 @@ -22,10 +22,11 @@ static cairo_rectangle_int_t check_RectangleInt(lua_State* L, int idx) { - luaL_checktype(L, idx, LUA_TTABLE); + cairo_rectangle_int_t rect; + + luaL_checktype(L, idx, LUA_TTABLE); lua_pushvalue(L, idx); // copy table to top - cairo_rectangle_int_t rect; rect.x = get_numfield(L, "x"); rect.y = get_numfield(L, "y"); rect.width = get_numfield(L, "width"); @@ -37,11 +38,12 @@ static int new_RectangleInt (lua_State *L) { - cairo_rectangle_int_t rectin = {0, 0, 0, 0}; + cairo_rectangle_int_t *rect; + cairo_rectangle_int_t rectin = {0, 0, 0, 0}; int top = lua_gettop(L); if (top > 1) rectin = check_RectangleInt(L, 2); - cairo_rectangle_int_t *rect = (cairo_rectangle_int_t *) lua_newuserdata(L, sizeof(cairo_rectangle_int_t)); + rect = (cairo_rectangle_int_t *) lua_newuserdata(L, sizeof(cairo_rectangle_int_t)); *rect = rectin; luaL_getmetatable(L, LUACAIRO ".RectangleInt.mt"); @@ -68,7 +70,7 @@ {NULL, NULL} }; -static const Xet_reg_pre RectangleInt_getters[] = { +static Xet_reg_pre RectangleInt_getters[] = { {"x", Xet_get_number, offsetof(cairo_rectangle_int_t, x) }, {"y", Xet_get_number, offsetof(cairo_rectangle_int_t, y) }, {"width", Xet_get_number, offsetof(cairo_rectangle_int_t, width) }, @@ -76,7 +78,7 @@ {0, 0, 0} }; -static const Xet_reg_pre RectangleInt_setters[] = { +static Xet_reg_pre RectangleInt_setters[] = { {"x", Xet_set_number, offsetof(cairo_rectangle_int_t, x) }, {"y", Xet_set_number, offsetof(cairo_rectangle_int_t, y) }, {"width", Xet_set_number, offsetof(cairo_rectangle_int_t, width) }, diff -r -u luacairo-1.10.2.0-src\src\lcairo-ud-region.c luacairo\src\lcairo-ud-region.c --- luacairo-1.10.2.0-src\src\lcairo-ud-region.c Fri Sep 17 17:01:42 2010 +++ luacairo\src\lcairo-ud-region.c Sat Nov 05 14:18:00 2011 @@ -30,7 +30,12 @@ static int new_Region (lua_State *L) { - lua_remove(L, 1); // remove cairo.Region + cairo_rectangle_int_t *rectangle = NULL; + cairo_region_t *reg = NULL; + int top; + Region *o; + + lua_remove(L, 1); // remove cairo.Region // cairo_public cairo_region_t * // cairo_region_create (void); @@ -38,17 +43,16 @@ // cairo_public cairo_region_t * // cairo_region_create_rectangle (const cairo_rectangle_int_t *rectangle); - cairo_rectangle_int_t *rectangle = NULL; - int top = lua_gettop(L); + top = lua_gettop(L); if (top > 0) rectangle = get_userdata (L, 1, LUACAIRO ".RectangleInt.mt"); - cairo_region_t *reg = NULL; + if (rectangle) reg = cairo_region_create_rectangle (rectangle); else reg = cairo_region_create (); - Region *o = (Region *) lua_newuserdata(L, sizeof(Region)); + o = (Region *) lua_newuserdata(L, sizeof(Region)); o->reg_ = reg; o->havereg_ = 1; diff -r -u luacairo-1.10.2.0-src\src\lcairo-ud-scaled-font.c luacairo\src\lcairo-ud-scaled-font.c --- luacairo-1.10.2.0-src\src\lcairo-ud-scaled-font.c Wed Sep 15 19:33:04 2010 +++ luacairo\src\lcairo-ud-scaled-font.c Sat Nov 05 14:12:40 2011 @@ -100,13 +100,19 @@ static int new_ScaledFont_default (lua_State *L) { + cairo_font_face_t *font_face; + const cairo_matrix_t *font_matrix; + const cairo_matrix_t *ctm; + const cairo_font_options_t *options; + cairo_scaled_font_t *sf; + lua_remove(L, 1); // remove cairo.ScaledFont - cairo_font_face_t *font_face = get_cairo_font_face_t (L, 1); - const cairo_matrix_t *font_matrix = get_cairo_matrix_t (L, 2); - const cairo_matrix_t *ctm = get_cairo_matrix_t (L, 3); - const cairo_font_options_t *options = get_cairo_font_options_t (L, 4); - cairo_scaled_font_t *sf = cairo_scaled_font_create (font_face, font_matrix, ctm, options); + font_face = get_cairo_font_face_t (L, 1); + font_matrix = get_cairo_matrix_t (L, 2); + ctm = get_cairo_matrix_t (L, 3); + options = get_cairo_font_options_t (L, 4); + sf = cairo_scaled_font_create (font_face, font_matrix, ctm, options); return new_ScaledFont(L, LUACAIRO ".ScaledFont.mt", sf, 0, 1); } diff -r -u luacairo-1.10.2.0-src\src\lcairo-ud-solid-pattern.c luacairo\src\lcairo-ud-solid-pattern.c --- luacairo-1.10.2.0-src\src\lcairo-ud-solid-pattern.c Wed Sep 15 18:36:04 2010 +++ luacairo\src\lcairo-ud-solid-pattern.c Sat Nov 05 14:18:44 2011 @@ -21,17 +21,20 @@ static int new_SolidPattern (lua_State *L) { - lua_remove(L, 1); // remove cairo.SolidPattern + cairo_pattern_t* cp = NULL; + double red,green,blue,alpha; + + lua_remove(L, 1); // remove cairo.SolidPattern //{"create_rgb", l_cairo_pattern_create_rgb}, //{"create_rgba", l_cairo_pattern_create_rgba}, - double red = luaL_checknumber(L, 1); - double green = luaL_checknumber(L, 2); - double blue = luaL_checknumber(L, 3); - double alpha = luaL_optnumber(L, 4, -1); + red = luaL_checknumber(L, 1); + green = luaL_checknumber(L, 2); + blue = luaL_checknumber(L, 3); + alpha = luaL_optnumber(L, 4, -1); + - cairo_pattern_t* cp = NULL; if (alpha < 0) cp = cairo_pattern_create_rgb (red, green, blue); diff -r -u luacairo-1.10.2.0-src\src\lcairo-ud-surface-pattern.c luacairo\src\lcairo-ud-surface-pattern.c --- luacairo-1.10.2.0-src\src\lcairo-ud-surface-pattern.c Wed Sep 15 18:40:22 2010 +++ luacairo\src\lcairo-ud-surface-pattern.c Sat Nov 05 14:19:17 2011 @@ -21,11 +21,14 @@ static int new_SurfacePattern (lua_State *L) { + cairo_surface_t *surface; + cairo_pattern_t *cp; + lua_remove(L, 1); // remove cairo.SurfacePattern //{"create_for_surface", l_cairo_pattern_create_for_surface}, - cairo_surface_t *surface = get_cairo_surface_t (L, 1); - cairo_pattern_t *cp = cairo_pattern_create_for_surface (surface); + surface = get_cairo_surface_t (L, 1); + cp = cairo_pattern_create_for_surface (surface); return new_Pattern(L, LUACAIRO ".SurfacePattern.mt", cp, CAIRO_PATTERN_TYPE_SURFACE, 1); } diff -r -u luacairo-1.10.2.0-src\src\lcairo-ud-svg-surface.c luacairo\src\lcairo-ud-svg-surface.c --- luacairo-1.10.2.0-src\src\lcairo-ud-svg-surface.c Fri Sep 17 15:39:24 2010 +++ luacairo\src\lcairo-ud-svg-surface.c Sat Nov 05 14:19:51 2011 @@ -22,16 +22,21 @@ static int new_SvgSurface (lua_State *L) { + const char *filename; + double width_in_points; + double height_in_points; + cairo_surface_t *cs; + lua_remove(L, 1); // remove cairo.SvgSurface //FIXME //{"create_for_stream", l_cairo_svg_surface_create_for_stream}, //{"create", l_cairo_svg_surface_create}, - const char *filename = luaL_checkstring(L, 1); - double width_in_points = luaL_checknumber(L, 2); - double height_in_points = luaL_checknumber(L, 3); - cairo_surface_t *cs = cairo_svg_surface_create(filename, width_in_points, height_in_points); + filename = luaL_checkstring(L, 1); + width_in_points = luaL_checknumber(L, 2); + height_in_points = luaL_checknumber(L, 3); + cs = cairo_svg_surface_create(filename, width_in_points, height_in_points); return new_Surface(L, LUACAIRO ".SvgSurface.mt", cs, CAIRO_SURFACE_TYPE_SVG, 1); } diff -r -u luacairo-1.10.2.0-src\src\lcairo-ud-text-extents.c luacairo\src\lcairo-ud-text-extents.c --- luacairo-1.10.2.0-src\src\lcairo-ud-text-extents.c Thu Sep 16 09:42:28 2010 +++ luacairo\src\lcairo-ud-text-extents.c Sat Nov 05 14:11:47 2011 @@ -20,10 +20,11 @@ static cairo_text_extents_t check_TextExtents(lua_State* L, int idx) { - luaL_checktype(L, idx, LUA_TTABLE); + cairo_text_extents_t extents; + + luaL_checktype(L, idx, LUA_TTABLE); lua_pushvalue(L, idx); // copy table to top - cairo_text_extents_t extents; extents.x_bearing = get_numfield(L, "x_bearing"); extents.y_bearing = get_numfield(L, "y_bearing"); extents.width = get_numfield(L, "width"); @@ -37,11 +38,12 @@ static int new_TextExtents (lua_State *L) { + cairo_text_extents_t *te; cairo_text_extents_t tein = {0, 0, 0, 0, 0, 0}; int top = lua_gettop(L); if (top > 1) tein = check_TextExtents(L, 2); - cairo_text_extents_t *te = (cairo_text_extents_t *) lua_newuserdata(L, sizeof(cairo_text_extents_t)); + te = (cairo_text_extents_t *) lua_newuserdata(L, sizeof(cairo_text_extents_t)); *te = tein; luaL_getmetatable(L, LUACAIRO ".TextExtents.mt"); @@ -68,7 +70,7 @@ {NULL, NULL} }; -static const Xet_reg_pre TextExtents_getters[] = { +static Xet_reg_pre TextExtents_getters[] = { {"x_bearing", Xet_get_number, offsetof(cairo_text_extents_t, x_bearing) }, {"y_bearing", Xet_get_number, offsetof(cairo_text_extents_t, y_bearing) }, {"width", Xet_get_number, offsetof(cairo_text_extents_t, width) }, @@ -78,7 +80,7 @@ {0, 0, 0} }; -static const Xet_reg_pre TextExtents_setters[] = { +static Xet_reg_pre TextExtents_setters[] = { {"x_bearing", Xet_set_number, offsetof(cairo_text_extents_t, x_bearing) }, {"y_bearing", Xet_set_number, offsetof(cairo_text_extents_t, y_bearing) }, {"width", Xet_set_number, offsetof(cairo_text_extents_t, width) }, diff -r -u luacairo-1.10.2.0-src\src\lcairo-ud-toy-font-face.c luacairo\src\lcairo-ud-toy-font-face.c --- luacairo-1.10.2.0-src\src\lcairo-ud-toy-font-face.c Wed Sep 15 15:28:20 2010 +++ luacairo\src\lcairo-ud-toy-font-face.c Sat Nov 05 14:20:29 2011 @@ -22,12 +22,17 @@ static int new_ToyFontFace (lua_State *L) { + const char *family; + cairo_font_slant_t slant; + cairo_font_weight_t weight; + cairo_font_face_t *ff; + lua_remove(L, 1); // remove cairo.ToyFontFace - const char *family = luaL_checkstring(L, 1); - cairo_font_slant_t slant = (cairo_font_slant_t) luaL_checkinteger(L, 2); - cairo_font_weight_t weight = (cairo_font_weight_t) luaL_checkinteger(L, 3); - cairo_font_face_t *ff = cairo_toy_font_face_create (family, slant, weight); + family = luaL_checkstring(L, 1); + slant = (cairo_font_slant_t) luaL_checkinteger(L, 2); + weight = (cairo_font_weight_t) luaL_checkinteger(L, 3); + ff = cairo_toy_font_face_create (family, slant, weight); return new_FontFace(L, LUACAIRO ".ToyFontFace.mt", ff, CAIRO_FONT_TYPE_TOY, 1); } diff -r -u luacairo-1.10.2.0-src\src\lcairo-ud-user-font-face.c luacairo\src\lcairo-ud-user-font-face.c --- luacairo-1.10.2.0-src\src\lcairo-ud-user-font-face.c Wed Sep 15 15:46:22 2010 +++ luacairo\src\lcairo-ud-user-font-face.c Sat Nov 05 14:20:44 2011 @@ -22,9 +22,10 @@ static int new_UserFontFace (lua_State *L) { + cairo_font_face_t *ff; lua_remove(L, 1); // remove cairo.UserFontFace - cairo_font_face_t *ff = cairo_user_font_face_create (); + ff = cairo_user_font_face_create (); return new_FontFace(L, LUACAIRO ".UserFontFace.mt", ff, CAIRO_FONT_TYPE_USER, 1); } diff -r -u luacairo-1.10.2.0-src\src\lcairo-ud-win32-font-face.c luacairo\src\lcairo-ud-win32-font-face.c --- luacairo-1.10.2.0-src\src\lcairo-ud-win32-font-face.c Wed Sep 15 15:34:44 2010 +++ luacairo\src\lcairo-ud-win32-font-face.c Sat Nov 05 14:21:03 2011 @@ -22,6 +22,9 @@ static int new_Win32FontFace (lua_State *L) { + LOGFONTW *logfont; + cairo_font_face_t *ff; + lua_remove(L, 1); // remove cairo.Win32FontFace //FIXME @@ -31,8 +34,8 @@ //{"win32_font_face_create_for_logfontw_hfont",l_cairo_win32_font_face_create_for_logfontw_hfont}, #endif - LOGFONTW *logfont = (LOGFONTW *) check_lightuserdata(L, 1); - cairo_font_face_t *ff = cairo_win32_font_face_create_for_logfontw (logfont); + logfont = (LOGFONTW *) check_lightuserdata(L, 1); + ff = cairo_win32_font_face_create_for_logfontw (logfont); return new_FontFace(L, LUACAIRO ".Win32FontFace.mt", ff, CAIRO_FONT_TYPE_WIN32, 1); } diff -r -u luacairo-1.10.2.0-src\src\lcairo-ud-win32-scaled-font.c luacairo\src\lcairo-ud-win32-scaled-font.c --- luacairo-1.10.2.0-src\src\lcairo-ud-win32-scaled-font.c Wed Sep 15 16:11:02 2010 +++ luacairo\src\lcairo-ud-win32-scaled-font.c Sat Nov 05 14:21:50 2011 @@ -22,13 +22,19 @@ static int new_Win32ScaledFont (lua_State *L) { + cairo_font_face_t *font_face; + const cairo_matrix_t *font_matrix; + const cairo_matrix_t *ctm; + const cairo_font_options_t *options ; + cairo_scaled_font_t *sf; + lua_remove(L, 1); // remove cairo.Win32ScaledFont - cairo_font_face_t *font_face = get_cairo_font_face_t (L, 1); - const cairo_matrix_t *font_matrix = get_cairo_matrix_t (L, 2); - const cairo_matrix_t *ctm = get_cairo_matrix_t (L, 3); - const cairo_font_options_t *options = get_cairo_font_options_t (L, 4); - cairo_scaled_font_t *sf = cairo_scaled_font_create (font_face, font_matrix, ctm, options); + font_face = get_cairo_font_face_t (L, 1); + font_matrix = get_cairo_matrix_t (L, 2); + ctm = get_cairo_matrix_t (L, 3); + options = get_cairo_font_options_t (L, 4); + sf = cairo_scaled_font_create (font_face, font_matrix, ctm, options); return new_ScaledFont(L, LUACAIRO ".Win32ScaledFont.mt", sf, 1, 1); } diff -r -u luacairo-1.10.2.0-src\src\lcairo-ud-win32-surface.c luacairo\src\lcairo-ud-win32-surface.c --- luacairo-1.10.2.0-src\src\lcairo-ud-win32-surface.c Fri Sep 17 15:39:54 2010 +++ luacairo\src\lcairo-ud-win32-surface.c Sat Nov 05 14:22:31 2011 @@ -22,6 +22,9 @@ static int new_Win32Surface (lua_State *L) { + HDC hdc; + cairo_surface_t *cs; + lua_remove(L, 1); // remove cairo.Win32Surface //FIXME @@ -29,8 +32,8 @@ //{"create_with_dib", l_cairo_win32_surface_create_with_dib}, //{"create", l_cairo_win32_surface_create}, - HDC hdc = (HDC) check_lightuserdata(L, 1); - cairo_surface_t *cs = cairo_win32_surface_create(hdc); + hdc = (HDC) check_lightuserdata(L, 1); + cs = cairo_win32_surface_create(hdc); return new_Surface(L, LUACAIRO ".Win32Surface.mt", cs, CAIRO_SURFACE_TYPE_WIN32, 1); } @@ -116,11 +119,14 @@ static int new_Win32PrintingSurface (lua_State *L) { + HDC hdc; + cairo_surface_t *cs; + lua_remove(L, 1); // remove cairo.Win32PrintingSurface //{"create", l_cairo_win32_printing_surface_create}, - HDC hdc = (HDC) check_lightuserdata(L, 1); - cairo_surface_t *cs = cairo_win32_printing_surface_create(hdc); + hdc = (HDC) check_lightuserdata(L, 1); + cs = cairo_win32_printing_surface_create(hdc); return new_Surface(L, LUACAIRO ".Win32PrintingSurface.mt", cs, CAIRO_SURFACE_TYPE_WIN32_PRINTING, 1); } diff -r -u luacairo-1.10.2.0-src\src\lcairo.c luacairo\src\lcairo.c --- luacairo-1.10.2.0-src\src\lcairo.c Tue Jan 11 12:45:16 2011 +++ luacairo\src\lcairo.c Sat Nov 05 14:26:26 2011 @@ -277,7 +277,7 @@ #include "lcairo-private-getters.c" -int luaopen_lcairo(lua_State* L) +LUA_API int luaopen_lcairo(lua_State* L) { luaopen_lcairo_private (L); luaopen_lcairo_ud_font_extents (L);