summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/lzma/CPP/7zip/Compress/CodecExports.cpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/lzma/CPP/7zip/Compress/CodecExports.cpp')
-rw-r--r--3rdparty/lzma/CPP/7zip/Compress/CodecExports.cpp94
1 files changed, 64 insertions, 30 deletions
diff --git a/3rdparty/lzma/CPP/7zip/Compress/CodecExports.cpp b/3rdparty/lzma/CPP/7zip/Compress/CodecExports.cpp
index 99085040d07..e37ae143b05 100644
--- a/3rdparty/lzma/CPP/7zip/Compress/CodecExports.cpp
+++ b/3rdparty/lzma/CPP/7zip/Compress/CodecExports.cpp
@@ -3,11 +3,13 @@
#include "StdAfx.h"
#include "../../../C/CpuArch.h"
+#include "../../../C/7zVersion.h"
#include "../../Common/ComTry.h"
#include "../../Common/MyCom.h"
#include "../../Windows/Defs.h"
+#include "../../Windows/PropVariant.h"
#include "../ICoder.h"
@@ -21,7 +23,7 @@ extern const CHasherInfo *g_Hashers[];
static void SetPropFromAscii(const char *s, PROPVARIANT *prop) throw()
{
- UINT len = (UINT)strlen(s);
+ const UINT len = (UINT)strlen(s);
BSTR dest = ::SysAllocStringLen(NULL, len);
if (dest)
{
@@ -45,7 +47,7 @@ static HRESULT MethodToClassID(UInt16 typeId, CMethodId id, PROPVARIANT *value)
clsId.Data1 = k_7zip_GUID_Data1;
clsId.Data2 = k_7zip_GUID_Data2;
clsId.Data3 = typeId;
- SetUi64(clsId.Data4, id);
+ SetUi64(clsId.Data4, id)
return SetPropGUID(clsId, value);
}
@@ -61,7 +63,7 @@ static HRESULT FindCodecClassId(const GUID *clsid, bool isCoder2, bool isFilter,
if (clsid->Data3 == k_7zip_GUID_Data3_Decoder) encode = false;
else if (clsid->Data3 != k_7zip_GUID_Data3_Encoder) return S_OK;
- UInt64 id = GetUi64(clsid->Data4);
+ const UInt64 id = GetUi64(clsid->Data4);
for (unsigned i = 0; i < g_NumCodecs; i++)
{
@@ -75,13 +77,21 @@ static HRESULT FindCodecClassId(const GUID *clsid, bool isCoder2, bool isFilter,
if (codec.NumStreams == 1 ? isCoder2 : !isCoder2)
return E_NOINTERFACE;
- index = i;
+ index = (int)i;
return S_OK;
}
return S_OK;
}
+/*
+#ifdef __GNUC__
+#ifndef __clang__
+#pragma GCC diagnostic ignored "-Wduplicated-branches"
+#endif
+#endif
+*/
+
static HRESULT CreateCoderMain(unsigned index, bool encode, void **coder)
{
COM_TRY_BEGIN
@@ -97,12 +107,15 @@ static HRESULT CreateCoderMain(unsigned index, bool encode, void **coder)
if (c)
{
IUnknown *unk;
+ unk = (IUnknown *)c;
+ /*
if (codec.IsFilter)
unk = (IUnknown *)(ICompressFilter *)c;
else if (codec.NumStreams != 1)
unk = (IUnknown *)(ICompressCoder2 *)c;
else
unk = (IUnknown *)(ICompressCoder *)c;
+ */
unk->AddRef();
*coder = c;
}
@@ -136,23 +149,29 @@ static HRESULT CreateCoder2(bool encode, UInt32 index, const GUID *iid, void **o
return CreateCoderMain(index, encode, outObject);
}
+
+STDAPI CreateDecoder(UInt32 index, const GUID *iid, void **outObject);
STDAPI CreateDecoder(UInt32 index, const GUID *iid, void **outObject)
{
return CreateCoder2(false, index, iid, outObject);
}
+
+STDAPI CreateEncoder(UInt32 index, const GUID *iid, void **outObject);
STDAPI CreateEncoder(UInt32 index, const GUID *iid, void **outObject)
{
return CreateCoder2(true, index, iid, outObject);
}
+
+STDAPI CreateCoder(const GUID *clsid, const GUID *iid, void **outObject);
STDAPI CreateCoder(const GUID *clsid, const GUID *iid, void **outObject)
{
*outObject = NULL;
bool isFilter = false;
bool isCoder2 = false;
- bool isCoder = (*iid == IID_ICompressCoder) != 0;
+ const bool isCoder = (*iid == IID_ICompressCoder) != 0;
if (!isCoder)
{
isFilter = (*iid == IID_ICompressFilter) != 0;
@@ -166,15 +185,17 @@ STDAPI CreateCoder(const GUID *clsid, const GUID *iid, void **outObject)
bool encode;
int codecIndex;
- HRESULT res = FindCodecClassId(clsid, isCoder2, isFilter, encode, codecIndex);
+ const HRESULT res = FindCodecClassId(clsid, isCoder2, isFilter, encode, codecIndex);
if (res != S_OK)
return res;
if (codecIndex < 0)
return CLASS_E_CLASSNOTAVAILABLE;
- return CreateCoderMain(codecIndex, encode, outObject);
+ return CreateCoderMain((unsigned)codecIndex, encode, outObject);
}
+
+STDAPI GetMethodProperty(UInt32 codecIndex, PROPID propID, PROPVARIANT *value);
STDAPI GetMethodProperty(UInt32 codecIndex, PROPID propID, PROPVARIANT *value)
{
::VariantClear((VARIANTARG *)value);
@@ -211,15 +232,12 @@ STDAPI GetMethodProperty(UInt32 codecIndex, PROPID propID, PROPVARIANT *value)
value->ulVal = (ULONG)codec.NumStreams;
}
break;
- /*
case NMethodPropID::kIsFilter:
- // if (codec.IsFilter)
{
value->vt = VT_BOOL;
value->boolVal = BoolToVARIANT_BOOL(codec.IsFilter);
}
break;
- */
/*
case NMethodPropID::kDecoderFlags:
{
@@ -238,7 +256,9 @@ STDAPI GetMethodProperty(UInt32 codecIndex, PROPID propID, PROPVARIANT *value)
return S_OK;
}
-STDAPI GetNumberOfMethods(UINT32 *numCodecs)
+
+STDAPI GetNumberOfMethods(UInt32 *numCodecs);
+STDAPI GetNumberOfMethods(UInt32 *numCodecs)
{
*numCodecs = g_NumCodecs;
return S_OK;
@@ -253,10 +273,10 @@ static int FindHasherClassId(const GUID *clsid) throw()
clsid->Data2 != k_7zip_GUID_Data2 ||
clsid->Data3 != k_7zip_GUID_Data3_Hasher)
return -1;
- UInt64 id = GetUi64(clsid->Data4);
+ const UInt64 id = GetUi64(clsid->Data4);
for (unsigned i = 0; i < g_NumCodecs; i++)
if (id == g_Hashers[i]->Id)
- return i;
+ return (int)i;
return -1;
}
@@ -270,17 +290,19 @@ static HRESULT CreateHasher2(UInt32 index, IHasher **hasher)
COM_TRY_END
}
+STDAPI CreateHasher(const GUID *clsid, IHasher **outObject);
STDAPI CreateHasher(const GUID *clsid, IHasher **outObject)
{
COM_TRY_BEGIN
- *outObject = 0;
- int index = FindHasherClassId(clsid);
+ *outObject = NULL;
+ const int index = FindHasherClassId(clsid);
if (index < 0)
return CLASS_E_CLASSNOTAVAILABLE;
- return CreateHasher2(index, outObject);
+ return CreateHasher2((UInt32)(unsigned)index, outObject);
COM_TRY_END
}
+STDAPI GetHasherProp(UInt32 codecIndex, PROPID propID, PROPVARIANT *value);
STDAPI GetHasherProp(UInt32 codecIndex, PROPID propID, PROPVARIANT *value)
{
::VariantClear((VARIANTARG *)value);
@@ -306,18 +328,9 @@ STDAPI GetHasherProp(UInt32 codecIndex, PROPID propID, PROPVARIANT *value)
return S_OK;
}
-class CHashers:
- public IHashers,
- public CMyUnknownImp
-{
-public:
- MY_UNKNOWN_IMP1(IHashers)
-
- STDMETHOD_(UInt32, GetNumHashers)();
- STDMETHOD(GetHasherProp)(UInt32 index, PROPID propID, PROPVARIANT *value);
- STDMETHOD(CreateHasher)(UInt32 index, IHasher **hasher);
-};
+Z7_CLASS_IMP_COM_1(CHashers, IHashers) };
+STDAPI GetHashers(IHashers **hashers);
STDAPI GetHashers(IHashers **hashers)
{
COM_TRY_BEGIN
@@ -328,17 +341,38 @@ STDAPI GetHashers(IHashers **hashers)
COM_TRY_END
}
-STDMETHODIMP_(UInt32) CHashers::GetNumHashers()
+Z7_COM7F_IMF2(UInt32, CHashers::GetNumHashers())
{
return g_NumHashers;
}
-STDMETHODIMP CHashers::GetHasherProp(UInt32 index, PROPID propID, PROPVARIANT *value)
+Z7_COM7F_IMF(CHashers::GetHasherProp(UInt32 index, PROPID propID, PROPVARIANT *value))
{
return ::GetHasherProp(index, propID, value);
}
-STDMETHODIMP CHashers::CreateHasher(UInt32 index, IHasher **hasher)
+Z7_COM7F_IMF(CHashers::CreateHasher(UInt32 index, IHasher **hasher))
{
return ::CreateHasher2(index, hasher);
}
+
+
+STDAPI GetModuleProp(PROPID propID, PROPVARIANT *value);
+STDAPI GetModuleProp(PROPID propID, PROPVARIANT *value)
+{
+ ::VariantClear((VARIANTARG *)value);
+ switch (propID)
+ {
+ case NModulePropID::kInterfaceType:
+ {
+ NWindows::NCOM::PropVarEm_Set_UInt32(value, NModuleInterfaceType::k_IUnknown_VirtDestructor_ThisModule);
+ break;
+ }
+ case NModulePropID::kVersion:
+ {
+ NWindows::NCOM::PropVarEm_Set_UInt32(value, (MY_VER_MAJOR << 16) | MY_VER_MINOR);
+ break;
+ }
+ }
+ return S_OK;
+}