Add creation functions for certain cairo structures.
authorBrenden Matthews <brenden@diddyinc.com>
Wed, 25 Nov 2009 20:52:44 +0000 (12:52 -0800)
committerBrenden Matthews <brenden@diddyinc.com>
Wed, 25 Nov 2009 20:53:42 +0000 (12:53 -0800)
doc/docs.xml
doc/lua.xml
lua/Makefile.am
lua/cairo.pkg
lua/libcairo-helper.h [new file with mode: 0644]

index 1019c88..6a37064 100644 (file)
        </refsect1>
        <refsect1>
                <title>Lua API</title>
-               <para>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.
+               <para>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.
                </para>
                <para>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
                        At this time, the Lua API should not be considered stable and may
                        change drastically from one release to another as it matures.
                </para>
+               <para>
+                       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.
+               </para>
                &lua;
        </refsect1>
        <refsect1>
index 7ae3db8..e55e159 100644 (file)
             configuration file.</para>
         </listitem>
     </varlistentry>
+    <varlistentry>
+        <term>
+            <command>
+                <option>cairo_text_extents_t:create()</option>
+            </command>
+            <option>function</option>
+        </term>
+        <listitem>
+                       <para>
+                               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.
+                       </para>
+        </listitem>
+    </varlistentry>
+    <varlistentry>
+        <term>
+            <command>
+                <option>cairo_font_extents_t:create()</option>
+            </command>
+            <option>function</option>
+        </term>
+        <listitem>
+                       <para>
+                               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.
+                       </para>
+        </listitem>
+    </varlistentry>
+    <varlistentry>
+        <term>
+            <command>
+                <option>cairo_matrix_t:create()</option>
+            </command>
+            <option>function</option>
+        </term>
+        <listitem>
+                       <para>
+                               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.
+                       </para>
+        </listitem>
+    </varlistentry>
 </variablelist>
index 5f344cc..467ed40 100644 (file)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-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:
index a2cd91a..2a6a6cf 100644 (file)
@@ -3,6 +3,7 @@ $#include <cairo-deprecated.h>
 $#include <cairo.h>
 $#include <cairo-xlib.h>
 $#include <X11/Xlib.h>
+$#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 (file)
index 0000000..92248fd
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef _LIBCAIRO_HELPER_H_
+#define _LIBCAIRO_HELPER_H_
+
+#include <cairo.h>
+
+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_ */