コード例 #1
0
ファイル: Word.c プロジェクト: EricSB/tg-community
Thing 	Word(const int i)
{
	Thing self = NewThing(WORD, 
			      (Pointer) i, 
			      NULL,  /* no need for dtor on simple one */
			      WordUFO, 
			      WordCopy,
			      WordToString);
	return(self);
}
コード例 #2
0
ファイル: TestSuite.c プロジェクト: EricSB/tg-community
static void MassTestThing()
{
	uint i=0;
	uint   addrs[MAXCOUNT];
	Thing things[MAXCOUNT];
	CommentLine("Test Things en masse.");
	printf("MassTestThing()\n");
	Coords foo;
	for (i = 0; i < MAXCOUNT; i++)
	{
		foo=(Coords)malloc(sizeof(struct Coords_t));	
		//printf("new coords %p\n", (void*)foo);
		foo->x=i, foo->y=MAXCOUNT-i;
		things[i] = NewThing(POINTER, 
				     (Pointer) foo, 
				     killerfoo, 
				     NULL, 
				     NULL, 
				     NULL);
		addrs[i]  = (uint)foo;
		/*
		printf("(%d, %d)\n", ((Coords)GetThingData(things[i]))->x, 
				     ((Coords)GetThingData(things[i]))->y);
				     */
	}
	for (i = 0; i < MAXCOUNT; i++)
	{
		printf("deleting arr[%d]\n", i);
		if (addrs[i] == (uint)GetThingData(things[i])) 
		{ 
			printf("%p: %d is ok\n", (void*)addrs[i], i); 
		}
		if (GetThingType(things[i])!=POINTER) { printf("error not a pointer\n"); }
		DelThing(things[i]);
	}
}
コード例 #3
0
Thing *ThingFactory::NewThing(const std::string &description, int x, int y)
{
    Thing * thing = NewThing(description);
    thing->setXY(x, y);

}