From e96b4db3fb46384f286e9297186b87648c7219c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sun, 17 Jul 2022 02:05:15 +0200 Subject: Add const to pointers, update spacing. It seems that "right-spaced" pointers are more widely used among C++ programmers. --- c/pl.h | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'c/pl.h') diff --git a/c/pl.h b/c/pl.h index 9f40676..38fa94f 100644 --- a/c/pl.h +++ b/c/pl.h @@ -4,8 +4,8 @@ #include #include -int PL_get_tchars(term_t, TCHAR **, int); -int Plx(const char *, const char *); +int PL_get_tchars(term_t, TCHAR**, int); +int Plx(const char*, const char*); struct Query { @@ -23,34 +23,34 @@ inline int PlPut(const term_t t, const int x) { return PL_put_integer(t, x); } inline int PlPut(const term_t t, const long x) { return PL_put_integer(t, x); } inline int PlPut(const term_t t, const long long x) { return PL_put_integer(t, x); } inline int PlPut(const term_t t, const atom_t x) { return PL_put_atom(t, x); } -inline int PlPut(const term_t t, char *x) { return PL_put_atom(t, PL_new_atom(x)); } -inline int PlPut(const term_t t, const char *x) { return PL_put_atom(t, PL_new_atom(x)); } -inline int PlPut(const term_t t, wchar_t *x) { return PL_put_atom(t, PL_new_atom_wchars(-1, x)); } -inline int PlPut(const term_t t, const wchar_t *x) { return PL_put_atom(t, PL_new_atom_wchars(-1, x)); } -inline int PlPut(const term_t, int *) { return -1; } -inline int PlPut(const term_t, long *) { return -1; } -inline int PlPut(const term_t, long long *) { return -1; } -inline int PlPut(const term_t, atom_t *) { return -1; } -inline int PlPut(const term_t, char **) { return -1; } -inline int PlPut(const term_t, wchar_t **) { return -1; } +inline int PlPut(const term_t t, char* const x) { return PL_put_atom(t, PL_new_atom(x)); } +inline int PlPut(const term_t t, const char* const x) { return PL_put_atom(t, PL_new_atom(x)); } +inline int PlPut(const term_t t, wchar_t* const x) { return PL_put_atom(t, PL_new_atom_wchars(-1, x)); } +inline int PlPut(const term_t t, const wchar_t* const x) { return PL_put_atom(t, PL_new_atom_wchars(-1, x)); } +inline int PlPut(const term_t, int* const) { return -1; } +inline int PlPut(const term_t, long* const) { return -1; } +inline int PlPut(const term_t, long long* const) { return -1; } +inline int PlPut(const term_t, atom_t* const) { return -1; } +inline int PlPut(const term_t, char** const) { return -1; } +inline int PlPut(const term_t, wchar_t** const) { return -1; } inline int PlGet(const term_t, const int) { return -1; } inline int PlGet(const term_t, const long) { return -1; } inline int PlGet(const term_t, const long long) { return -1; } inline int PlGet(const term_t, const atom_t) { return -1; } -inline int PlGet(const term_t, char*) { return -1; } -inline int PlGet(const term_t, const char *) { return -1; } -inline int PlGet(const term_t t, int *x) { return PL_get_integer(t, x); } -inline int PlGet(const term_t t, long *x) { return PL_get_long(t, x); } -inline int PlGet(const term_t t, long long *x) { return PL_get_int64(t, x); } -inline int PlGet(const term_t t, atom_t *x) { return PL_get_atom(t, x); } -inline int PlGet(const term_t t, char **x) { return PL_get_atom_chars(t, x); } -inline int PlGet(const term_t t, wchar_t **x) +inline int PlGet(const term_t, char* const) { return -1; } +inline int PlGet(const term_t, const char* const) { return -1; } +inline int PlGet(const term_t t, int* const x) { return PL_get_integer(t, x); } +inline int PlGet(const term_t t, long* const x) { return PL_get_long(t, x); } +inline int PlGet(const term_t t, long long* const x) { return PL_get_int64(t, x); } +inline int PlGet(const term_t t, atom_t* const x) { return PL_get_atom(t, x); } +inline int PlGet(const term_t t, char** const x) { return PL_get_atom_chars(t, x); } +inline int PlGet(const term_t t, wchar_t** const x) { atom_t a; size_t len; if (!PL_get_atom(t, &a)) return 0; - *x = (wchar_t *)PL_atom_wchars(a, &len); + *x = (wchar_t*)PL_atom_wchars(a, &len); return *x != NULL; } @@ -70,7 +70,7 @@ int Countv(const int i, T arg, R... rest) { return Countv(i+1, rest...); } /* Call Prolog predicate, propagating Prolog exceptions. */ template -int Plx(const char *szMod, const char *szPred, T... args) +int Plx(const char* const szMod, const char* const szPred, T... args) { const int iArity = Countv(0, args...); const term_t t = PL_new_term_refs(iArity); @@ -82,20 +82,20 @@ int Plx(const char *szMod, const char *szPred, T... args) } /* Call Prolog predicate, ignoring Prolog exceptions. */ -inline int Pl(const char *szMod, const char *szPred) +inline int Pl(const char* const szMod, const char* const szPred) { try { return Plx(szMod, szPred); - } catch (term_t &t) { + } catch (term_t& t) { return 0; } } template -int Pl(const char *szMod, const char *szPred, T... args) +int Pl(const char* const szMod, const char* const szPred, T... args) { try { return Plx(szMod, szPred, args...); - } catch (term_t &t) { + } catch (term_t& t) { return 0; } } -- cgit v1.2.3