Commit 6a2ca11c authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

mshtml: Use unlink and destructor in the vtbl for function disps.

parent 3c92edfd
......@@ -826,11 +826,8 @@ static ULONG WINAPI Function_Release(IUnknown *iface)
TRACE("(%p) ref=%ld\n", This, ref);
if(!ref) {
assert(!This->obj);
if(!ref)
release_dispex(&This->dispex);
free(This);
}
return ref;
}
......@@ -846,6 +843,13 @@ static inline func_disp_t *impl_from_DispatchEx(DispatchEx *iface)
return CONTAINING_RECORD(iface, func_disp_t, dispex);
}
static void function_destructor(DispatchEx *dispex)
{
func_disp_t *This = impl_from_DispatchEx(dispex);
assert(!This->obj);
free(This);
}
static HRESULT function_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *params,
VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
{
......@@ -902,6 +906,8 @@ static HRESULT function_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPAR
}
static const dispex_static_data_vtbl_t function_dispex_vtbl = {
function_destructor,
NULL,
function_value,
NULL,
NULL,
......@@ -2053,8 +2059,11 @@ void release_dispex(DispatchEx *This)
{
dynamic_prop_t *prop;
if(This->info->desc->vtbl && This->info->desc->vtbl->unlink)
This->info->desc->vtbl->unlink(This);
if(!This->dynamic_data)
return;
goto destructor;
for(prop = This->dynamic_data->props; prop < This->dynamic_data->props + This->dynamic_data->prop_cnt; prop++) {
VariantClear(&prop->var);
......@@ -2078,6 +2087,10 @@ void release_dispex(DispatchEx *This)
}
free(This->dynamic_data);
destructor:
if(This->info->desc->vtbl && This->info->desc->vtbl->destructor)
This->info->desc->vtbl->destructor(This);
}
void init_dispatch(DispatchEx *dispex, IUnknown *outer, dispex_static_data_t *data, compat_mode_t compat_mode)
......
......@@ -6088,6 +6088,8 @@ static const event_target_vtbl_t HTMLDocumentNode_event_target_vtbl = {
{
NULL,
NULL,
NULL,
NULL,
HTMLDocumentNode_get_name,
HTMLDocumentNode_invoke,
NULL,
......
......@@ -1270,6 +1270,8 @@ static HRESULT HTMLRectCollection_invoke(DispatchEx *dispex, DISPID id, LCID lci
static const dispex_static_data_vtbl_t HTMLRectCollection_dispex_vtbl = {
NULL,
NULL,
NULL,
HTMLRectCollection_get_dispid,
HTMLRectCollection_get_name,
HTMLRectCollection_invoke,
......@@ -7329,6 +7331,8 @@ static const tid_t HTMLElement_iface_tids[] = {
const event_target_vtbl_t HTMLElement_event_target_vtbl = {
{
NULL,
NULL,
NULL,
HTMLElement_get_dispid,
HTMLElement_get_name,
HTMLElement_invoke,
......@@ -7795,6 +7799,8 @@ static HRESULT token_list_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD
}
static const dispex_static_data_vtbl_t token_list_dispex_vtbl = {
NULL,
NULL,
token_list_value,
token_list_get_dispid,
token_list_get_name,
......@@ -8212,6 +8218,8 @@ static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID
static const dispex_static_data_vtbl_t HTMLFiltersCollection_dispex_vtbl = {
NULL,
NULL,
NULL,
HTMLFiltersCollection_get_dispid,
HTMLFiltersCollection_get_name,
HTMLFiltersCollection_invoke,
......@@ -8968,6 +8976,8 @@ static HRESULT HTMLAttributeCollection_invoke(DispatchEx *dispex, DISPID id, LCI
static const dispex_static_data_vtbl_t HTMLAttributeCollection_dispex_vtbl = {
NULL,
NULL,
NULL,
HTMLAttributeCollection_get_dispid,
HTMLAttributeCollection_get_name,
HTMLAttributeCollection_invoke,
......
......@@ -623,6 +623,8 @@ static HRESULT HTMLElementCollection_invoke(DispatchEx *dispex, DISPID id, LCID
static const dispex_static_data_vtbl_t HTMLElementColection_dispex_vtbl = {
NULL,
NULL,
NULL,
HTMLElementCollection_get_dispid,
HTMLElementCollection_get_name,
HTMLElementCollection_invoke,
......
......@@ -975,6 +975,8 @@ static const tid_t HTMLImageElementFactory_iface_tids[] = {
};
static const dispex_static_data_vtbl_t HTMLImageElementFactory_dispex_vtbl = {
NULL,
NULL,
HTMLImageElementFactory_value,
NULL,
NULL,
......
......@@ -434,6 +434,8 @@ static HRESULT HTMLDOMChildrenCollection_invoke(DispatchEx *dispex, DISPID id, L
static const dispex_static_data_vtbl_t HTMLDOMChildrenCollection_dispex_vtbl = {
NULL,
NULL,
NULL,
HTMLDOMChildrenCollection_get_dispid,
HTMLDOMChildrenCollection_get_name,
HTMLDOMChildrenCollection_invoke,
......
......@@ -629,6 +629,8 @@ static const tid_t HTMLOptionElementFactory_iface_tids[] = {
};
static const dispex_static_data_vtbl_t HTMLOptionElementFactory_dispex_vtbl = {
NULL,
NULL,
HTMLOptionElementFactory_value,
NULL,
NULL,
......
......@@ -1309,6 +1309,8 @@ static HRESULT HTMLStorage_next_dispid(DispatchEx *dispex, DISPID id, DISPID *pi
static const dispex_static_data_vtbl_t HTMLStorage_dispex_vtbl = {
NULL,
NULL,
NULL,
HTMLStorage_get_dispid,
HTMLStorage_get_name,
HTMLStorage_invoke,
......
......@@ -9998,6 +9998,8 @@ void CSSStyle_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
const dispex_static_data_vtbl_t CSSStyle_dispex_vtbl = {
NULL,
NULL,
NULL,
CSSStyle_get_dispid,
NULL,
NULL
......
......@@ -467,6 +467,8 @@ static HRESULT HTMLStyleSheetRulesCollection_invoke(DispatchEx *dispex, DISPID i
static const dispex_static_data_vtbl_t HTMLStyleSheetRulesCollection_dispex_vtbl = {
NULL,
NULL,
NULL,
HTMLStyleSheetRulesCollection_get_dispid,
HTMLStyleSheetRulesCollection_get_name,
HTMLStyleSheetRulesCollection_invoke
......@@ -894,6 +896,8 @@ static HRESULT HTMLStyleSheetsCollection_invoke(DispatchEx *dispex, DISPID id, L
static const dispex_static_data_vtbl_t HTMLStyleSheetsCollection_dispex_vtbl = {
NULL,
NULL,
NULL,
HTMLStyleSheetsCollection_get_dispid,
HTMLStyleSheetsCollection_get_name,
HTMLStyleSheetsCollection_invoke
......
......@@ -4030,6 +4030,8 @@ static const event_target_vtbl_t HTMLWindow_event_target_vtbl = {
{
NULL,
NULL,
NULL,
NULL,
HTMLWindow_get_name,
HTMLWindow_invoke,
NULL,
......
......@@ -347,6 +347,10 @@ typedef struct DispatchEx DispatchEx;
- dynamic props: These props are generally allocated by external code (e.g. 'document.wine = 42' creates 'wine' dynamic prop on document)
*/
typedef struct {
/* Unlike delete_cycle_collectable, unlink is called before the destructor (if available). */
void (*destructor)(DispatchEx*);
void (*unlink)(DispatchEx*);
/* Called when the object wants to handle DISPID_VALUE invocations */
HRESULT (*value)(DispatchEx*,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
......
......@@ -1790,6 +1790,8 @@ static HRESULT HTMLXMLHttpRequestFactory_value(DispatchEx *iface, LCID lcid, WOR
}
static const dispex_static_data_vtbl_t HTMLXMLHttpRequestFactory_dispex_vtbl = {
NULL,
NULL,
HTMLXMLHttpRequestFactory_value
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment