本文整理汇总了C++中OBJ_TYPE函数的典型用法代码示例。如果您正苦于以下问题:C++ OBJ_TYPE函数的具体用法?C++ OBJ_TYPE怎么用?C++ OBJ_TYPE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OBJ_TYPE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sml_obj_dup
void *
sml_obj_dup(void *obj)
{
void **slot, *newobj;
size_t obj_size;
switch (OBJ_TYPE(obj)) {
case OBJTYPE_UNBOXED_ARRAY:
case OBJTYPE_BOXED_ARRAY:
case OBJTYPE_UNBOXED_VECTOR:
case OBJTYPE_BOXED_VECTOR:
obj_size = OBJ_SIZE(obj);
slot = sml_push_tmp_rootset(1);
*slot = obj;
newobj = sml_obj_alloc(OBJ_TYPE(obj), obj_size);
memcpy(newobj, *slot, obj_size);
sml_pop_tmp_rootset(slot);
return newobj;
case OBJTYPE_RECORD:
obj_size = OBJ_SIZE(obj);
slot = sml_push_tmp_rootset(1);
*slot = obj;
newobj = sml_record_alloc(obj_size);
memcpy(newobj, *slot,
obj_size + SIZEOF_BITMAP * OBJ_BITMAPS_LEN(obj_size));
sml_pop_tmp_rootset(slot);
return newobj;
default:
sml_fatal(0, "BUG: invalid object type : %d", OBJ_TYPE(obj));
}
}
示例2: sml_obj_enum_ptr
void
sml_obj_enum_ptr(void *obj, void (*trace)(void **, void *), void *data)
{
unsigned int i;
unsigned int *bitmaps;
/*
DBG("%p: size=%lu, type=%08x",
obj, (unsigned long)OBJ_SIZE(obj), (unsigned int)OBJ_TYPE(obj));
*/
switch (OBJ_TYPE(obj)) {
case OBJTYPE_UNBOXED_ARRAY:
case OBJTYPE_UNBOXED_VECTOR:
case OBJTYPE_INTINF:
break;
case OBJTYPE_BOXED_ARRAY:
case OBJTYPE_BOXED_VECTOR:
for (i = 0; i < OBJ_SIZE(obj) / sizeof(void*); i++)
trace((void**)obj + i, data);
break;
case OBJTYPE_RECORD:
bitmaps = OBJ_BITMAP(obj);
for (i = 0; i < OBJ_SIZE(obj) / sizeof(void*); i++) {
if (BITMAP_BIT(bitmaps, i) != TAG_UNBOXED)
trace((void**)obj + i, data);
}
break;
default:
sml_fatal(0, "BUG: invalid object type : %d", OBJ_TYPE(obj));
}
}
示例3: prim_IntInf_cmp
int
prim_IntInf_cmp(sml_intinf_t *x, sml_intinf_t *y)
{
ASSERT(OBJ_TYPE(x) == OBJTYPE_INTINF);
ASSERT(OBJ_TYPE(y) == OBJTYPE_INTINF);
return sml_intinf_cmp(x, y);
}
示例4: print_list
static void print_list(struct lispobj *obj)
{
if(print_bracket) {
printf("(");
}
print_bracket = 0;
if(CAR(obj) != NULL && OBJ_TYPE(CAR(obj)) == CONS) {
printf("(");
}
print(CAR(obj));
if(CDR(obj) == NULL) {
printf(")");
print_bracket = 1;
return;
}
if(OBJ_TYPE(CDR(obj)) == CONS) {
printf(" ");
} else {
printf(" . ");
}
print_bracket = 0;
print(CDR(obj));
if(!print_bracket) {
printf(")");
}
print_bracket = 1;
return;
}
示例5: eval_cond
static struct lispobj* eval_cond(struct lispobj *exps, struct lispobj *env)
{
struct lispobj *ret = OBJ_FALSE;
if(exps != NULL) {
struct lispobj *cond;
cond = CAR(exps);
if(cond != NULL && OBJ_TYPE(cond) == CONS) {
struct lispobj *pred;
pred = eval(CAR(cond), env);
if(pred != NULL && OBJ_TYPE(pred) == ERROR) {
ret = pred;
} else {
if(pred) {
if(length(cond) == 1) {
ret = OBJ_TRUE;
} else {
ret = eval(CADR(cond), env);
}
} else {
ret = eval_cond(CDR(exps), env);
}
heap_release(pred);
}
} else {
ret = NEW_ERROR("Bad cond clause.\n");
}
}
return ret;
}
示例6: obj_dump__
/* for debug */
static void
obj_dump__(int indent, void *obj)
{
unsigned int i;
unsigned int *bitmap;
void **field = obj;
char *buf;
if (obj == NULL) {
sml_debug("%*sNULL\n", indent, "");
return;
}
switch (OBJ_TYPE(obj)) {
case OBJTYPE_UNBOXED_ARRAY:
case OBJTYPE_UNBOXED_VECTOR:
sml_debug("%*s%p:%u:%s\n",
indent, "", obj, OBJ_SIZE(obj),
(OBJ_TYPE(obj) == OBJTYPE_UNBOXED_ARRAY)
? "UNBOXED_ARRAY" : "UNBOXED_VECTOR");
for (i = 0; i < OBJ_SIZE(obj) / sizeof(unsigned int); i++)
sml_debug("%*s0x%08x\n",
indent + 2, "", ((unsigned int *)field)[i]);
for (i = i * sizeof(unsigned int); i < OBJ_SIZE(obj); i++)
sml_debug("%*s0x%02x\n",
indent + 2, "", ((unsigned char*)field)[i]);
break;
case OBJTYPE_BOXED_ARRAY:
case OBJTYPE_BOXED_VECTOR:
sml_debug("%*s%p:%u:%s\n",
indent, "", obj, OBJ_SIZE(obj),
(OBJ_TYPE(obj) == OBJTYPE_BOXED_ARRAY)
? "BOXED_ARRAY" : "BOXED_VECTOR");
for (i = 0; i < OBJ_SIZE(obj) / sizeof(void*); i++)
obj_dump__(indent + 2, field[i]);
for (i = i * sizeof(void*); i < OBJ_SIZE(obj); i++)
sml_debug("%*s0x%02x\n",
indent + 2, "", ((char*)field)[i]);
break;
case OBJTYPE_RECORD:
sml_debug("%*s%p:%u:RECORD\n",
indent, "", obj, OBJ_SIZE(obj));
bitmap = OBJ_BITMAP(obj);
for (i = 0; i < OBJ_SIZE(obj) / sizeof(void*); i++) {
if (BITMAP_BIT(bitmap, i) != TAG_UNBOXED)
obj_dump__(indent + 2, field[i]);
else
sml_debug("%*s%p\n", indent + 2, "", field[i]);
}
break;
default:
sml_debug("%*s%p:%u:unknown type %u",
indent, "", obj, OBJ_SIZE(obj), OBJ_TYPE(obj));
break;
}
}
示例7: prim_String_size
int
prim_String_size(const char *str)
{
/* used for not only CharVector but CharArray */
ASSERT(OBJ_TYPE(str) == OBJTYPE_UNBOXED_VECTOR
|| OBJ_TYPE(str) == OBJTYPE_UNBOXED_ARRAY);
return OBJ_STR_SIZE(str);
}
示例8: prim_String_update
void
prim_String_update(char *str, int index, char ch)
{
/* used for not only CharVector but CharArray */
ASSERT(OBJ_TYPE(str) == OBJTYPE_UNBOXED_ARRAY
|| OBJ_TYPE(str) == OBJTYPE_UNBOXED_VECTOR);
ASSERT(index >= 0 && (size_t)index < OBJ_STR_SIZE(str));
str[index] = ch;
}
示例9: prim_String_sub
char
prim_String_sub(const char *str, int n)
{
/* used for not only CharVector but CharArray */
ASSERT(OBJ_TYPE(str) == OBJTYPE_UNBOXED_ARRAY
|| OBJ_TYPE(str) == OBJTYPE_UNBOXED_VECTOR);
ASSERT(n >= 0 && (size_t)n < OBJ_STR_SIZE(str));
return str[n];
}
示例10: prim_IntInf_andb
sml_intinf_t *
prim_IntInf_andb(sml_intinf_t *x, sml_intinf_t *y)
{
sml_intinf_t xv, yv, *z;
ASSERT(OBJ_TYPE(x) == OBJTYPE_INTINF);
ASSERT(OBJ_TYPE(y) == OBJTYPE_INTINF);
xv = *x, yv = *y; /* rescue from garbage collector */
z = sml_intinf_new();
sml_intinf_and(z, &xv, &yv);
return z;
}
示例11: prim_String_copy
void
prim_String_copy(const char *src, int si, char *dst, int di, int len)
{
/* used for not only CharVector but CharArray */
ASSERT(OBJ_TYPE(src) == OBJTYPE_UNBOXED_ARRAY
|| OBJ_TYPE(src) == OBJTYPE_UNBOXED_VECTOR);
ASSERT(OBJ_TYPE(dst) == OBJTYPE_UNBOXED_ARRAY
|| OBJ_TYPE(dst) == OBJTYPE_UNBOXED_VECTOR);
ASSERT(len >= 0);
ASSERT(si >= 0 && (size_t)(si + len) <= OBJ_STR_SIZE(src));
ASSERT(di >= 0 && (size_t)(di + len) <= OBJ_STR_SIZE(dst));
memcpy(dst + di, src + si, len);
}
示例12: prim_UnmanagedMemory_export
void *
prim_UnmanagedMemory_export(const char *str, unsigned int offset,
unsigned int size)
{
void *p;
ASSERT(OBJ_TYPE(str) == OBJTYPE_UNBOXED_VECTOR
|| OBJ_TYPE(str) == OBJTYPE_UNBOXED_ARRAY);
ASSERT(offset < OBJ_STR_SIZE(str) && size < OBJ_STR_SIZE(str) - offset);
p = xmalloc(size);
memcpy(p, str + offset, size);
return p;
}
示例13: prim_GenericOS_write
int
prim_GenericOS_write(int fd, const char *buf,
unsigned int offset, unsigned int len)
{
ASSERT(OBJ_TYPE(buf) == OBJTYPE_UNBOXED_ARRAY
|| OBJ_TYPE(buf) == OBJTYPE_UNBOXED_VECTOR);
ASSERT(offset + len <= OBJ_SIZE(buf));
#ifdef HAVE_INTERACTIVE_MODE
if (interactive_mode && fd == 0)
return interact_prim_write(fd, buf, offset, len);
#endif /* HAVE_INTERACTIVE_MODE */
return write(fd, buf + offset, len);
}
示例14: env_var_lookup
struct lispobj *env_var_define(struct lispobj *var, struct lispobj *val, struct lispobj *env)
{
struct lispobj *frame, *pair, *cell, *lookup;
/* Checking on variable existence. */
lookup = env_var_lookup(var, env);
/* If variable exists return error. */
if(OBJ_TYPE(lookup) != ERROR) {
char error[64];
snprintf(error, 64, "Variable already exists: %s.\n", SYMBOL_VALUE(var));
return NEW_ERROR(error);
}
/* Remove not necessary object. */
heap_release(lookup);
/* Get top frame from environment. */
frame = ENV_FIRST(env);
/* Creating cell for new variable. */
cell = NEW_CONS(var, val);
/* Appending new cell into the frame. */
pair = NEW_CONS(cell, frame);
frame = heap_grab(pair);
/* Appending the frame into the environment. */
CAR(env) = frame;
return val;
}
示例15: CAR
struct lispobj *subr_apply(struct lispobj *args)
{
if(length(args) != 2)
return ERROR_ARGS;
struct lispobj *proc, *params;
proc = CAR(args);
params = CADR(args);
if((proc != NULL && OBJ_TYPE(proc) != CONS) ||
(params != NULL && OBJ_TYPE(params) != CONS)) {
return NEW_ERROR("Wrong arguments type.\n");
}
return apply(proc, params);
}