toxon
/
lita-tox
Archived
1
0
Fork 0

Implement Tox::Options#data=

This commit is contained in:
Braiden Vasco 2015-09-12 00:13:52 +00:00
parent 063475b597
commit ba96349489
1 changed files with 17 additions and 0 deletions

View File

@ -20,6 +20,7 @@ static VALUE cTox_cOptions;
static VALUE cTox_cOptions_alloc(VALUE klass);
static void cTox_cOptions_free(void *ptr);
static VALUE cTox_cOptions_initialize(VALUE self);
static VALUE cTox_cOptions_data_EQUALS(VALUE self, VALUE data);
void Init_tox()
{
@ -31,6 +32,7 @@ void Init_tox()
cTox_cOptions = rb_define_class_under(cTox, "Options", rb_cObject);
rb_define_alloc_func(cTox_cOptions, cTox_cOptions_alloc);
rb_define_method(cTox_cOptions, "initialize", cTox_cOptions_initialize, 0);
rb_define_method(cTox_cOptions, "data=", cTox_cOptions_data_EQUALS, 1);
}
/******************************************************************************
@ -117,3 +119,18 @@ VALUE cTox_cOptions_initialize(const VALUE self)
return self;
}
VALUE cTox_cOptions_data_EQUALS(VALUE self, VALUE savedata)
{
cTox_cOptions_ *tox_options;
Check_Type(savedata, T_STRING);
Data_Get_Struct(self, cTox_cOptions_, tox_options);
tox_options->savedata_type = TOX_SAVEDATA_TYPE_TOX_SAVE;
tox_options->savedata_data = (uint8_t*)RSTRING_PTR(savedata);
tox_options->savedata_length = RSTRING_LEN(savedata);
return savedata;
}