|
@@ -13,16 +13,40 @@ __construct(struct BIGPOINT_DYNTYPE * _this, va_list * params) |
|
@@ -13,16 +13,40 @@ __construct(struct BIGPOINT_DYNTYPE * _this, va_list * params) |
13
|
_this->type = va_arg(* params, enum BIGPOINT_DYNTYPE_TYPES);
|
13
|
_this->type = va_arg(* params, enum BIGPOINT_DYNTYPE_TYPES);
|
14
|
_this->size = va_arg(* params, size_t);
|
14
|
_this->size = va_arg(* params, size_t);
|
15
|
|
15
|
|
16
|
- _this->data = calloc(_this->size, sizeof(char));
|
|
|
17
|
- memcpy(_this->data, va_arg(* params, void *), _this->size);
|
16
|
+ switch(_this->type) {
|
|
|
17
|
+ case BIGPOINT_DYNTYPE_INT:
|
|
|
18
|
+ (_this->data)._int = va_arg(* params, long);
|
|
|
19
|
+ break;
|
|
|
20
|
+
|
|
|
21
|
+ default:
|
|
|
22
|
+ (_this->data)._object = NULL;
|
|
|
23
|
+ }
|
|
|
24
|
+}
|
|
|
25
|
+
|
|
|
26
|
+static
|
|
|
27
|
+void
|
|
|
28
|
+__jsonConst(struct BIGPOINT_DYNTYPE * _this, struct json_object * json)
|
|
|
29
|
+{
|
|
|
30
|
+ switch (json_object_get_type(json)) {
|
|
|
31
|
+ case json_type_int:
|
|
|
32
|
+ _this->type = BIGPOINT_DYNTYPE_INT;
|
|
|
33
|
+ _this->size = sizeof(long);
|
|
|
34
|
+ (_this->data)._int = (long)json_object_get_int(json);
|
|
|
35
|
+ break;
|
|
|
36
|
+
|
|
|
37
|
+ default:
|
|
|
38
|
+ _this->type = BIGPOINT_DYNTYPE_NULL;
|
|
|
39
|
+ _this->size = 0;
|
|
|
40
|
+ (_this->data)._object = NULL;
|
|
|
41
|
+ }
|
18
|
}
|
42
|
}
|
19
|
|
43
|
|
20
|
static
|
44
|
static
|
21
|
void
|
45
|
void
|
22
|
__destruct(struct BIGPOINT_DYNTYPE * _this)
|
46
|
__destruct(struct BIGPOINT_DYNTYPE * _this)
|
23
|
{
|
47
|
{
|
24
|
- if (_this && _this->data) {
|
|
|
25
|
- free(_this->data);
|
48
|
+ if (_this && BIGPOINT_DYNTYPE_OBJECT == _this->type && (_this->data)._object) {
|
|
|
49
|
+ free((_this->data)._object);
|
26
|
}
|
50
|
}
|
27
|
}
|
51
|
}
|
28
|
|
52
|
|
|
@@ -39,22 +63,13 @@ __toJson(struct BIGPOINT_DYNTYPE * _this) |
|
@@ -39,22 +63,13 @@ __toJson(struct BIGPOINT_DYNTYPE * _this) |
39
|
return json;
|
63
|
return json;
|
40
|
}
|
64
|
}
|
41
|
|
65
|
|
42
|
-static
|
|
|
43
|
-void
|
|
|
44
|
-__jsonConst(struct BIGPOINT_DYNTYPE * _this, struct json_object * json)
|
|
|
45
|
-{
|
|
|
46
|
- /**
|
|
|
47
|
- * @TODO: initialize by json....
|
|
|
48
|
- */
|
|
|
49
|
-}
|
|
|
50
|
-
|
|
|
51
|
static const
|
66
|
static const
|
52
|
struct BIGPOINT_CCLASS _bigpoint_dyntype = {
|
67
|
struct BIGPOINT_CCLASS _bigpoint_dyntype = {
|
53
|
sizeof(struct BIGPOINT_DYNTYPE),
|
68
|
sizeof(struct BIGPOINT_DYNTYPE),
|
54
|
(ctor)__construct,
|
69
|
(ctor)__construct,
|
55
|
- __jsonConst,
|
70
|
+ (jCtor)__jsonConst,
|
56
|
(dtor)__destruct,
|
71
|
(dtor)__destruct,
|
57
|
- __toJson
|
72
|
+ (jTo)__toJson
|
58
|
};
|
73
|
};
|
59
|
|
74
|
|
60
|
const struct BIGPOINT_CCLASS * const BIGPOINT_DYNTYPE = &_bigpoint_dyntype;
|
75
|
const struct BIGPOINT_CCLASS * const BIGPOINT_DYNTYPE = &_bigpoint_dyntype;
|