Skip to content

Commit

Permalink
use "config.h"
Browse files Browse the repository at this point in the history
  • Loading branch information
alanlivio committed Nov 14, 2022
1 parent fe915c4 commit 2330e7c
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 168 deletions.
141 changes: 74 additions & 67 deletions lib/aux-ginga.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@ along with Ginga. If not, see <https://www.gnu.org/licenses/>. */
#ifndef AUX_GINGA_H
#define AUX_GINGA_H

#include "aux-glib.h"
#include "ginga.h"

GINGA_BEGIN_DECLS

#include <config.h>
#include "aux-glib.h"
#include "config.h"
#include <stdlib.h>

#define GINGA_PRAGMA_DIAG PRAGMA_DIAG
#define GINGA_PRAGMA_DIAG_PUSH PRAGMA_DIAG_PUSH
#define GINGA_PRAGMA_DIAG_POP PRAGMA_DIAG_POP
#define GINGA_PRAGMA_DIAG_IGNORE PRAGMA_DIAG_IGNORE
#define GINGA_PRAGMA_DIAG PRAGMA_DIAG
#define GINGA_PRAGMA_DIAG_PUSH PRAGMA_DIAG_PUSH
#define GINGA_PRAGMA_DIAG_POP PRAGMA_DIAG_POP
#define GINGA_PRAGMA_DIAG_IGNORE PRAGMA_DIAG_IGNORE
#define GINGA_PRAGMA_DIAG_WARNING PRAGMA_DIAG_WARNING

// C library.
Expand Down Expand Up @@ -60,85 +61,91 @@ GINGA_END_DECLS
using namespace std;

