From 8bd41caa51e080fd3ef28c7cdeee775872cdc1f4 Mon Sep 17 00:00:00 2001 From: Brenden Matthews Date: Wed, 25 Nov 2009 12:52:44 -0800 Subject: [PATCH] Add creation functions for certain cairo structures. --- doc/docs.xml | 13 +++++++++---- doc/lua.xml | 39 +++++++++++++++++++++++++++++++++++++++ lua/Makefile.am | 23 +++++++++++++++-------- lua/cairo.pkg | 4 ++++ lua/libcairo-helper.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 109 insertions(+), 12 deletions(-) create mode 100644 lua/libcairo-helper.h diff --git a/doc/docs.xml b/doc/docs.xml index 1019c882..6a370648 100644 --- a/doc/docs.xml +++ b/doc/docs.xml @@ -208,10 +208,10 @@ Lua API - Conky features a Lua Programming API, and also ships with - some Lua bindings for some useful libraries. Conky defines - certain global functions and variables which can be accessed - from Lua code running in Conky. + Conky features a Lua Programming API, and also ships with Lua + bindings for some useful libraries. Conky defines certain global + functions and variables which can be accessed from Lua code running + in Conky. To use Lua Conky, you first need to make sure you have a version of Conky with Lua support enabled (``conky -v'' will report this). Scripts @@ -228,6 +228,11 @@ At this time, the Lua API should not be considered stable and may change drastically from one release to another as it matures. + + NOTE: In order to accommodate certain features in the cairo + library's API, Conky will export a few additional functions for the + creation of certain structures. These are documented below. + &lua; diff --git a/doc/lua.xml b/doc/lua.xml index 7ae3db87..e55e1599 100644 --- a/doc/lua.xml +++ b/doc/lua.xml @@ -186,4 +186,43 @@ configuration file. + + + + + + + + + + Call this function to return a new cairo_text_extents_t structure. A creation function for this structure is not provided by the cairo API. After calling this, you should use tolua.takeownership() on the return value to ensure ownership is passed properly. + + + + + + + + + + + + + Call this function to return a new cairo_font_extents_t structure. A creation function for this structure is not provided by the cairo API. After calling this, you should use tolua.takeownership() on the return value to ensure ownership is passed properly. + + + + + + + + + + + + + Call this function to return a new cairo_matrix_t structure. A creation function for this structure is not provided by the cairo API. After calling this, you should use tolua.takeownership() on the return value to ensure ownership is passed properly. + + + diff --git a/lua/Makefile.am b/lua/Makefile.am index 5f344cc4..467ed407 100644 --- a/lua/Makefile.am +++ b/lua/Makefile.am @@ -20,37 +20,44 @@ # along with this program. If not, see . # -libcairo_la_SOURCES = libcairo.c -libimlib2_la_SOURCES = libimlib2.c if BUILD_LUA if BUILD_LUA_CAIRO -libcairo = libcairo.la +libcairo_built_sources = libcairo.c -libcairo_la_CFLAGS = $(cairo_CFLAGS) $(cairo_xlib_CFLAGS) $(tolua_CFLAGS) -libcairo_la_LIBADD = $(cairo_LIBS) $(cairo_xlib_LIBS) $(tolua_LIBS) +libcairo = libcairo.la libcairo.c: cairo.pkg ${toluapp} -n cairo -o $@ $(srcdir)/cairo.pkg +libcairo_la_CFLAGS = $(cairo_CFLAGS) $(cairo_xlib_CFLAGS) $(tolua_CFLAGS) +libcairo_la_LIBADD = $(cairo_LIBS) $(cairo_xlib_LIBS) $(tolua_LIBS) +libcairo_la_SOURCES = cairo.pkg libcairo-helper.h libcairo.c + endif # BUILD_LUA_CAIRO if BUILD_LUA_IMLIB2 -libimlib2 = libimlib2.la +libimlib2_built_sources = libimlib2.c -libimlib2_la_CFLAGS = $(Imlib2_CFLAGS) $(tolua_CFLAGS) -libimlib2_la_LIBADD = $(Imlib2_LIBS) $(tolua_LIBS) +libimlib2 = libimlib2.la libimlib2.c: imlib2.pkg ${toluapp} -n imlib2 -o $@ $(srcdir)/imlib2.pkg +libimlib2_la_CFLAGS = $(Imlib2_CFLAGS) $(tolua_CFLAGS) +libimlib2_la_LIBADD = $(Imlib2_LIBS) $(tolua_LIBS) +libimlib2_la_SOURCES = imlib2.pkg libimlib2.c + endif # BUILD_LUA_IMLIB2 pkglib_LTLIBRARIES = $(libcairo) $(libimlib2) endif # BUILD_LUA +EXTRA_DIST = libcairo-helper.h +BUILT_SOURCES = $(cairo_built_sources) $(imlib2_built_sources) + # vi:set ts=4 sw=4 noet ai nocindent syntax=automake: diff --git a/lua/cairo.pkg b/lua/cairo.pkg index a2cd91a3..2a6a6cfd 100644 --- a/lua/cairo.pkg +++ b/lua/cairo.pkg @@ -3,6 +3,7 @@ $#include $#include $#include $#include +$#include "libcairo-helper.h" /* * This code was mostly copied from cairo.h and cairo-xlib.h with comments * removed. The licence noticed below is present for the sake of clarity. @@ -59,6 +60,7 @@ typedef struct _cairo_matrix { double yy; double x0; double y0; + static tolua_outside cairo_matrix_t* create_cairo_matrix_t @ create(); } cairo_matrix_t; typedef int cairo_bool_t; @@ -375,6 +377,7 @@ typedef struct { double height; double x_advance; double y_advance; + static tolua_outside cairo_text_extents_t* create_cairo_text_extents_t @ create(); } cairo_text_extents_t; typedef struct { @@ -383,6 +386,7 @@ typedef struct { double height; double max_x_advance; double max_y_advance; + static tolua_outside cairo_font_extents_t* create_cairo_font_extents_t @ create(); } cairo_font_extents_t; typedef enum _cairo_font_slant { diff --git a/lua/libcairo-helper.h b/lua/libcairo-helper.h new file mode 100644 index 00000000..92248fde --- /dev/null +++ b/lua/libcairo-helper.h @@ -0,0 +1,42 @@ +/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- + * + * Conky, a system monitor, based on torsmo + * + * Please see COPYING for details + * + * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al. + * (see AUTHORS) + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#ifndef _LIBCAIRO_HELPER_H_ +#define _LIBCAIRO_HELPER_H_ + +#include + +cairo_text_extents_t *create_cairo_text_extents_t(void) { + return calloc(1, sizeof(cairo_text_extents_t)); +} + +cairo_font_extents_t *create_cairo_font_extents_t(void) { + return calloc(1, sizeof(cairo_font_extents_t)); +} + +cairo_matrix_t *create_cairo_matrix_t(void) { + return calloc(1, sizeof(cairo_matrix_t)); +} + +#endif /* _LIBCAIRO_HELPER_H_ */