DXGL r44 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r43‎ | r44 | r45 >
Date:17:29, 25 December 2011
Author:admin
Status:new
Tags:
Comment:
Begin adding COM interface.
Modified paths:
  • /ddraw/ddraw.cpp (modified) (history)
  • /ddraw/ddraw.vcxproj (modified) (history)
  • /ddraw/ddraw.vcxproj.filters (modified) (history)
  • /ddraw/glClassFactory.cpp (added) (history)
  • /ddraw/glClassFactory.h (added) (history)

Diff [purge]

Index: ddraw/ddraw.cpp
@@ -17,6 +17,7 @@
1818
1919 #include "common.h"
2020 #include "ddraw.h"
 21+#include "glClassFactory.h"
2122 #include "glDirectDraw.h"
2223 #include "glDirectDrawClipper.h"
2324 #include <intrin.h>
@@ -234,8 +235,12 @@
235236 }
236237 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
237238 {
238 - FIXME("DllGetClassObject: stub\n");
239 - return CLASS_E_CLASSNOTAVAILABLE;
 239+ if(rclsid != CLSID_DirectDraw) return CLASS_E_CLASSNOTAVAILABLE;
 240+ glClassFactory *factory = new glClassFactory;
 241+ if(factory == NULL) return E_OUTOFMEMORY;
 242+ HRESULT result = factory->QueryInterface(riid,ppv);
 243+ factory->Release();
 244+ return result;
240245 }
241246 DDRAW_API void WINAPI GetDDSurfaceLocal()
242247 {
Index: ddraw/ddraw.vcxproj
@@ -161,6 +161,7 @@
162162 <ItemGroup>
163163 <ClInclude Include="common.h" />
164164 <ClInclude Include="ddraw.h" />
 165+ <ClInclude Include="glClassFactory.h" />
165166 <ClInclude Include="glDirectDraw.h" />
166167 <ClInclude Include="glDirectDrawClipper.h" />
167168 <ClInclude Include="glDirectDrawPalette.h" />
@@ -191,6 +192,7 @@
192193 <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release no DXGL|Win32'">
193194 </PrecompiledHeader>
194195 </ClCompile>
 196+ <ClCompile Include="glClassFactory.cpp" />
195197 <ClCompile Include="dxguid.cpp">
196198 <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
197199 <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug no DXGL|Win32'">NotUsing</PrecompiledHeader>
Index: ddraw/ddraw.vcxproj.filters
@@ -71,6 +71,9 @@
7272 <ClInclude Include="scalers.h">
7373 <Filter>Header Files</Filter>
7474 </ClInclude>
 75+ <ClInclude Include="glClassFactory.h">
 76+ <Filter>Header Files</Filter>
 77+ </ClInclude>
7578 </ItemGroup>
7679 <ItemGroup>
7780 <ClCompile Include="ddraw.cpp">
@@ -106,6 +109,9 @@
107110 <ClCompile Include="scalers.cpp">
108111 <Filter>Source Files</Filter>
109112 </ClCompile>
 113+ <ClCompile Include="glClassFactory.cpp">
 114+ <Filter>Source Files</Filter>
 115+ </ClCompile>
110116 </ItemGroup>
111117 <ItemGroup>
112118 <ResourceCompile Include="ddraw.rc">
Index: ddraw/glClassFactory.cpp
@@ -0,0 +1,50 @@
 2+// DXGL
 3+// Copyright (C) 2011 William Feely
 4+
 5+// This library is free software; you can redistribute it and/or
 6+// modify it under the terms of the GNU Lesser General Public
 7+// License as published by the Free Software Foundation; either
 8+// version 2.1 of the License, or (at your option) any later version.
 9+
 10+// This library is distributed in the hope that it will be useful,
 11+// but WITHOUT ANY WARRANTY; without even the implied warranty of
 12+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 13+// Lesser General Public License for more details.
 14+
 15+// You should have received a copy of the GNU Lesser General Public
 16+// License along with this library; if not, write to the Free Software
 17+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 18+
 19+#include "common.h"
 20+#include "glClassFactory.h"
 21+
 22+ULONG WINAPI glClassFactory::AddRef()
 23+{
 24+ refcount++;
 25+ return refcount;
 26+}
 27+ULONG WINAPI glClassFactory::Release()
 28+{
 29+ ULONG ret;
 30+ refcount--;
 31+ ret = refcount;
 32+ if(refcount == 0) delete this;
 33+ return ret;
 34+}
 35+
 36+HRESULT WINAPI glClassFactory::QueryInterface(REFIID riid, void** ppvObj)
 37+{
 38+ FIXME("glClassFactory::QueryInterface: stub");
 39+ return E_FAIL;
 40+}
 41+HRESULT WINAPI glClassFactory::CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObject)
 42+{
 43+ FIXME("glClassFactory::CreateInterface: stub");
 44+ return E_FAIL;
 45+}
 46+HRESULT WINAPI glClassFactory::LockServer(BOOL fLock)
 47+{
 48+ FIXME("glClassFactory::LockServer: stub");
 49+ return E_FAIL;
 50+}
 51+
Index: ddraw/glClassFactory.h
@@ -0,0 +1,36 @@
 2+// DXGL
 3+// Copyright (C) 2011 William Feely
 4+
 5+// This library is free software; you can redistribute it and/or
 6+// modify it under the terms of the GNU Lesser General Public
 7+// License as published by the Free Software Foundation; either
 8+// version 2.1 of the License, or (at your option) any later version.
 9+
 10+// This library is distributed in the hope that it will be useful,
 11+// but WITHOUT ANY WARRANTY; without even the implied warranty of
 12+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 13+// Lesser General Public License for more details.
 14+
 15+// You should have received a copy of the GNU Lesser General Public
 16+// License along with this library; if not, write to the Free Software
 17+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 18+
 19+#pragma once
 20+#ifndef _DXGLCLASSFACTORY_H
 21+#define _DXGLCLASSFACTORY_H
 22+
 23+class glClassFactory : public IClassFactory
 24+{
 25+public:
 26+ ULONG WINAPI AddRef();
 27+ ULONG WINAPI Release();
 28+ HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
 29+ HRESULT WINAPI CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObject);
 30+ HRESULT WINAPI LockServer(BOOL fLock);
 31+ glClassFactory() {refcount = 1; lockcount = 0;}
 32+ ~glClassFactory() {}
 33+private:
 34+ ULONG refcount;
 35+ ULONG lockcount;
 36+};
 37+#endif //_DXGLCLASSFACTORY_H