CoreFW  Check-in [1fd9e16f18]

Overview
Comment:clsptr -> cls.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1fd9e16f1871b79e99b7e0e4ba1c3b9698cbe4d14906be470b123a26480f9e5e
User & Date: js on 2012-04-08 19:06:46
Other Links: manifest | tags
Context
2012-04-08
19:12
Add corefw.h. check-in: 23d36a4cfe user: js tags: trunk
19:06
clsptr -> cls. check-in: 1fd9e16f18 user: js tags: trunk
19:05
Add cfw_class_name(). check-in: 07a4b94e52 user: js tags: trunk
Changes

Modified src/cfwarray.c from [58791b4765] to [ff44ea7550].

68
69
70
71
72
73
74
75

76
77
78
79
80
81
82
68
69
70
71
72
73
74

75
76
77
78
79
80
81
82







-
+







static bool
equal(void *ptr1, void *ptr2)
{
	CFWObject *obj2 = ptr2;
	CFWArray *array1, *array2;
	size_t i;

	if (obj2->clsptr != cfw_array)
	if (obj2->cls != cfw_array)
		return false;

	array1 = ptr1;
	array2 = ptr2;

	if (array1->size != array2->size)
		return false;

Modified src/cfwobject.c from [36ac9401ba] to [13f417b3bd].

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







-
+







cfw_new(CFWClass *class, ...)
{
	CFWObject *obj;

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

	obj->clsptr = class;
	obj->cls = class;
	obj->ref_cnt = 1;

	if (class->ctor != NULL) {
		va_list args;
		va_start(args, class);

		if (!class->ctor(obj, args)) {
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
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







-
-
+
+









-
-
+
+









-
-
+
+









}

void
cfw_free(void *ptr)
{
	CFWObject *obj = ptr;

	if (obj->clsptr->dtor != NULL)
		obj->clsptr->dtor(obj);
	if (obj->cls->dtor != NULL)
		obj->cls->dtor(obj);

	free(obj);
}

bool
cfw_equal(void *ptr1, void *ptr2)
{
	CFWObject *obj1 = ptr1, *obj2 = ptr2;

	if (obj1->clsptr->equal != NULL) {
		return obj1->clsptr->equal(obj1, obj2);
	if (obj1->cls->equal != NULL) {
		return obj1->cls->equal(obj1, obj2);
	} else
		return (obj1 == obj2);
}

void*
cfw_copy(void *ptr)
{
	CFWObject *obj = ptr;

	if (obj->clsptr->copy != NULL)
		return obj->clsptr->copy(obj);
	if (obj->cls->copy != NULL)
		return obj->cls->copy(obj);
	else
		return NULL;
}

static CFWClass class = {
	.name = "CFWObject",
	.size = sizeof(CFWObject),
};
CFWClass *cfw_object = &class;

Modified src/cfwobject.h from [3af61b6ce2] to [b76c332b63].

26
27
28
29
30
31
32
33

34
35
36
37
38
39
40
41
42
43
44
45
26
27
28
29
30
31
32

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







-
+













#ifndef __CFWOBJECT_H__
#define __CFWOBJECT_H__

#include "cfwclass.h"

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

extern CFWClass *cfw_object;
extern void* cfw_new(CFWClass*, ...);
extern void* cfw_ref(void*);
extern void cfw_unref(void*);
extern void cfw_free(void*);
extern bool cfw_equal(void*, void*);
extern void* cfw_copy(void*);

#endif

Modified src/cfwstring.c from [51f2e1e12f] to [59f525dc2e].

66
67
68
69
70
71
72
73

74
75
76
77
78
79
80
66
67
68
69
70
71
72

73
74
75
76
77
78
79
80







-
+








static bool
equal(void *ptr1, void *ptr2)
{
	CFWObject *obj2 = ptr2;
	CFWString *str1, *str2;

	if (obj2->clsptr != cfw_string)
	if (obj2->cls != cfw_string)
		return false;

	str1 = ptr1;
	str2 = ptr2;

	if (str1->len != str2->len)
		return false;