1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-24 17:27:18 +00:00
janet/value.h

45 lines
1.4 KiB
C
Raw Normal View History

2017-02-09 20:02:59 +00:00
#ifndef VALUE_H_1RJPQKFM
#define VALUE_H_1RJPQKFM
#include "datatypes.h"
/* Check for boolean truthiness */
int gst_truthy(GstValue x);
/* Compare two gst values. All gst values are comparable and strictly
* ordered by default. Return 0 if equal, -1 if x is less than y, and
* 1 and x is greater than y. */
int gst_compare(GstValue x, GstValue y);
2017-02-09 20:02:59 +00:00
/* Returns if two values are equal. */
int gst_equals(GstValue x, GstValue y);
2017-02-09 20:02:59 +00:00
/* Get a value from an associative gst object. Can throw errors. */
const char *gst_get(GstValue ds, GstValue key, GstValue *out);
2017-02-12 20:53:52 +00:00
/* Set a value in an associative gst object. Can throw errors. */
const char *gst_set(Gst *vm, GstValue ds, GstValue key, GstValue value);
2017-02-12 20:53:52 +00:00
/* Load a c style string into a gst value (copies data) */
GstValue gst_load_cstring(Gst *vm, const char *string);
2017-02-09 20:02:59 +00:00
/* Simple hash function (djb2) */
uint32_t gst_string_calchash(const uint8_t *str);
/* C string hash version */
uint32_t gst_cstring_calchash(const uint8_t *str, uint32_t len);
/* Convert any gst value into a string */
uint8_t *gst_to_string(Gst *vm, GstValue x);
2017-02-09 20:02:59 +00:00
/* Generate a hash value for a gst object */
uint32_t gst_hash(GstValue x);
2017-02-09 20:02:59 +00:00
/* Get the class object of a value */
GstValue gst_get_class(GstValue x);
/* Set the class object of a value. Returns possible c error string */
const char *gst_set_class(GstValue obj, GstValue class);
2017-02-09 20:02:59 +00:00
#endif /* end of include guard: VALUE_H_1RJPQKFM */