• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ OBJ_TYPE函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中OBJ_TYPE函数的典型用法代码示例。如果您正苦于以下问题:C++ OBJ_TYPE函数的具体用法?C++ OBJ_TYPE怎么用?C++ OBJ_TYPE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了OBJ_TYPE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
	}
}
开发者ID:hsk,项目名称:docs,代码行数:33,代码来源:object.c


示例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));
	}
}
开发者ID:smlsharp,项目名称:smlsharp,代码行数:35,代码来源:object.c


示例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);
}
开发者ID:masquerade0324,项目名称:smlsharp,代码行数:7,代码来源:prim.c


示例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;
}
开发者ID:grouzen,项目名称:fflisp,代码行数:35,代码来源:print.c


示例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;
}
开发者ID:grouzen,项目名称:fflisp,代码行数:33,代码来源:eval.c


示例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;
	}
}
开发者ID:hsk,项目名称:docs,代码行数:60,代码来源:object.c


示例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);
}
开发者ID:masquerade0324,项目名称:smlsharp,代码行数:8,代码来源:prim.c


示例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;
}
开发者ID:masquerade0324,项目名称:smlsharp,代码行数:9,代码来源:prim.c


示例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];
}
开发者ID:masquerade0324,项目名称:smlsharp,代码行数:9,代码来源:prim.c


示例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;
}
开发者ID:masquerade0324,项目名称:smlsharp,代码行数:12,代码来源:prim.c


示例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);
}
开发者ID:masquerade0324,项目名称:smlsharp,代码行数:14,代码来源:prim.c


示例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;
}
开发者ID:masquerade0324,项目名称:smlsharp,代码行数:14,代码来源:prim.c


示例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);
}
开发者ID:masquerade0324,项目名称:smlsharp,代码行数:15,代码来源:prim.c


示例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;
}
开发者ID:grouzen,项目名称:fflisp,代码行数:30,代码来源:environment.c


示例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);
}
开发者ID:grouzen,项目名称:fflisp,代码行数:16,代码来源:subr.c


示例16: snprintf

struct lispobj *subr_minus(struct lispobj *args)
{
    if(length(args) == 0)
        return ERROR_ARGS;

    struct lispobj *num;
    char num_value[30];

    snprintf(num_value, 30, "%d", NUMBER_VALUE(CAR(args)));
    num = NEW_NUMBER(num_value);

    args = CDR(args);
    if(args == NULL) {
        NUMBER_VALUE(num) = 0 - NUMBER_VALUE(num);
    } else {
        while(args != NULL) {
            if(CAR(args) != NULL && OBJ_TYPE(CAR(args)) == NUMBER) {
                NUMBER_VALUE(num) -= NUMBER_VALUE(CAR(args));
                args = CDR(args);
            } else {
                object_delete(num);
                return NEW_ERROR("Argument is not a number.\n");
            }
        }
    }
    return num;
}
开发者ID:grouzen,项目名称:fflisp,代码行数:27,代码来源:subr.c


示例17: prim_GenericOS_readlink

STRING
prim_GenericOS_readlink(const char *filename)
{
#if !defined(HAVE_CONFIG_H) || defined(HAVE_READLINK)
	char buf[128], *p;
	ssize_t n, len;
	void *obj;

	ASSERT(OBJ_TYPE(filename) == OBJTYPE_UNBOXED_VECTOR);

	n = readlink(filename, buf, sizeof(buf));
	if (n < 0)
		return NULL;
	if ((size_t)n < sizeof(buf))
		return sml_str_new2(buf, n);

	p = NULL;
	for (len = sizeof(buf); n >= len; len *= 2) {
		p = xrealloc(p, len);
		n = readlink(filename, buf, len);
	}

	if (n < 0) {
		free(p);
		return NULL;
	}
	obj = sml_str_new2(buf, n);
	free(p);
	return obj;
#else
	errno = EIO;
	return NULL;
#endif /* HAVE_READLINK */
}
开发者ID:masquerade0324,项目名称:smlsharp,代码行数:34,代码来源:prim.c


示例18: prim_IntInf_log2

int
prim_IntInf_log2(sml_intinf_t *x)
{
	sml_intinf_t xv;
	ASSERT(OBJ_TYPE(x) == OBJTYPE_INTINF);

	xv = *x; /* rescue from garbage collector */
	return sml_intinf_log2(&xv);
}
开发者ID:masquerade0324,项目名称:smlsharp,代码行数:9,代码来源:prim.c


示例19: prim_String_substring

STRING
prim_String_substring(const char *str, int beg, int len)
{
	ASSERT(OBJ_TYPE(str) == OBJTYPE_UNBOXED_VECTOR);
	ASSERT(beg >= 0 && len >= 0);
	ASSERT((size_t)(beg + len) <= OBJ_STR_SIZE(str));

	return sml_str_new2(&str[beg], len);
}
开发者ID:masquerade0324,项目名称:smlsharp,代码行数:9,代码来源:prim.c


示例20: heap_debug_object

//#ifdef __DEBUG_HEAP__
void heap_debug_object(struct lispobj *obj)
{
    if(obj == NULL) {
        printf(" null pointer");
    } else {
        printf(" [%p ", obj);
        if(OBJ_TYPE(obj) == SYMBOL) {
            printf("(symbol %s) ", SYMBOL_VALUE(obj));
        } else if(OBJ_TYPE(obj) == NUMBER) {
            printf("(number %d) ", NUMBER_VALUE(obj));
        } else if(OBJ_TYPE(obj) == STRING) {
            printf("(string %s) ", STRING_VALUE(obj));
        } else {
            printf("(cons) ");
        }
        printf("%d] ", OBJ_REFS(obj));
    }
}
开发者ID:grouzen,项目名称:fflisp,代码行数:19,代码来源:heap.c



注:本文中的OBJ_TYPE函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ OBJ_cmp函数代码示例发布时间:2022-05-30
下一篇:
C++ OBJ_TAINT函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap