summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDetlev Casanova <detlev.casanova@gmail.com>2010-07-19 14:48:51 +0200
committerDetlev Casanova <detlev.casanova@gmail.com>2010-07-19 14:48:51 +0200
commita3ac6869831b8cce7cd0f738019a0acc2271cbb8 (patch)
tree3e43f6f93ad00c80597d813df7bea10531e2fd66
parentba276428647f49fd7031f7a7f96f1d75458b523e (diff)
downloadlayman-a3ac6869831b8cce7cd0f738019a0acc2271cbb8.tar.gz
layman-a3ac6869831b8cce7cd0f738019a0acc2271cbb8.tar.bz2
layman-a3ac6869831b8cce7cd0f738019a0acc2271cbb8.zip
Add some more comments, rename interpreterInitialize to
laymanInitialize, add layman.h header
-rw-r--r--Makefile.am2
-rw-r--r--Makefile.in11
-rw-r--r--src/interpreter.c28
-rw-r--r--src/interpreter.h4
-rw-r--r--src/layman.h11
-rw-r--r--src/tester.c4
6 files changed, 42 insertions, 18 deletions
diff --git a/Makefile.am b/Makefile.am
index 17f3ac5..c12c925 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,7 +9,7 @@ liblayman_la_SOURCES = src/config.c src/dict.c src/interpreter.c src/laymanapi.c
liblayman_la_LIBADD = $(PYTHON_LIBS)
layman_includedir = $(includedir)/layman
-layman_include_HEADERS = src/config.h src/dict.h src/interpreter.h src/laymanapi.h src/message.h src/stringlist.h
+layman_include_HEADERS = src/layman.h src/config.h src/dict.h src/interpreter.h src/laymanapi.h src/message.h src/stringlist.h
#bin_PROGRAMS = tester
diff --git a/Makefile.in b/Makefile.in
index f21ffe3..0255cef 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -38,8 +38,9 @@ host_triplet = @host@
subdir = .
DIST_COMMON = README $(am__configure_deps) $(layman_include_HEADERS) \
$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
- $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
- config.guess config.sub depcomp install-sh ltmain.sh missing
+ $(top_srcdir)/configure $(top_srcdir)/src/Makefile.in AUTHORS \
+ COPYING ChangeLog INSTALL NEWS config.guess config.sub depcomp \
+ install-sh ltmain.sh missing
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@@ -47,7 +48,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno config.status.lineno
mkinstalldirs = $(install_sh) -d
-CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_FILES = src/Makefile
CONFIG_CLEAN_VPATH_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
@@ -229,7 +230,7 @@ liblayman_la_SOURCES = src/config.c src/dict.c src/interpreter.c src/laymanapi.c
#src/tester.c
liblayman_la_LIBADD = $(PYTHON_LIBS)
layman_includedir = $(includedir)/layman
-layman_include_HEADERS = src/config.h src/dict.h src/interpreter.h src/laymanapi.h src/message.h src/stringlist.h
+layman_include_HEADERS = src/layman.h src/config.h src/dict.h src/interpreter.h src/laymanapi.h src/message.h src/stringlist.h
all: all-am
.SUFFIXES:
@@ -268,6 +269,8 @@ $(top_srcdir)/configure: $(am__configure_deps)
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
$(am__aclocal_m4_deps):
+src/Makefile: $(top_builddir)/config.status $(top_srcdir)/src/Makefile.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
diff --git a/src/interpreter.c b/src/interpreter.c
index 151af2d..a372120 100644
--- a/src/interpreter.c
+++ b/src/interpreter.c
@@ -7,8 +7,9 @@
#include <string.h>
#include "interpreter.h"
-/*
+/**
* PyObjectList
+ * Stores modules in a linked list so that they don't have to be reloaded every time.
*/
typedef struct PyObjectListElem
{
@@ -90,7 +91,10 @@ struct Interpreter
PyObjectList *modules;
} *in = 0;
-void interpreterInit()
+/**
+ * This is the first function that must be called before using the library.
+ */
+void laymanInit()
{
if (in)
return;
@@ -102,7 +106,11 @@ void interpreterInit()
in->modules = createObjectList();
}
-void interpreterFinalize()
+/**
+ * Call this function when you're done using the library.
+ * It will free memory.
+ */
+void laymanFinalize()
{
if (!in)
return;
@@ -113,14 +121,16 @@ void interpreterFinalize()
Py_Finalize();
}
-/*
+/**
* printf() like function that executes a python function
- * @param module name of the python module in which the function is
- * @param funcName the function name to call
- * @param format printf() like list of arguments. See Python documentation
- * @param ... arguments for the function
+ *
+ * \param module name of the python module in which the function is
+ * \param funcName the function name to call
+ * \param format printf() like list of arguments. See Python documentation
+ * \param ... arguments for the function
+ *
+ * \return the result of the execution. Can be NULL if the call failed.
*/
-
PyObject *executeFunction(const char *module, const char *funcName, const char* format, ...)
{
if (!Py_IsInitialized())
diff --git a/src/interpreter.h b/src/interpreter.h
index 8e04ce0..b280ad2 100644
--- a/src/interpreter.h
+++ b/src/interpreter.h
@@ -1,7 +1,7 @@
#ifndef INTERPRETER_H
#define INTERPRETER_H
-void interpreterInit();
-void interpreterFinalize();
+void laymanInit();
+void laymanFinalize();
#endif
diff --git a/src/layman.h b/src/layman.h
new file mode 100644
index 0000000..9811ba5
--- /dev/null
+++ b/src/layman.h
@@ -0,0 +1,11 @@
+#ifndef LAYMAN_H
+#define LAYMAN_H
+
+#include "laymanapi.h"
+#include "message.h"
+#include "stringlist.h"
+#include "config.h"
+#include "dict.h"
+#include "interpreter.h"
+
+#endif
diff --git a/src/tester.c b/src/tester.c
index 98dc171..de0b6c7 100644
--- a/src/tester.c
+++ b/src/tester.c
@@ -9,7 +9,7 @@ int main(int argc, char *argv[])
argc = argc;
argv = argv;
int ret = 0;
- interpreterInit();
+ laymanInit();
Message *msg = messageCreate("layman", 0, 0, 0);
BareConfig *cfg = bareConfigCreate(msg, 0, 0, 0);
@@ -66,7 +66,7 @@ int main(int argc, char *argv[])
bareConfigFree(cfg);
laymanAPIFree(l);
- interpreterFinalize();
+ laymanFinalize();
return ret;
}