Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Changed bridgesupport format

  • Loading branch information...
commit 9d6e4087412f50a237354523e1247b9e290bc5ff 1 parent 52b7675
@masuidrive masuidrive authored
Showing with 19 additions and 8 deletions.
  1. +1 −0  include/cocoa.h
  2. +16 −6 src/cocoa_bridgesupport.m
  3. +2 −2 test/define.m
View
1  include/cocoa.h
@@ -51,6 +51,7 @@ struct BridgeSupportEnumTable
const char *name;
const char type;
union {
+ char dump[8];
uint64_t u64;
int64_t i64;
double dbl;
View
22 src/cocoa_bridgesupport.m
@@ -95,7 +95,7 @@
char *namestr = mrb_string_value_ptr(mrb, name);
struct BridgeSupportConstTable *ccur = cs->const_table;
- while(ccur->name) {
+ while(ccur && ccur->name) {
if(strcmp(namestr, ccur->name)==0) {
mrb_value type = objc_type_to_cfunc_type(mrb, ccur->type);
mrb_value ptr = cfunc_pointer_new_with_pointer(mrb, ccur->value, false);
@@ -105,20 +105,30 @@
}
struct BridgeSupportEnumTable *ecur = cs->enum_table;
- while(ecur->name) {
+ while(ecur && ecur->name) {
if(strcmp(namestr, ecur->name)==0) {
struct cfunc_state *cfs = cfunc_state(mrb, NULL);
- mrb_value result_ptr = cfunc_pointer_new_with_pointer(mrb, &ecur->value, false);
+ struct cfunc_type_data *data;
+ mrb_value val;
switch(ecur->type) {
case 's':
- return mrb_funcall(mrb, mrb_obj_value(cfs->sint64_class), "refer", 1, result_ptr);
+ val = mrb_funcall(mrb, mrb_obj_value(cfs->sint64_class), "new", 0);
+ data = (struct cfunc_type_data*)DATA_PTR(val);
+ data->value._sint64 = ecur->value.i64;
+ return val;
case 'u':
- return mrb_funcall(mrb, mrb_obj_value(cfs->uint64_class), "refer", 1, result_ptr);
+ val = mrb_funcall(mrb, mrb_obj_value(cfs->uint64_class), "new", 0);
+ data = (struct cfunc_type_data*)DATA_PTR(val);
+ data->value._uint64 = ecur->value.u64;
+ return val;
case 'd':
- return mrb_funcall(mrb, mrb_obj_value(cfs->double_class), "refer", 1, result_ptr);
+ val = mrb_funcall(mrb, mrb_obj_value(cfs->double_class), "new", 0);
+ data = (struct cfunc_type_data*)DATA_PTR(val);
+ data->value._double = ecur->value.dbl;
+ return val;
default:
return mrb_nil_value();
View
4 test/define.m
@@ -17,8 +17,8 @@
};
struct BridgeSupportEnumTable enum_table[] = {
- {.name="enum1", .value={0x1}, .type='s'},
- {.name="enum2", .value={0x3fd0000000000000}, .type='d'}, // 0.25
+ {.name="enum1", .value={"\001\000\000\000\000\000\000\000"}, .type='s'},
+ {.name="enum2", .value={"\000\000\000\000\000\000\320?"}, .type='d'}, // 0.25
{.name = NULL}
};
Please sign in to comment.
Something went wrong with that request. Please try again.