1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

ext/win32ole/win32ole_event.c: use typed data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
suke 2014-11-17 11:18:54 +00:00
parent d35a2bd4df
commit aed7a09aea
2 changed files with 25 additions and 6 deletions

View file

@ -1,3 +1,7 @@
Mon Nov 17 20:17:59 2014 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole_event.c: use typed data.
Mon Nov 17 12:54:56 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
* lib/rubygems/*, test/rubygems/*: Update to RubyGems 2.4.4

View file

@ -86,7 +86,8 @@ static long ole_search_event_at(VALUE ary, VALUE ev);
static VALUE ole_search_event(VALUE ary, VALUE ev, BOOL *is_default);
static VALUE ole_search_handler_method(VALUE handler, VALUE ev, BOOL *is_default_handler);
static void ole_delete_event(VALUE ary, VALUE ev);
static void ole_event_free(struct oleeventdata *poleev);
static void oleevent_free(void *ptr);
static size_t oleevent_size(const void *ptr);
static VALUE fev_s_allocate(VALUE klass);
static VALUE ev_advise(int argc, VALUE *argv, VALUE self);
static VALUE fev_initialize(int argc, VALUE *argv, VALUE self);
@ -105,6 +106,13 @@ static VALUE evs_delete(long i);
static VALUE evs_entry(long i);
static long evs_length(void);
static const rb_data_type_t oleevent_datatype = {
"win32ole_event",
{NULL, oleevent_free, oleevent_size,},
NULL, NULL, RUBY_TYPED_FREE_IMMEDIATELY
};
STDMETHODIMP EVENTSINK_Invoke(
PEVENTSINK pEventSink,
DISPID dispid,
@ -852,8 +860,9 @@ ole_delete_event(VALUE ary, VALUE ev)
static void
ole_event_free(struct oleeventdata *poleev)
oleevent_free(void *ptr)
{
struct oleeventdata *poleev = ptr;
if (poleev->pConnectionPoint) {
poleev->pConnectionPoint->lpVtbl->Unadvise(poleev->pConnectionPoint, poleev->dwCookie);
OLE_RELEASE(poleev->pConnectionPoint);
@ -863,12 +872,18 @@ ole_event_free(struct oleeventdata *poleev)
free(poleev);
}
static size_t
oleevent_size(const void *ptr)
{
return ptr ? sizeof(struct oleeventdata) : 0;
}
static VALUE
fev_s_allocate(VALUE klass)
{
VALUE obj;
struct oleeventdata *poleev;
obj = Data_Make_Struct(klass,struct oleeventdata,0,ole_event_free,poleev);
obj = TypedData_Make_Struct(klass, struct oleeventdata, &oleevent_datatype, poleev);
poleev->dwCookie = 0;
poleev->pConnectionPoint = NULL;
poleev->event_id = 0;
@ -944,7 +959,7 @@ ev_advise(int argc, VALUE *argv, VALUE self)
ole_raise(hr, rb_eRuntimeError, "Advise Error");
}
Data_Get_Struct(self, struct oleeventdata, poleev);
TypedData_Get_Struct(self, struct oleeventdata, &oleevent_datatype, poleev);
pIEV->m_event_id = evs_length();
pIEV->pTypeInfo = pTypeInfo;
poleev->dwCookie = dwCookie;
@ -1016,7 +1031,7 @@ ev_on_event(int argc, VALUE *argv, VALUE self, VALUE is_ary_arg)
{
struct oleeventdata *poleev;
VALUE event, args, data;
Data_Get_Struct(self, struct oleeventdata, poleev);
TypedData_Get_Struct(self, struct oleeventdata, &oleevent_datatype, poleev);
if (poleev->pConnectionPoint == NULL) {
rb_raise(eWIN32OLERuntimeError, "IConnectionPoint not found. You must call advise at first.");
}
@ -1146,7 +1161,7 @@ static VALUE
fev_unadvise(VALUE self)
{
struct oleeventdata *poleev;
Data_Get_Struct(self, struct oleeventdata, poleev);
TypedData_Get_Struct(self, struct oleeventdata, &oleevent_datatype, poleev);
if (poleev->pConnectionPoint) {
ole_msg_loop();
evs_delete(poleev->event_id);