CoreFW  Check-in [8f2b2b8255]

Overview
Comment:Rename cfw_new_p to cfw_create.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 8f2b2b825539aab5eb1815300a03f679ea495e575129c206fef56c02efade2c9
User & Date: js on 2012-04-22 15:30:25
Other Links: manifest | tags
Context
2012-04-25
09:17
Oops. check-in: 0adce25085 user: js tags: trunk
2012-04-22
15:30
Rename cfw_new_p to cfw_create. check-in: 8f2b2b8255 user: js tags: trunk
14:19
Nicer tests. check-in: 3e28d1e360 user: js tags: trunk
Changes

Modified src/object.c from [f1b2c26b73] to [d87768cf4b].

53
54
55
56
57
58
59
60

61
62
63
64
65
66
67
53
54
55
56
57
58
59

60
61
62
63
64
65
66
67







-
+







		va_end(args);
	}

	return obj;
}

void*
cfw_new_p(CFWClass *class, ...)
cfw_create(CFWClass *class, ...)
{
	CFWObject *obj;

	assert(class != cfw_refpool);

	if ((obj = malloc(class->size)) == NULL)
		return NULL;

Modified src/object.h from [44faac2ce6] to [650f39f047].

32
33
34
35
36
37
38
39

40
41
42
43
44
45
46
32
33
34
35
36
37
38

39
40
41
42
43
44
45
46







-
+







typedef struct CFWObject {
	CFWClass *cls;
	int ref_cnt;
} CFWObject;

extern CFWClass *cfw_object;
extern void* cfw_new(CFWClass*, ...);
extern void* cfw_new_p(CFWClass*, ...);
extern void* cfw_create(CFWClass*, ...);
extern void* cfw_ref(void*);
extern void cfw_unref(void*);
extern void cfw_free(void*);
extern CFWClass* cfw_class(void*);
extern bool cfw_is(void*, CFWClass*);
extern bool cfw_equal(void*, void*);
extern uint32_t cfw_hash(void*);

Modified tests/tests.c from [8e2fa3e14c] to [9cf7932e29].

55
56
57
58
59
60
61
62
63
64
65




66
67
68

69
70
71
72
73




74
75

76
77
78


79
80

81
82

83
84
85
86



87
88
89


90
91

92
93
94
95
96
97
98
99







100
101

102
103
104
105



106
107

108
109
110


111
112

113
114
115
55
56
57
58
59
60
61




62
63
64
65
66
67

68
69




70
71
72
73
74

75
76


77
78
79

80
81

82
83



84
85
86
87


88
89
90

91
92







93
94
95
96
97
98
99
100

101
102



103
104
105
106

107
108


109
110
111

112
113
114
115







-
-
-
-
+
+
+
+


-
+

-
-
-
-
+
+
+
+

-
+

-
-
+
+

-
+

-
+

-
-
-
+
+
+

-
-
+
+

-
+

-
-
-
-
-
-
-
+
+
+
+
+
+
+

-
+

-
-
-
+
+
+

-
+

-
-
+
+

-
+




	fputs("}\n", stdout);
}

int
main()
{
	CFWRefPool *p;
	CFWArray *a;
	CFWString *s, *s2;
	CFWMap *m;
	CFWRefPool *pool;
	CFWArray *array;
	CFWString *str, *str2;
	CFWMap *map;
	size_t i;

	p = cfw_new(cfw_refpool);
	pool = cfw_new(cfw_refpool);

	a = cfw_new_p(cfw_array,
	    cfw_new_p(cfw_string, "Hallo"),
	    cfw_new_p(cfw_string, " Welt"),
	    cfw_new_p(cfw_string, "!"), NULL);
	array = cfw_create(cfw_array,
	    cfw_create(cfw_string, "Hallo"),
	    cfw_create(cfw_string, " Welt"),
	    cfw_create(cfw_string, "!"), NULL);

	s = cfw_new(cfw_string, NULL);
	str = cfw_new(cfw_string, NULL);

	for (i = 0; i < cfw_array_size(a); i++)
		cfw_string_append(s, cfw_array_get(a, i));
	for (i = 0; i < cfw_array_size(array); i++)
		cfw_string_append(str, cfw_array_get(array, i));

	cfw_unref(p);
	cfw_unref(pool);

	puts(cfw_string_c(s));
	puts(cfw_string_c(str));

	p = cfw_new(cfw_refpool);
	s2 = cfw_new_p(cfw_string, "ll");
	printf("%zd\n", cfw_string_find(s, s2, cfw_range_all));
	pool = cfw_new(cfw_refpool);
	str2 = cfw_create(cfw_string, "ll");
	printf("%zd\n", cfw_string_find(str, str2, cfw_range_all));

	cfw_unref(p);
	cfw_unref(s);
	cfw_unref(pool);
	cfw_unref(str);

	p = cfw_new(cfw_refpool);
	pool = cfw_new(cfw_refpool);

	m = cfw_new_p(cfw_map,
	    cfw_new_p(cfw_string, "Hallo"),
	    cfw_new_p(cfw_string, "Welt!"),
	    cfw_new_p(cfw_string, "Test"),
	    cfw_new_p(cfw_string, "success!"),
	    cfw_new_p(cfw_string, "int"),
	    cfw_new_p(cfw_int, INTMAX_C(1234)), NULL);
	map = cfw_create(cfw_map,
	    cfw_create(cfw_string, "Hallo"),
	    cfw_create(cfw_string, "Welt!"),
	    cfw_create(cfw_string, "Test"),
	    cfw_create(cfw_string, "success!"),
	    cfw_create(cfw_string, "int"),
	    cfw_create(cfw_int, INTMAX_C(1234)), NULL);

	print_map(m);
	print_map(map);

	cfw_map_set(m,
	    cfw_new_p(cfw_string, "Hallo"),
	    cfw_new_p(cfw_string, "Test"));
	cfw_map_set(map,
	    cfw_create(cfw_string, "Hallo"),
	    cfw_create(cfw_string, "Test"));

	print_map(m);
	print_map(map);

	cfw_map_set(m, cfw_new_p(cfw_string, "Hallo"), NULL);
	print_map(m);
	cfw_map_set(map, cfw_create(cfw_string, "Hallo"), NULL);
	print_map(map);

	cfw_unref(p);
	cfw_unref(pool);

	return 0;
}