TADや、その他BTRON基本データ型を扱うmrbgemの開発用
Revisión | 8d86a0519d2f6d9c8e5a04513f9abee8c0d30641 (tree) |
---|---|
Tiempo | 2017-06-24 01:31:30 |
Autor | ornse01 <ornse01@user...> |
Commiter | ornse01 |
fix compile error.
@@ -1,4 +1,8 @@ | ||
1 | 1 | #include "mruby.h" |
2 | +#include "mruby/class.h" | |
3 | +#include "mruby/data.h" | |
4 | + | |
5 | +#include <btron/btron.h> | |
2 | 6 | |
3 | 7 | const static struct mrb_data_type mrb_PNT_type = { "PNT", mrb_free }; |
4 | 8 |
@@ -27,7 +31,7 @@ mrb_PNT_init(mrb_state *mrb, mrb_value self) | ||
27 | 31 | p->y = arg.y; |
28 | 32 | |
29 | 33 | DATA_TYPE(self) = &mrb_PNT_type; |
30 | - DATA_PTR(self) = h; | |
34 | + DATA_PTR(self) = p; | |
31 | 35 | |
32 | 36 | return self; |
33 | 37 | } |
@@ -87,7 +91,7 @@ mrb_PNT_init_copy(mrb_state *mrb, mrb_value copy) | ||
87 | 91 | mrb_raise(mrb, E_TYPE_ERROR, "wrong argument class"); |
88 | 92 | } |
89 | 93 | if (!DATA_PTR(copy)) { |
90 | - DATA_PTR(copy) = (struct hoge *)mrb_malloc(mrb, sizeof(struct hoge)); | |
94 | + DATA_PTR(copy) = (struct hoge *)mrb_malloc(mrb, sizeof(PNT)); | |
91 | 95 | DATA_TYPE(copy) = &mrb_PNT_type; |
92 | 96 | } |
93 | 97 | *(PNT*)DATA_PTR(copy) = *(PNT*)DATA_PTR(src); |
@@ -98,14 +102,14 @@ mrb_PNT_init_copy(mrb_state *mrb, mrb_value copy) | ||
98 | 102 | LOCAL mrb_value |
99 | 103 | mrb_PNT_equal(mrb_state *mrb, mrb_value self) |
100 | 104 | { |
101 | - mrb_value src; | |
105 | + mrb_value other; | |
102 | 106 | PNT *self_real, *other_real; |
103 | 107 | |
104 | 108 | mrb_get_args(mrb, "o", &other); |
105 | 109 | if (mrb_obj_equal(mrb, self, other)) { |
106 | 110 | return mrb_bool_value(FALSE); |
107 | 111 | } |
108 | - if (!mrb_obj_is_instance_of(mrb, other, mrb_obj_class(mrb, copy))) { | |
112 | + if (!mrb_obj_is_instance_of(mrb, other, mrb_obj_class(mrb, self))) { | |
109 | 113 | return mrb_bool_value(FALSE); |
110 | 114 | } |
111 | 115 | if (!DATA_PTR(other)) { |
@@ -114,7 +118,7 @@ mrb_PNT_equal(mrb_state *mrb, mrb_value self) | ||
114 | 118 | |
115 | 119 | self_real = DATA_PTR(self); |
116 | 120 | other_real = DATA_PTR(other); |
117 | - if ((self_real->x == other_real->x) && (self_real->y == other_real.y)) { | |
121 | + if ((self_real->x == other_real->x) && (self_real->y == other_real->y)) { | |
118 | 122 | return mrb_bool_value(TRUE); |
119 | 123 | } |
120 | 124 | return mrb_bool_value(FALSE); |
@@ -124,7 +128,7 @@ LOCAL mrb_value | ||
124 | 128 | mrb_PNT_plus(mrb_state *mrb, mrb_value self) |
125 | 129 | { |
126 | 130 | struct RClass *cls; |
127 | - mrb_value src, result; | |
131 | + mrb_value other, result; | |
128 | 132 | PNT *self_real, *other_real; |
129 | 133 | |
130 | 134 | cls = mrb_obj_class(mrb, self); |
@@ -150,7 +154,7 @@ LOCAL mrb_value | ||
150 | 154 | mrb_PNT_minus(mrb_state *mrb, mrb_value self) |
151 | 155 | { |
152 | 156 | struct RClass *cls; |
153 | - mrb_value src, result; | |
157 | + mrb_value other, result; | |
154 | 158 | PNT *self_real, *other_real; |
155 | 159 | |
156 | 160 | cls = mrb_obj_class(mrb, self); |