mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
* src/engine/gw-glib-spec.scm: remove
* src/engine/gw-engine-spec.scm: g-wrap split & trans lookup * src/engine/gnc-engine-util.h: add more timing utils * src/engine/gnc-engine-util.c: add more timing utils * src/engine/Transaction.h: g-wrap split & trans lookup * src/engine/Transaction.c: g-wrap split & trans lookup * src/engine/Makefile.am: Take out glib wrapping cruft git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6613 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
16
ChangeLog
16
ChangeLog
@@ -1,3 +1,19 @@
|
||||
2002-01-12 Dave Peticolas <dave@krondo.com>
|
||||
|
||||
* src/engine/gw-glib-spec.scm: remove
|
||||
|
||||
* src/engine/gw-engine-spec.scm: g-wrap split & trans lookup
|
||||
|
||||
* src/engine/gnc-engine-util.h: add more timing utils
|
||||
|
||||
* src/engine/gnc-engine-util.c: add more timing utils
|
||||
|
||||
* src/engine/Transaction.h: g-wrap split & trans lookup
|
||||
|
||||
* src/engine/Transaction.c: g-wrap split & trans lookup
|
||||
|
||||
* src/engine/Makefile.am: Take out glib wrapping cruft
|
||||
|
||||
2002-01-09 Rob Browning <rlb@defaultvalue.org>
|
||||
|
||||
* lib/srfi/Makefile.am: handle conditional per-SRFI install.
|
||||
|
||||
@@ -90,9 +90,6 @@ libgncmod_engine_la_LIBADD = ${GNUCASH_ENGINE_BASE_LIBS} \
|
||||
${top_srcdir}/src/engine/libgw-engine.la \
|
||||
${top_srcdir}/src/engine/libgw-kvp.la
|
||||
|
||||
#libgw_glib_la_SOURCES = gw-glib.c
|
||||
#libgw_glib_la_LDFLAGS = -module ${G_WRAP_LINK_ARGS}
|
||||
|
||||
libgw_kvp_la_SOURCES = gw-kvp.c kvp-scm.c
|
||||
libgw_kvp_la_LDFLAGS = -module ${G_WRAP_LINK_ARGS}
|
||||
|
||||
@@ -149,12 +146,6 @@ gw-engine.scm gw-engine.c gw-engine.h: .scm-links gw-engine-spec.scm
|
||||
(primitive-load \"./gw-engine-spec.scm\") \
|
||||
(gw:generate-wrapset \"gw-engine\")"
|
||||
|
||||
#gw-glib.scm gw-glib.c gw-glib.h: .scm-links gw-glib-spec.scm
|
||||
# FLAVOR=gnome guile -c \
|
||||
# "(set! %load-path (cons \"${G_WRAP_MODULE_DIR}\" %load-path)) \
|
||||
# (primitive-load \"./gw-glib-spec.scm\") \
|
||||
# (gw:generate-wrapset \"gw-glib\")"
|
||||
|
||||
gw-kvp.scm gw-kvp.c gw-kvp.h: .scm-links gw-kvp-spec.scm
|
||||
FLAVOR=gnome guile -c \
|
||||
"(set! %load-path (cons \"${G_WRAP_MODULE_DIR}\" %load-path)) \
|
||||
|
||||
@@ -428,6 +428,14 @@ xaccSplitLookup (const GUID *guid, GNCBook *book)
|
||||
guid, GNC_ID_SPLIT);
|
||||
}
|
||||
|
||||
Split *
|
||||
xaccSplitLookupDirect (GUID guid, GNCBook *book)
|
||||
{
|
||||
if (!book) return NULL;
|
||||
return xaccLookupEntity(gnc_book_get_entity_table (book),
|
||||
&guid, GNC_ID_SPLIT);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
@@ -1091,7 +1099,8 @@ xaccTransSetGUID (Transaction *trans, const GUID *guid)
|
||||
if (!trans || !guid) return;
|
||||
xaccRemoveEntity(trans->book->entity_table, &trans->guid);
|
||||
trans->guid = *guid;
|
||||
xaccStoreEntity(trans->book->entity_table, trans, &trans->guid, GNC_ID_TRANS);
|
||||
xaccStoreEntity(trans->book->entity_table, trans,
|
||||
&trans->guid, GNC_ID_TRANS);
|
||||
}
|
||||
|
||||
|
||||
@@ -1106,6 +1115,14 @@ xaccTransLookup (const GUID *guid, GNCBook *book)
|
||||
guid, GNC_ID_TRANS);
|
||||
}
|
||||
|
||||
Transaction *
|
||||
xaccTransLookupDirect (GUID guid, GNCBook *book)
|
||||
{
|
||||
if (!book) return NULL;
|
||||
return xaccLookupEntity (gnc_book_get_entity_table (book),
|
||||
&guid, GNC_ID_TRANS);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ gboolean xaccTransIsOpen (Transaction *trans);
|
||||
const GUID * xaccTransGetGUID (Transaction *trans);
|
||||
GUID xaccTransReturnGUID (Transaction *trans);
|
||||
Transaction * xaccTransLookup (const GUID *guid, GNCBook *book);
|
||||
|
||||
Transaction * xaccTransLookupDirect (GUID guid, GNCBook *book);
|
||||
|
||||
/* Transaction slots are used to store arbitrary strings, numbers, and
|
||||
* structures which aren't members of the transaction struct. */
|
||||
@@ -279,6 +279,7 @@ void xaccSplitSetSlots_nc(Split *s, kvp_frame *frm);
|
||||
const GUID * xaccSplitGetGUID (Split *split);
|
||||
GUID xaccSplitReturnGUID (Split *split);
|
||||
Split * xaccSplitLookup (const GUID *guid, GNCBook *book);
|
||||
Split * xaccSplitLookupDirect (GUID guid, GNCBook *book);
|
||||
|
||||
/* The memo is an arbitrary string associated with a split.
|
||||
* Users typically type in free form text from the GUI.
|
||||
|
||||
@@ -64,6 +64,7 @@ static gncLogLevel loglevel[MOD_LAST + 1] =
|
||||
GNC_LOG_WARNING, /* KVP */
|
||||
GNC_LOG_DEBUG, /* SX */
|
||||
GNC_LOG_WARNING, /* BOOK */
|
||||
GNC_LOG_TRACE, /* TEST */
|
||||
};
|
||||
|
||||
static FILE *fout = NULL;
|
||||
@@ -173,9 +174,15 @@ struct timeval gnc_clock[NUM_CLOCKS] = {
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},
|
||||
};
|
||||
|
||||
static
|
||||
struct timeval gnc_clock_total[NUM_CLOCKS] = {
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},
|
||||
{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},
|
||||
};
|
||||
|
||||
void
|
||||
gnc_start_clock (int clockno, gncModuleType module, gncLogLevel log_level,
|
||||
const char *function_name, const char *format, ...)
|
||||
const char *function_name, const char *format, ...)
|
||||
{
|
||||
struct timezone tz;
|
||||
va_list ap;
|
||||
@@ -183,6 +190,8 @@ gnc_start_clock (int clockno, gncModuleType module, gncLogLevel log_level,
|
||||
if ((0>clockno) || (NUM_CLOCKS <= clockno)) return;
|
||||
gettimeofday (&gnc_clock[clockno], &tz);
|
||||
|
||||
if (!fout) fout = stderr;
|
||||
|
||||
fprintf (fout, "Clock %d Start: %s: ",
|
||||
clockno, prettify (function_name));
|
||||
|
||||
@@ -197,7 +206,7 @@ gnc_start_clock (int clockno, gncModuleType module, gncLogLevel log_level,
|
||||
|
||||
void
|
||||
gnc_report_clock (int clockno, gncModuleType module, gncLogLevel log_level,
|
||||
const char *function_name, const char *format, ...)
|
||||
const char *function_name, const char *format, ...)
|
||||
{
|
||||
struct timezone tz;
|
||||
struct timeval now;
|
||||
@@ -206,7 +215,7 @@ gnc_report_clock (int clockno, gncModuleType module, gncLogLevel log_level,
|
||||
if ((0>clockno) || (NUM_CLOCKS <= clockno)) return;
|
||||
gettimeofday (&now, &tz);
|
||||
|
||||
/* need to borrow to make differnce */
|
||||
/* need to borrow to make difference */
|
||||
if (now.tv_usec < gnc_clock[clockno].tv_usec)
|
||||
{
|
||||
now.tv_sec --;
|
||||
@@ -215,7 +224,12 @@ gnc_report_clock (int clockno, gncModuleType module, gncLogLevel log_level,
|
||||
now.tv_sec -= gnc_clock[clockno].tv_sec;
|
||||
now.tv_usec -= gnc_clock[clockno].tv_usec;
|
||||
|
||||
fprintf (fout, "Clock %d Elapsed: %ld.%06ld %s: ",
|
||||
gnc_clock_total[clockno].tv_sec += now.tv_sec;
|
||||
gnc_clock_total[clockno].tv_usec += now.tv_usec;
|
||||
|
||||
if (!fout) fout = stderr;
|
||||
|
||||
fprintf (fout, "Clock %d Elapsed: %ld.%06lds %s: ",
|
||||
clockno, now.tv_sec, now.tv_usec, prettify (function_name));
|
||||
|
||||
va_start (ap, format);
|
||||
@@ -227,6 +241,41 @@ gnc_report_clock (int clockno, gncModuleType module, gncLogLevel log_level,
|
||||
fprintf (fout, "\n");
|
||||
}
|
||||
|
||||
void
|
||||
gnc_report_clock_total (int clockno,
|
||||
gncModuleType module, gncLogLevel log_level,
|
||||
const char *function_name, const char *format, ...)
|
||||
{
|
||||
struct timezone tz;
|
||||
struct timeval now;
|
||||
va_list ap;
|
||||
|
||||
if ((0>clockno) || (NUM_CLOCKS <= clockno)) return;
|
||||
|
||||
/* need to normalize usec */
|
||||
while (gnc_clock_total[clockno].tv_usec >= 1000000)
|
||||
{
|
||||
gnc_clock_total[clockno].tv_sec ++;
|
||||
gnc_clock_total[clockno].tv_usec -= 1000000;
|
||||
}
|
||||
|
||||
if (!fout) fout = stderr;
|
||||
|
||||
fprintf (fout, "Clock %d Total Elapsed: %ld.%06lds %s: ",
|
||||
clockno,
|
||||
gnc_clock_total[clockno].tv_sec,
|
||||
gnc_clock_total[clockno].tv_usec,
|
||||
prettify (function_name));
|
||||
|
||||
va_start (ap, format);
|
||||
|
||||
vfprintf (fout, format, ap);
|
||||
|
||||
va_end (ap);
|
||||
|
||||
fprintf (fout, "\n");
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
@@ -62,7 +62,8 @@ typedef enum
|
||||
MOD_KVP = 15,
|
||||
MOD_SX = 16,
|
||||
MOD_BOOK = 17,
|
||||
MOD_LAST = 17
|
||||
MOD_TEST = 18,
|
||||
MOD_LAST = 18
|
||||
} gncModuleType;
|
||||
|
||||
typedef enum
|
||||
@@ -152,11 +153,19 @@ void gnc_log (gncModuleType module, gncLogLevel log_level,
|
||||
}
|
||||
|
||||
void gnc_start_clock (int clockno, gncModuleType module, gncLogLevel log_level,
|
||||
const char *function_name, const char *format, ...);
|
||||
const char *function_name, const char *format, ...);
|
||||
|
||||
void gnc_report_clock (int clockno, gncModuleType module, gncLogLevel log_level,
|
||||
const char *function_name, const char *format, ...);
|
||||
void gnc_report_clock (int clockno,
|
||||
gncModuleType module,
|
||||
gncLogLevel log_level,
|
||||
const char *function_name,
|
||||
const char *format, ...);
|
||||
|
||||
void gnc_report_clock_total (int clockno,
|
||||
gncModuleType module,
|
||||
gncLogLevel log_level,
|
||||
const char *function_name,
|
||||
const char *format, ...);
|
||||
|
||||
#define START_CLOCK(clockno,format, args...) { \
|
||||
if (gnc_should_log (module, GNC_LOG_INFO)) \
|
||||
@@ -170,6 +179,11 @@ void gnc_report_clock (int clockno, gncModuleType module, gncLogLevel log_level,
|
||||
__FUNCTION__, format, ## args); \
|
||||
}
|
||||
|
||||
#define REPORT_CLOCK_TOTAL(clockno,format, args...) { \
|
||||
if (gnc_should_log (module, GNC_LOG_INFO)) \
|
||||
gnc_report_clock_total (clockno, module, GNC_LOG_INFO, \
|
||||
__FUNCTION__, format, ## args); \
|
||||
}
|
||||
|
||||
/* Set the logging level of the given module. */
|
||||
void gnc_set_log_level(gncModuleType module, gncLogLevel level);
|
||||
|
||||
@@ -309,6 +309,15 @@
|
||||
'((<gnc:Split*> s))
|
||||
"Return the GUID of Split s.")
|
||||
|
||||
(gw:wrap-function
|
||||
ws
|
||||
'gnc:split-lookup
|
||||
'<gnc:Split*>
|
||||
"xaccSplitLookupDirect"
|
||||
'((<gnc:guid-scm> guid)
|
||||
(<gnc:Book*> book))
|
||||
"Lookup a split with its GUID.")
|
||||
|
||||
(gw:wrap-function
|
||||
ws
|
||||
'gnc:split-get-balance
|
||||
@@ -465,6 +474,15 @@ code of its account")
|
||||
'((<gnc:Transaction*> t))
|
||||
"Return the GUID of Transaction t.")
|
||||
|
||||
(gw:wrap-function
|
||||
ws
|
||||
'gnc:transaction-lookup
|
||||
'<gnc:Transaction*>
|
||||
"xaccTransLookupDirect"
|
||||
'((<gnc:guid-scm> guid)
|
||||
(<gnc:Book*> book))
|
||||
"Lookup a transaction with its GUID.")
|
||||
|
||||
(gw:wrap-function
|
||||
ws
|
||||
'gnc:transaction-get-split
|
||||
|
||||
@@ -1,195 +0,0 @@
|
||||
(use-modules (g-wrap))
|
||||
|
||||
(debug-set! maxdepth 100000)
|
||||
(debug-set! stack 2000000)
|
||||
|
||||
(define-module (g-wrapped gw-glib-spec)
|
||||
:use-module (g-wrap))
|
||||
|
||||
(let ((mod (gw:new-module "gw-glib")))
|
||||
|
||||
(define (standard-c-call-gen result func-call-code)
|
||||
(list (gw:result-get-c-name result) " = " func-call-code ";\n"))
|
||||
|
||||
(define (add-standard-result-handlers! type c->scm-converter)
|
||||
(define (standard-pre-handler result)
|
||||
(let* ((ret-type-name (gw:result-get-proper-c-type-name result))
|
||||
(ret-var-name (gw:result-get-c-name result)))
|
||||
(list "{\n"
|
||||
" " ret-type-name " " ret-var-name ";\n")))
|
||||
|
||||
(gw:type-set-pre-call-result-ccodegen! type standard-pre-handler)
|
||||
|
||||
(gw:type-set-post-call-result-ccodegen!
|
||||
type
|
||||
(lambda (result)
|
||||
(let* ((scm-name (gw:result-get-scm-name result))
|
||||
(c-name (gw:result-get-c-name result)))
|
||||
(list
|
||||
(c->scm-converter scm-name c-name)
|
||||
" }\n")))))
|
||||
|
||||
(gw:module-depends-on mod "gw-runtime")
|
||||
|
||||
(gw:module-set-guile-module! mod '(g-wrapped gw-glib))
|
||||
|
||||
;; All of this glib string code needs to be moved to the (g-wrapped
|
||||
;; glib) module, as does the supporting header code above -- we'll
|
||||
;; do that next time round.
|
||||
|
||||
(let ((nnt (gw:wrap-non-native-type mod '<glib:GList*>
|
||||
"GList*" "const GList*")))
|
||||
#t)
|
||||
|
||||
(gw:wrap-function
|
||||
mod
|
||||
'gnc:glist->list
|
||||
'<gw:scm> "gnc_glist_to_scm_list" '((<glib:GList*> glist) (<gw:wct> wct))
|
||||
"Convert glist to scheme list of wcp's of type wct.")
|
||||
|
||||
(gw:wrap-function
|
||||
mod
|
||||
'gnc:list->glist
|
||||
'<glib:GList*> "gnc_scm_list_to_glist" '((<gw:scm> wcp-list))
|
||||
"Convert scheme list of wcp's to GList*.")
|
||||
|
||||
(gw:wrap-function
|
||||
mod
|
||||
'gnc:glist-map
|
||||
'<gw:scm> "gnc_glist_scm_map" '((<gw:wct> wct) (<gw:scm> thunk) (<glib:GList*> glist))
|
||||
"Call thunk on every element of glist after conversion to wcp of type wct, "
|
||||
"and return a list of the results.")
|
||||
|
||||
(gw:wrap-function
|
||||
mod
|
||||
'gnc:glist-for-each
|
||||
'<gw:void> "gnc_glist_scm_for_each"
|
||||
'((<gw:wct> wct) (<gw:scm> thunk) (<glib:GList*> glist))
|
||||
"Call thunk on every element of glist after conversion to wcp of type wct.")
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; gint64
|
||||
(let ((wt (gw:wrap-type mod '<glib:gint64> "gint64" "const gint64")))
|
||||
|
||||
(gw:type-set-scm-arg-type-test-ccodegen!
|
||||
wt
|
||||
(lambda (param)
|
||||
;; I don't know if it's more efficient to work on the C side or
|
||||
;; the scheme side...
|
||||
(let ((x (gw:param-get-scm-name param)))
|
||||
(list "gnc_gh_gint64_p(" x ")"))))
|
||||
|
||||
(gw:type-set-pre-call-arg-ccodegen!
|
||||
wt
|
||||
(lambda (param)
|
||||
(let* ((scm-name (gw:param-get-scm-name param))
|
||||
(c-name (gw:param-get-c-name param)))
|
||||
(list
|
||||
c-name " = gnc_scm_to_gint64(" scm-name ");\n"))))
|
||||
|
||||
(gw:type-set-call-ccodegen! wt standard-c-call-gen)
|
||||
|
||||
(add-standard-result-handlers!
|
||||
wt
|
||||
(lambda (scm-name c-name)
|
||||
(list scm-name " = gnc_gint64_to_scm(" c-name ");\n"))))
|
||||
|
||||
|
||||
;; until we have a case for g-chars-callee-owned as arg or
|
||||
;; g-chars-caller-owned for result, then we don't need these, but
|
||||
;; they're ready to go right now.
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; g-chars-caller-owned
|
||||
;; g_newed gchar* (string), caller-owned
|
||||
;;
|
||||
;; arg temps will be allocated with g_new before call, g_freed on return.
|
||||
;; result temps will be g_freed after conversion to scheme.
|
||||
;;
|
||||
|
||||
(let ((wt (gw:wrap-type mod '<glib:g-chars-caller-owned>
|
||||
"gchar *" "const gchar *")))
|
||||
|
||||
(gw:type-set-scm-arg-type-test-ccodegen!
|
||||
wt
|
||||
(lambda (type param)
|
||||
(let ((x (gw:param-get-scm-name param)))
|
||||
(list "((" x " == SCM_BOOL_F) || SCM_STRINGP(" x "))"))))
|
||||
|
||||
(gw:type-set-pre-call-arg-ccodegen!
|
||||
wt
|
||||
(lambda (type param)
|
||||
(let* ((scm-name (gw:param-get-scm-name param))
|
||||
(c-name (gw:param-get-c-name param)))
|
||||
(list
|
||||
"{\n"
|
||||
" if(" scm-name " == SCM_BOOL_F) {\n"
|
||||
" " c-name " = NULL;\n"
|
||||
" } else {\n"
|
||||
" char *tmpstr = gh_scm2newstr(" scm-name ", NULL);\n"
|
||||
" " c-name " = g_strdup(tmpstr);\n"
|
||||
" free(tmpstr);\n"
|
||||
" }\n"
|
||||
"}\n"))))
|
||||
|
||||
(gw:type-set-call-ccodegen! wt standard-c-call-gen)
|
||||
|
||||
(gw:type-set-post-call-arg-ccodegen!
|
||||
wt
|
||||
(lambda (type param)
|
||||
(let* ((c-name (gw:param-get-c-name param)))
|
||||
(list "g_free((void *) " c-name ");\n"))))
|
||||
|
||||
(add-standard-result-handlers!
|
||||
wt
|
||||
(lambda (scm-name c-name)
|
||||
(list
|
||||
scm-name " = ((" c-name ") ? gh_str02scm(" c-name ") : SCM_BOOL_F);\n"
|
||||
"g_free((void *) " c-name ");\n"))))
|
||||
|
||||
(let ((wt (gw:wrap-type
|
||||
mod
|
||||
'<gnc:list-of-string>
|
||||
"GList *" "const GList *")))
|
||||
(gw:type-set-scm-arg-type-test-ccodegen!
|
||||
wt
|
||||
(lambda (param)
|
||||
(let ((old-func
|
||||
(lambda (x) (list "gnc_glist_string_p(" x ")"))))
|
||||
(old-func (gw:param-get-scm-name param)))))
|
||||
(gw:type-set-pre-call-arg-ccodegen!
|
||||
wt
|
||||
(lambda (param)
|
||||
(let* ((scm-name (gw:param-get-scm-name param))
|
||||
(c-name (gw:param-get-c-name param))
|
||||
(old-func
|
||||
(lambda (x)
|
||||
(list "gnc_scm_to_glist_string(" x ")"))))
|
||||
(list c-name
|
||||
" = "
|
||||
(old-func scm-name)
|
||||
";\n"))))
|
||||
(gw:type-set-call-ccodegen! wt standard-c-call-gen)
|
||||
|
||||
(add-standard-result-handlers!
|
||||
wt
|
||||
(lambda (scm-name c-name)
|
||||
(let ((old-func
|
||||
(lambda (x)
|
||||
(list "gnc_glist_string_to_scm(" x ")"))))
|
||||
(list scm-name
|
||||
" = "
|
||||
(old-func c-name)
|
||||
";\n")))))
|
||||
|
||||
(gw:module-set-declarations-ccodegen!
|
||||
mod
|
||||
(lambda (client-only?)
|
||||
(list
|
||||
"#include <glib.h>\n"
|
||||
"#include \"glib-helpers.h\"\n"))))
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user