aboutsummaryrefslogtreecommitdiff
path: root/c/pl.h
diff options
context:
space:
mode:
Diffstat (limited to 'c/pl.h')
-rw-r--r--c/pl.h17
1 files changed, 5 insertions, 12 deletions
diff --git a/c/pl.h b/c/pl.h
index 06efe13..276f79a 100644
--- a/c/pl.h
+++ b/c/pl.h
@@ -23,10 +23,10 @@ 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* 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 t, char* const x) { return PL_put_atom_chars(t, x); }
+inline int PlPut(const term_t t, const char* const x) { return PL_put_atom_chars(t, x); }
+inline int PlPut(const term_t t, wchar_t* const x) { return PL_unify_wchars(t, PL_ATOM, -1, x); }
+inline int PlPut(const term_t t, const wchar_t* const x) { return PL_unify_wchars(t, PL_ATOM, -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; }
@@ -45,14 +45,7 @@ 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);
- return *x != NULL;
-}
+inline int PlGet(const term_t t, wchar_t** const x) { size_t len; return PL_get_wchars(t, &len, x, CVT_ATOM); }
/* Helper templates for Plx, Pl. */
template <typename T>