示例#1
0
文件: find.c 项目: ryuever/sgrid
static int compare(OBJECT *obj, FINDTYPE ftype, FINDOP op, void *value, char *propname)
{
	switch (ftype) {
	case FT_ID: return compare_int((int64)obj->id,op,(int64)*(OBJECTNUM*)value);
	case FT_SIZE: return compare_int((int64)obj->oclass->size,op,(int64)*(int*)value);
	case FT_CLASS: return compare_string((char*)obj->oclass->name,op,(char*)value);
	case FT_ISA: return object_isa(obj,(char*)value);
	case FT_MODULE: return compare_string((char*)obj->oclass->module->name,op,(char*)value);
	case FT_GROUPID: return compare_string((char*)obj->groupid,op,(char*)value);
	case FT_RANK: return compare_int((int64)obj->rank,op,(int64)*(int*)value);
	case FT_CLOCK: return compare_int((int64)obj->clock,op,(int64)*(TIMESTAMP*)value);
	//case FT_PROPERTY: return compare_property_alt(obj,propname,op,value);
	case FT_PROPERTY: return compare_property(obj,propname,op,value);
	default:
		output_error("findtype %s not supported", ftype);
		/* TROUBLESHOOT
			This error is caused when an object find procedure uses a comparison operator
			that isn't allowed on a that header item.  Make sure the header item
			and the comparison operator are compatible and try again.  If your GLM file
			isn't the cause of the problem, try reducing the complexity of the GLM file 
			you are using to isolate which module is causing the error and file a report 
			with the GLM file attached.
		 */
		return 0;
	}
}
示例#2
0
文件: object.t.c 项目: jajm/libobject
int main()
{
	object_t *o;
	char *s;
	const char *string_type = "STRING";
	type_t *type;

	plan(9);
	
	type = type_get(string_type);
	type_set_callback(type, "free", free);

	s = calloc(20, sizeof(char));
	strcpy(s, "Hello, object world");

	o = object_new(string_type, s);
	ok(o != NULL, "object is not NULL");
	ok(object_isset(o), "object is set");
	ok(object_isa(o, string_type), "object isa '%s'", string_type);
	str_eq(object_type(o), string_type);
	ok(object_type(o) == string_type, "object_type() returns direct pointer to type string");
	str_eq(object_value(o), s);
	ok(object_value(o) == s, "object_value() returns direct pointer to value");

	object_set(o, "Goodbye");
	str_eq(object_value(o), "Goodbye");
	object_set(o, s);

	object_free(o);
	ok(object_isset(NULL) == 0, "NULL is considered as an unset object");

	types_finalize();

	return 0;
}
示例#3
0
文件: cwaf_callback.c 项目: jajm/cwaf
cwaf_cb cwaf_callback_get(cwaf_callback_t *callback)
{
	cwaf_cb cb = NULL;

	if (object_isa(callback, cwaf_callback_type)) {
		cb = object_value(callback);
	}

	return cb;
}