From b6548137de004fcf6f72d1f203473bc96a326eff Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 9 Sep 2013 21:40:57 +0200 Subject: [PATCH] Move confess_at() to utils.cpp --- xs/src/myinit.h | 37 +++---------------------------------- xs/src/utils.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 34 deletions(-) create mode 100644 xs/src/utils.cpp diff --git a/xs/src/myinit.h b/xs/src/myinit.h index 5d1c17a17..84175da96 100644 --- a/xs/src/myinit.h +++ b/xs/src/myinit.h @@ -20,39 +20,8 @@ namespace Slic3r {} using namespace Slic3r; /* Implementation of CONFESS("foo"): */ -#define CONFESS(...) \ - confess_at(__FILE__, __LINE__, __func__, __VA_ARGS__) - -void -do_confess(SV *error_sv) -{ - dSP; - ENTER; - SAVETMPS; - PUSHMARK(SP); - XPUSHs( sv_2mortal(error_sv) ); - PUTBACK; - call_pv("Carp::confess", G_DISCARD); - FREETMPS; - LEAVE; -} - -void -confess_at(const char *file, int line, const char *func, - const char *pat, ...) -{ - va_list args; - SV *error_sv = newSVpvf("Error in function %s at %s:%d: ", func, - file, line); - - va_start(args, pat); - sv_vcatpvf(error_sv, pat, &args); - va_end(args); - - sv_catpvn(error_sv, "\n\t", 2); - - do_confess(error_sv); -} -/* End implementation of CONFESS("foo") */ +#define CONFESS(...) confess_at(__FILE__, __LINE__, __func__, __VA_ARGS__) +void confess_at(const char *file, int line, const char *func, const char *pat, ...); +/* End implementation of CONFESS("foo"): */ #endif diff --git a/xs/src/utils.cpp b/xs/src/utils.cpp new file mode 100644 index 000000000..7a3b11ade --- /dev/null +++ b/xs/src/utils.cpp @@ -0,0 +1,26 @@ +#include + +void +confess_at(const char *file, int line, const char *func, + const char *pat, ...) +{ + va_list args; + SV *error_sv = newSVpvf("Error in function %s at %s:%d: ", func, + file, line); + + va_start(args, pat); + sv_vcatpvf(error_sv, pat, &args); + va_end(args); + + sv_catpvn(error_sv, "\n\t", 2); + + dSP; + ENTER; + SAVETMPS; + PUSHMARK(SP); + XPUSHs( sv_2mortal(error_sv) ); + PUTBACK; + call_pv("Carp::confess", G_DISCARD); + FREETMPS; + LEAVE; +}