wsock32: Assign to struct instead of using memcpy.
[wine/hacks.git] / dlls / mshtml / htmlscript.c
blob5bf4a180c5e951d5806563d8ec829849bd5e1ec0
1 /*
2 * Copyright 2008 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "winnls.h"
30 #include "ole2.h"
32 #include "wine/debug.h"
34 #include "mshtml_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
38 typedef struct {
39 HTMLElement element;
41 const IHTMLScriptElementVtbl *lpHTMLScriptElementVtbl;
43 nsIDOMHTMLScriptElement *nsscript;
44 } HTMLScriptElement;
46 #define HTMLSCRIPT(x) ((IHTMLScriptElement*) &(x)->lpHTMLScriptElementVtbl)
48 #define HTMLSCRIPT_THIS(iface) DEFINE_THIS(HTMLScriptElement, HTMLScriptElement, iface)
50 static HRESULT WINAPI HTMLScriptElement_QueryInterface(IHTMLScriptElement *iface,
51 REFIID riid, void **ppv)
53 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
55 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
58 static ULONG WINAPI HTMLScriptElement_AddRef(IHTMLScriptElement *iface)
60 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
62 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node));
65 static ULONG WINAPI HTMLScriptElement_Release(IHTMLScriptElement *iface)
67 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
69 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node));
72 static HRESULT WINAPI HTMLScriptElement_GetTypeInfoCount(IHTMLScriptElement *iface, UINT *pctinfo)
74 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
75 FIXME("(%p)->(%p)\n", This, pctinfo);
76 return E_NOTIMPL;
79 static HRESULT WINAPI HTMLScriptElement_GetTypeInfo(IHTMLScriptElement *iface, UINT iTInfo,
80 LCID lcid, ITypeInfo **ppTInfo)
82 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
83 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
84 return E_NOTIMPL;
87 static HRESULT WINAPI HTMLScriptElement_GetIDsOfNames(IHTMLScriptElement *iface, REFIID riid,
88 LPOLESTR *rgszNames, UINT cNames,
89 LCID lcid, DISPID *rgDispId)
91 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
92 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
93 lcid, rgDispId);
94 return E_NOTIMPL;
97 static HRESULT WINAPI HTMLScriptElement_Invoke(IHTMLScriptElement *iface, DISPID dispIdMember,
98 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
99 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
101 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
102 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
103 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
104 return E_NOTIMPL;
107 static HRESULT WINAPI HTMLScriptElement_put_src(IHTMLScriptElement *iface, BSTR v)
109 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
110 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
111 return E_NOTIMPL;
114 static HRESULT WINAPI HTMLScriptElement_get_src(IHTMLScriptElement *iface, BSTR *p)
116 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
117 FIXME("(%p)->(%p)\n", This, p);
118 return E_NOTIMPL;
121 static HRESULT WINAPI HTMLScriptElement_put_htmlFor(IHTMLScriptElement *iface, BSTR v)
123 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
124 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
125 return E_NOTIMPL;
128 static HRESULT WINAPI HTMLScriptElement_get_htmlFor(IHTMLScriptElement *iface, BSTR *p)
130 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
131 FIXME("(%p)->(%p)\n", This, p);
132 return E_NOTIMPL;
135 static HRESULT WINAPI HTMLScriptElement_put_event(IHTMLScriptElement *iface, BSTR v)
137 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
138 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
139 return E_NOTIMPL;
142 static HRESULT WINAPI HTMLScriptElement_get_event(IHTMLScriptElement *iface, BSTR *p)
144 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
145 FIXME("(%p)->(%p)\n", This, p);
146 return E_NOTIMPL;
149 static HRESULT WINAPI HTMLScriptElement_put_text(IHTMLScriptElement *iface, BSTR v)
151 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
152 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
153 return E_NOTIMPL;
156 static HRESULT WINAPI HTMLScriptElement_get_text(IHTMLScriptElement *iface, BSTR *p)
158 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
159 FIXME("(%p)->(%p)\n", This, p);
160 return E_NOTIMPL;
163 static HRESULT WINAPI HTMLScriptElement_put_defer(IHTMLScriptElement *iface, VARIANT_BOOL v)
165 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
166 FIXME("(%p)->(%x)\n", This, v);
167 return E_NOTIMPL;
170 static HRESULT WINAPI HTMLScriptElement_get_defer(IHTMLScriptElement *iface, VARIANT_BOOL *p)
172 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
173 FIXME("(%p)->(%p)\n", This, p);
174 return E_NOTIMPL;
177 static HRESULT WINAPI HTMLScriptElement_get_readyState(IHTMLScriptElement *iface, BSTR *p)
179 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
180 FIXME("(%p)->(%p)\n", This, p);
181 return E_NOTIMPL;
184 static HRESULT WINAPI HTMLScriptElement_put_onerror(IHTMLScriptElement *iface, VARIANT v)
186 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
187 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
188 return E_NOTIMPL;
191 static HRESULT WINAPI HTMLScriptElement_get_onerror(IHTMLScriptElement *iface, VARIANT *p)
193 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
194 FIXME("(%p)->(%p)\n", This, p);
195 return E_NOTIMPL;
198 static HRESULT WINAPI HTMLScriptElement_put_type(IHTMLScriptElement *iface, BSTR v)
200 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
201 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
202 return E_NOTIMPL;
205 static HRESULT WINAPI HTMLScriptElement_get_type(IHTMLScriptElement *iface, BSTR *p)
207 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
208 const PRUnichar *nstype;
209 nsAString nstype_str;
210 nsresult nsres;
212 TRACE("(%p)->(%p)\n", This, p);
214 nsAString_Init(&nstype_str, NULL);
215 nsres = nsIDOMHTMLScriptElement_GetType(This->nsscript, &nstype_str);
216 if(NS_FAILED(nsres))
217 ERR("GetType failed: %08x\n", nsres);
219 nsAString_GetData(&nstype_str, &nstype);
220 *p = *nstype ? SysAllocString(nstype) : NULL;
221 nsAString_Finish(&nstype_str);
223 return S_OK;
226 static const IHTMLScriptElementVtbl HTMLScriptElementVtbl = {
227 HTMLScriptElement_QueryInterface,
228 HTMLScriptElement_AddRef,
229 HTMLScriptElement_Release,
230 HTMLScriptElement_GetTypeInfoCount,
231 HTMLScriptElement_GetTypeInfo,
232 HTMLScriptElement_GetIDsOfNames,
233 HTMLScriptElement_Invoke,
234 HTMLScriptElement_put_src,
235 HTMLScriptElement_get_src,
236 HTMLScriptElement_put_htmlFor,
237 HTMLScriptElement_get_htmlFor,
238 HTMLScriptElement_put_event,
239 HTMLScriptElement_get_event,
240 HTMLScriptElement_put_text,
241 HTMLScriptElement_get_text,
242 HTMLScriptElement_put_defer,
243 HTMLScriptElement_get_defer,
244 HTMLScriptElement_get_readyState,
245 HTMLScriptElement_put_onerror,
246 HTMLScriptElement_get_onerror,
247 HTMLScriptElement_put_type,
248 HTMLScriptElement_get_type
251 #undef HTMLSCRIPT_THIS
253 #define HTMLSCRIPT_NODE_THIS(iface) DEFINE_THIS2(HTMLScriptElement, element.node, iface)
255 static HRESULT HTMLScriptElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
257 HTMLScriptElement *This = HTMLSCRIPT_NODE_THIS(iface);
259 *ppv = NULL;
261 if(IsEqualGUID(&IID_IUnknown, riid)) {
262 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
263 *ppv = HTMLSCRIPT(This);
264 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
265 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
266 *ppv = HTMLSCRIPT(This);
267 }else if(IsEqualGUID(&IID_IHTMLScriptElement, riid)) {
268 TRACE("(%p)->(IID_IHTMLScriptElement %p)\n", This, ppv);
269 *ppv = HTMLSCRIPT(This);
272 if(*ppv) {
273 IUnknown_AddRef((IUnknown*)*ppv);
274 return S_OK;
277 return HTMLElement_QI(&This->element.node, riid, ppv);
280 static void HTMLScriptElement_destructor(HTMLDOMNode *iface)
282 HTMLScriptElement *This = HTMLSCRIPT_NODE_THIS(iface);
283 HTMLElement_destructor(&This->element.node);
286 #undef HTMLSCRIPT_NODE_THIS
288 static const NodeImplVtbl HTMLScriptElementImplVtbl = {
289 HTMLScriptElement_QI,
290 HTMLScriptElement_destructor
293 HTMLElement *HTMLScriptElement_Create(nsIDOMHTMLElement *nselem)
295 HTMLScriptElement *ret = heap_alloc(sizeof(HTMLScriptElement));
296 nsresult nsres;
298 HTMLElement_Init(&ret->element);
300 ret->lpHTMLScriptElementVtbl = &HTMLScriptElementVtbl;
301 ret->element.node.vtbl = &HTMLScriptElementImplVtbl;
303 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLScriptElement, (void**)&ret->nsscript);
304 if(NS_FAILED(nsres))
305 ERR("Could not get nsIDOMHTMLScriptElement: %08x\n", nsres);
307 return &ret->element;