// Namespaces.
#define GINGA_NAMESPACE_BEGIN namespace ginga {/*}*/
#define GINGA_NAMESPACE_END /*{*/}
#define GINGA_NAMESPACE_BEGIN \
namespace ginga \
{ /*}*/
#define GINGA_NAMESPACE_END /*{*/ }

GINGA_NAMESPACE_BEGIN

// Utility macros.
#undef unused
#define unused(...) G_GNUC_UNUSED __VA_ARGS__

template <typename...T> void ignore_unused (const T&...) {}
template <typename... T>
void
ignore_unused (const T &...)
{
}

#undef cast
#define cast(a, b) (dynamic_cast<a>((b)))
#define instanceof(a, b) (cast (a,(b)) != nullptr)

#define tryinsert(a, b, fn) \
(std::count ((b).begin (), (b).end (), (a)) == 0) \
? ((b).fn (a), true) : false

#define MAP_GET_IMPL(m, a, b) \
G_STMT_START \
{ \
auto it = (m).find ((a)); \
if (it == (m).end ()) \
return false; \
tryset ((b), it->second); \
return true; \
} \
G_STMT_END \

#define MAP_SET_IMPL(m, a, b) \
G_STMT_START \
{ \
auto it = (m).find ((a)); \
(m)[(a)] = (b); \
return it == (m).end (); \
} \
#define cast(a, b) (dynamic_cast<a> ((b)))
#define instanceof(a, b) (cast (a, (b)) != nullptr)

#define tryinsert(a, b, fn) \
(std::count ((b).begin (), (b).end (), (a)) == 0) ? ((b).fn (a), true) \
: false

#define MAP_GET_IMPL(m, a, b) \
G_STMT_START \
{ \
auto it = (m).find ((a)); \
if (it == (m).end ()) \
return false; \
tryset ((b), it->second); \
return true; \
} \
G_STMT_END

#define MAP_SET_IMPL(m, a, b) \
G_STMT_START \
{ \
auto it = (m).find ((a)); \
(m)[(a)] = (b); \
return it == (m).end (); \
} \
G_STMT_END

// Logging, warnings and errors.
#define GINGA_STRFUNC (__ginga_strfunc (G_STRFUNC)).c_str ()
string __ginga_strfunc (const string &);
#define __ginga_log(fn, fmt, ...)\
fn ("%s: " fmt, GINGA_STRFUNC, ## __VA_ARGS__)
#define __ginga_log(fn, fmt, ...) \
fn ("%s: " fmt, GINGA_STRFUNC, ##__VA_ARGS__)

#define TRACE(fmt, ...) __ginga_log (g_debug, fmt, ## __VA_ARGS__)
#define WARNING(fmt, ...) __ginga_log (g_warning, fmt, ## __VA_ARGS__)
#define ERROR(fmt, ...) __ginga_log (g_error, fmt, ## __VA_ARGS__)
#define CRITICAL(fmt, ...) __ginga_log (g_critical, fmt, ## __VA_ARGS__)
#define TRACE(fmt, ...) __ginga_log (g_debug, fmt, ##__VA_ARGS__)
#define WARNING(fmt, ...) __ginga_log (g_warning, fmt, ##__VA_ARGS__)
#define ERROR(fmt, ...) __ginga_log (g_error, fmt, ##__VA_ARGS__)
#define CRITICAL(fmt, ...) __ginga_log (g_critical, fmt, ##__VA_ARGS__)

#define ERROR_NOT_IMPLEMENTED(fmt, ...)\
ERROR ("not implemented: " fmt, ## __VA_ARGS__)
#define ERROR_NOT_IMPLEMENTED(fmt, ...) \
ERROR ("not implemented: " fmt, ##__VA_ARGS__)

// Internal types.
typedef GdkRGBA Color;
typedef GdkRectangle Rect;
typedef GstClockTime Time;

// Time macros and functions.
#define GINGA_TIME_NONE GST_CLOCK_TIME_NONE
#define GINGA_TIME_IS_VALID(t) GST_CLOCK_TIME_IS_VALID ((t))
#define GINGA_STIME_NONE GST_CLOCK_STIME_NONE
#define GINGA_STIME_IS_VALID(t) GST_CLOCK_STIME_IS_VALID ((t))
#define GINGA_SECOND GST_SECOND
#define GINGA_MSECOND GST_MSECOND
#define GINGA_USECOND GST_USECOND
#define GINGA_NSECOND GST_NSECOND
#define GINGA_TIME_AS_SECONDS(t) GST_TIME_AS_SECONDS ((t))
#define GINGA_TIME_AS_MSECONDS(t) GST_TIME_AS_MSECONDS ((t))
#define GINGA_TIME_AS_USECONDS(t) GST_TIME_AS_USECONDS ((t))
#define GINGA_TIME_AS_NSECONDS(t) GST_TIME_AS_NSECONDS ((t))
#define GINGA_TIME_DIFF(s,e) GST_CLOCK_DIFF ((s), (e))
#define GINGA_TIME_FORMAT GST_TIME_FORMAT
#define GINGA_TIME_ARGS(t) GST_TIME_ARGS ((t))
#define GINGA_STIME_FORMAT GST_STIME_FORMAT
#define GINGA_STIME_ARGS(t) GST_STIME_ARGS ((t))
#define GINGA_TIME_NONE GST_CLOCK_TIME_NONE
#define GINGA_TIME_IS_VALID(t) GST_CLOCK_TIME_IS_VALID ((t))
#define GINGA_STIME_NONE GST_CLOCK_STIME_NONE
#define GINGA_STIME_IS_VALID(t) GST_CLOCK_STIME_IS_VALID ((t))
#define GINGA_SECOND GST_SECOND
#define GINGA_MSECOND GST_MSECOND
#define GINGA_USECOND GST_USECOND
#define GINGA_NSECOND GST_NSECOND
#define GINGA_TIME_AS_SECONDS(t) GST_TIME_AS_SECONDS ((t))
#define GINGA_TIME_AS_MSECONDS(t) GST_TIME_AS_MSECONDS ((t))
#define GINGA_TIME_AS_USECONDS(t) GST_TIME_AS_USECONDS ((t))
#define GINGA_TIME_AS_NSECONDS(t) GST_TIME_AS_NSECONDS ((t))
#define GINGA_TIME_DIFF(s, e) GST_CLOCK_DIFF ((s), (e))
#define GINGA_TIME_FORMAT GST_TIME_FORMAT
#define GINGA_TIME_ARGS(t) GST_TIME_ARGS ((t))
#define GINGA_STIME_FORMAT GST_STIME_FORMAT
#define GINGA_STIME_ARGS(t) GST_STIME_ARGS ((t))

// Numeric functions.
bool floateq (double, double, double epsilon=.0000001);
bool floateq (double, double, double epsilon = .0000001);
#define doubleeq floateq

// Parsing and evaluation functions.
Expand Down Expand Up @@ -177,11 +184,11 @@ int xstrcasecmp (const string &, const string &);
#define xstrcaseeq(s1, s2) (xstrcasecmp ((s1), (s2)) == 0)
bool xstrhasprefix (const string &, const string &);
bool xstrhassuffix (const string &, const string &);
int G_GNUC_PRINTF (2,3) xstrassign (string &, const char *, ...);
string G_GNUC_PRINTF (1,2) xstrbuild (const char *, ...);
int G_GNUC_PRINTF (2, 3) xstrassign (string &, const char *, ...);
string G_GNUC_PRINTF (1, 2) xstrbuild (const char *, ...);
string xstrstrip (string);
list<string> xstrsplit (const string &, char);
void xstrdelete(void *);
void xstrdelete (void *);

// Path functions.
string xpathbasename (string);
Expand All @@ -197,18 +204,18 @@ string xpathfromuri (const string &);
string xurifromsrc (const string &, const string &);
bool xurigetcontents (const string &, string &);


// User data.
typedef void (*UserDataCleanFunc)(void *);
typedef void (*UserDataCleanFunc) (void *);
class UserData
{
public:
UserData ();
~UserData ();
bool getData (const string &, void **);
bool setData (const string &, void *, UserDataCleanFunc fn=nullptr);
bool setData (const string &, void *, UserDataCleanFunc fn = nullptr);

private:
map<string,pair<void *, void (*)(void *)>> _udata;
map<string, pair<void *, void (*) (void *)> > _udata;
};

GINGA_NAMESPACE_END
Expand Down
Loading

0 comments on commit 2330e7c

Please sign in to comment.