-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinteger.c
48 lines (40 loc) · 1.05 KB
/
integer.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "integer.h"
#include "object.h"
#include <stdlib.h>
const char *integer_to_string(void)
{
return "Integer";
}
const int integer_get_number(struct integer *this)
{
return this->this.number;
}
void integer_set_number(struct integer *this, int number)
{
this->this.number = number;
}
struct integer *integer_new(void);
void integer_initialize(struct integer *integer)
{
integer->this.new = integer_new;
integer->this.initialize = integer_initialize;
integer->this.to_string = integer_to_string;
integer->this.get_number = integer_get_number;
integer->this.set_number = integer_set_number;
}
struct integer *integer_new(void)
{
struct integer *integer = malloc(sizeof(struct integer));
Object.initialize(&(integer->super));
Integer.this.initialize(integer);
return integer;
}
struct integer Integer = {
.this = {
.new = integer_new,
.initialize = integer_initialize,
.to_string = integer_to_string,
.get_number = integer_get_number,
.set_number = integer_set_number
}
};