Hacky C++ fixes.

This commit is contained in:
Alex Shinn 2015-03-06 17:43:23 +09:00
parent 214a1aaf78
commit 9b3529b0e6
2 changed files with 27 additions and 0 deletions

View file

@ -9,7 +9,26 @@
#if ! SEXP_USE_BOEHM
extern sexp sexp_gc (sexp ctx, size_t *sum_freed);
#ifdef __cplusplus
sexp_uint_t sexp_allocated_bytes (sexp ctx, sexp x) {
sexp_uint_t res;
sexp t;
if (!sexp_pointerp(x) || (sexp_pointer_tag(x) >= sexp_context_num_types(ctx)))
return sexp_heap_align(1);
t = sexp_object_type(ctx, x);
res = sexp_type_size_of_object(t, x) + SEXP_GC_PAD;
#if SEXP_USE_DEBUG_GC
if (res == 0) {
fprintf(stderr, SEXP_BANNER("%p zero-size object: %p"), ctx, x);
return 1;
}
#endif
return res;
}
#else
extern sexp_uint_t sexp_allocated_bytes (sexp ctx, sexp x);
#endif
static void sexp_print_simple (sexp ctx, sexp x, sexp out, int depth) {
int i;

View file

@ -4,6 +4,10 @@
#include "chibi/eval.h"
#ifdef __cplusplus
namespace {
#endif
#if SEXP_USE_HUFF_SYMS
#if SEXP_USE_STATIC_LIBS
#include "chibi/sexp-hufftabdefs.h"
@ -12,6 +16,10 @@
#endif
#endif
#ifdef __cplusplus
}
#endif
#define swap(tmp_var, a, b) (tmp_var=a, a=b, b=tmp_var)
static sexp sexp_vector_copy_to_list (sexp ctx, sexp vec, sexp seq) {