vbscript: Added compiler support for string literals.
[wine] / dlls / vbscript / vbscript_main.c
1 /*
2  * Copyright 2011 Jacek Caban for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include "initguid.h"
20
21 #include "vbscript.h"
22 #include "objsafe.h"
23 #include "rpcproxy.h"
24 #include "vbscript_classes.h"
25
26 #include "wine/debug.h"
27
28 WINE_DEFAULT_DEBUG_CHANNEL(vbscript);
29
30 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
31
32 static HINSTANCE vbscript_hinstance;
33
34 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
35 {
36     *ppv = NULL;
37
38     if(IsEqualGUID(&IID_IUnknown, riid)) {
39         TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
40         *ppv = iface;
41     }else if(IsEqualGUID(&IID_IClassFactory, riid)) {
42         TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
43         *ppv = iface;
44     }
45
46     if(*ppv) {
47         IUnknown_AddRef((IUnknown*)*ppv);
48         return S_OK;
49     }
50
51     FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
52     return E_NOINTERFACE;
53 }
54
55 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
56 {
57     TRACE("(%p)\n", iface);
58     return 2;
59 }
60
61 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
62 {
63     TRACE("(%p)\n", iface);
64     return 1;
65 }
66
67 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
68 {
69     TRACE("(%p)->(%x)\n", iface, fLock);
70     return S_OK;
71 }
72
73 static const IClassFactoryVtbl VBScriptFactoryVtbl = {
74     ClassFactory_QueryInterface,
75     ClassFactory_AddRef,
76     ClassFactory_Release,
77     VBScriptFactory_CreateInstance,
78     ClassFactory_LockServer
79 };
80
81 static IClassFactory VBScriptFactory = { &VBScriptFactoryVtbl };
82
83 /******************************************************************
84  *              DllMain (vbscript.@)
85  */
86 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
87 {
88     TRACE("(%p %d %p)\n", hInstDLL, fdwReason, lpv);
89
90     switch(fdwReason)
91     {
92     case DLL_WINE_PREATTACH:
93         return FALSE;  /* prefer native version */
94     case DLL_PROCESS_ATTACH:
95         DisableThreadLibraryCalls(hInstDLL);
96         vbscript_hinstance = hInstDLL;
97         break;
98     }
99
100     return TRUE;
101 }
102
103 /***********************************************************************
104  *              DllGetClassObject       (vbscript.@)
105  */
106 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
107 {
108     if(IsEqualGUID(&CLSID_VBScript, rclsid)) {
109         TRACE("(CLSID_VBScript %s %p)\n", debugstr_guid(riid), ppv);
110         return IClassFactory_QueryInterface(&VBScriptFactory, riid, ppv);
111     }
112
113     FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
114     return CLASS_E_CLASSNOTAVAILABLE;
115 }
116
117 /***********************************************************************
118  *          DllCanUnloadNow (vbscript.@)
119  */
120 HRESULT WINAPI DllCanUnloadNow(void)
121 {
122     return S_FALSE;
123 }
124
125 /***********************************************************************
126  *          DllRegisterServer (vbscript.@)
127  */
128 HRESULT WINAPI DllRegisterServer(void)
129 {
130     TRACE("()\n");
131     return __wine_register_resources(vbscript_hinstance);
132 }
133
134 /***********************************************************************
135  *          DllUnregisterServer (vbscript.@)
136  */
137 HRESULT WINAPI DllUnregisterServer(void)
138 {
139     TRACE("()\n");
140     return __wine_unregister_resources(vbscript_hinstance);
141 }