Repository: Const-me/Whisper
Branch: master
Commit: 306aadd1fce4
Files: 485
Total size: 3.3 MB
Directory structure:
gitextract_nzqawnur/
├── .gitignore
├── ComLightLib/
│ ├── ComLightLib.vcxproj
│ ├── ComLightLib.vcxproj.filters
│ ├── Exception.hpp
│ ├── Readme.txt
│ ├── client/
│ │ └── CComPtr.hpp
│ ├── comLightClient.h
│ ├── comLightCommon.h
│ ├── comLightServer.h
│ ├── hresult.h
│ ├── pal/
│ │ ├── guiddef.h
│ │ └── hresult.h
│ ├── server/
│ │ ├── Object.hpp
│ │ ├── ObjectRoot.hpp
│ │ ├── RefCounter.hpp
│ │ ├── freeThreadedMarshaller.cpp
│ │ ├── freeThreadedMarshaller.h
│ │ └── interfaceMap.h
│ ├── streams.h
│ ├── unknwn.h
│ └── utils/
│ ├── guid_parse.hpp
│ └── typeTraits.hpp
├── ComputeShaders/
│ ├── ComputeShaders.cpp
│ ├── ComputeShaders.vcxproj
│ ├── ComputeShaders.vcxproj.filters
│ ├── Readme.txt
│ ├── add.hlsl
│ ├── addInPlace.hlsl
│ ├── addRepeat.hlsl
│ ├── addRepeat64.hlsl
│ ├── addRepeatEx.hlsl
│ ├── addRepeatGelu.hlsl
│ ├── addRepeatGelu64.hlsl
│ ├── addRepeatScale.hlsl
│ ├── addRows.hlsl
│ ├── componentwiseBinaryOp.hlsli
│ ├── convolutionMain.hlsl
│ ├── convolutionMain2.hlsl
│ ├── convolutionMain2Fixed.hlsl
│ ├── convolutionPrep1.hlsl
│ ├── convolutionPrep2.hlsl
│ ├── copyConvert.hlsl
│ ├── copyTranspose.hlsl
│ ├── dbgFindNaN.hlsl
│ ├── diagMaskInf.hlsl
│ ├── flashAttention.hlsl
│ ├── flashAttentionCommon.hlsli
│ ├── flashAttentionCompat1.hlsl
│ ├── flashAttentionCompat2.hlsl
│ ├── flashAttentionCompat3.hlsl
│ ├── fmaRepeat1.hlsl
│ ├── fmaRepeat164.hlsl
│ ├── fmaRepeat2.hlsl
│ ├── fp64Utils.hlsli
│ ├── groupReduce.hlsli
│ ├── groupReduce64.hlsli
│ ├── matReshapePanels.hlsl
│ ├── miscUtils.hlsli
│ ├── mulMatByRow.hlsl
│ ├── mulMatByRow64.hlsl
│ ├── mulMatByRowTiled.hlsl
│ ├── mulMatByRowTiledEx.hlsl
│ ├── mulMatByScalar.hlsl
│ ├── mulMatDotMain.hlsl
│ ├── mulMatDotReshape.hlsl
│ ├── mulMatMadMain.hlsl
│ ├── mulMatTiled.hlsl
│ ├── mulMatTiledEx.hlsl
│ ├── norm.hlsl
│ ├── normCompat.hlsl
│ ├── normFixed.hlsl
│ ├── normFixed64.hlsl
│ ├── repeatUtils.hlsli
│ ├── scaleInPlace.hlsl
│ ├── softMax.hlsl
│ ├── softMax64.hlsl
│ ├── softMaxCompat.hlsl
│ ├── softMaxFixed.hlsl
│ ├── softMaxLong.hlsl
│ └── zeroMemory.hlsl
├── Examples/
│ ├── MicrophoneCS/
│ │ ├── CaptureThread.cs
│ │ ├── CommandLineArgs.cs
│ │ ├── MicrophoneCS.cs
│ │ ├── MicrophoneCS.csproj
│ │ ├── Readme.txt
│ │ └── TranscribeCallbacks.cs
│ ├── OldMain/
│ │ ├── OldMain.vcxproj
│ │ ├── OldMain.vcxproj.filters
│ │ ├── Readme.txt
│ │ ├── Utils/
│ │ │ ├── Logger.cpp
│ │ │ └── Logger.h
│ │ ├── dr_wav.h
│ │ └── main.cpp
│ ├── TranscribeCS/
│ │ ├── AnsiCodes.cs
│ │ ├── CommandLineArgs.cs
│ │ ├── Readme.txt
│ │ ├── Transcribe.cs
│ │ ├── TranscribeCS.cs
│ │ └── TranscribeCS.csproj
│ ├── WhisperDesktop/
│ │ ├── AppState.cpp
│ │ ├── AppState.h
│ │ ├── CaptureDlg.cpp
│ │ ├── CaptureDlg.h
│ │ ├── CircleIndicator.cpp
│ │ ├── CircleIndicator.h
│ │ ├── LoadModelDlg.cpp
│ │ ├── LoadModelDlg.h
│ │ ├── ModelAdvancedDlg.cpp
│ │ ├── ModelAdvancedDlg.h
│ │ ├── Readme.txt
│ │ ├── Resource.h
│ │ ├── TranscribeDlg.cpp
│ │ ├── TranscribeDlg.h
│ │ ├── Utils/
│ │ │ ├── DebugConsole.cpp
│ │ │ ├── DebugConsole.h
│ │ │ ├── LanguageDropdown.cpp
│ │ │ ├── LanguageDropdown.h
│ │ │ ├── PendingState.cpp
│ │ │ ├── PendingState.h
│ │ │ ├── TranslateCheckbox.cpp
│ │ │ ├── TranslateCheckbox.h
│ │ │ ├── WTL/
│ │ │ │ ├── MS-PL.txt
│ │ │ │ ├── ReadMe.html
│ │ │ │ ├── atlapp.h
│ │ │ │ ├── atlcrack.h
│ │ │ │ ├── atlctrls.h
│ │ │ │ ├── atlddx.h
│ │ │ │ ├── atlgdi.h
│ │ │ │ ├── atlres.h
│ │ │ │ ├── atluser.h
│ │ │ │ └── atlwinx.h
│ │ │ ├── logger.cpp
│ │ │ ├── logger.h
│ │ │ ├── miscUtils.cpp
│ │ │ └── miscUtils.h
│ │ ├── WhisperDesktop.cpp
│ │ ├── WhisperDesktop.manifest
│ │ ├── WhisperDesktop.rc
│ │ ├── WhisperDesktop.vcxproj
│ │ ├── WhisperDesktop.vcxproj.filters
│ │ ├── framework.h
│ │ ├── stdafx.cpp
│ │ ├── stdafx.h
│ │ ├── targetver.h
│ │ └── useDiscreteGpu.c
│ └── main/
│ ├── Readme.txt
│ ├── main.cpp
│ ├── main.vcxproj
│ ├── main.vcxproj.filters
│ ├── miscUtils.cpp
│ ├── miscUtils.h
│ ├── params.cpp
│ ├── params.h
│ ├── textWriter.cpp
│ └── textWriter.h
├── LICENSE
├── Readme.md
├── SampleClips/
│ ├── Readme.txt
│ ├── columbia-large-1080ti.txt
│ ├── columbia-large-1650.txt
│ ├── columbia-large-vega7.txt
│ ├── columbia-large-vega8.txt
│ ├── columbia-medium-1080ti.txt
│ ├── columbia-medium-1650.txt
│ ├── columbia-medium-vega7.txt
│ ├── columbia-medium-vega8.txt
│ ├── columbia.wma
│ ├── jfk-large-1080ti.txt
│ ├── jfk-large-1650.txt
│ ├── jfk-large-vega7.txt
│ ├── jfk-large-vega8.txt
│ ├── jfk-medium-1080ti.txt
│ ├── jfk-medium-1650.txt
│ ├── jfk-medium-vega7.txt
│ ├── jfk-medium-vega8.txt
│ └── summary.tsv
├── Tools/
│ ├── CompressShaders/
│ │ ├── Cabinet.cs
│ │ ├── CompressShaders.cs
│ │ ├── CompressShaders.csproj
│ │ ├── DetectFp64.cs
│ │ ├── LZ4.cs
│ │ ├── LanguageCodes.cs
│ │ ├── Readme.txt
│ │ └── ShaderNames.cs
│ ├── CompressTables/
│ │ ├── CompressTables.cs
│ │ └── CompressTables.csproj
│ ├── PerfSummary/
│ │ ├── LogParser.cs
│ │ ├── PerfSummary.cs
│ │ ├── PerfSummary.csproj
│ │ └── Summary.cs
│ ├── compareTraces/
│ │ ├── CommandLineArgs.cpp
│ │ ├── CommandLineArgs.h
│ │ ├── Readme.txt
│ │ ├── TraceReader.cpp
│ │ ├── TraceReader.h
│ │ ├── compare.cpp
│ │ ├── compare.h
│ │ ├── compareTraces.cpp
│ │ ├── compareTraces.vcxproj
│ │ ├── compareTraces.vcxproj.filters
│ │ ├── stdafx.cpp
│ │ ├── stdafx.h
│ │ └── testUtils.cpp
│ └── copy-binaries.cmd
├── Whisper/
│ ├── API/
│ │ ├── MfStructs.h
│ │ ├── Readme.txt
│ │ ├── SpecialTokens.h
│ │ ├── TranscribeStructs.h
│ │ ├── iContext.cl.h
│ │ ├── iContext.h
│ │ ├── iMediaFoundation.cl.h
│ │ ├── iMediaFoundation.h
│ │ ├── iTranscribeResult.cl.h
│ │ ├── iTranscribeResult.h
│ │ ├── loggerApi.h
│ │ ├── sFullParams.h
│ │ ├── sLanguageList.h
│ │ ├── sLoadModelCallbacks.h
│ │ ├── sModelSetup.h
│ │ ├── whisperComLight.h
│ │ └── whisperWindows.h
│ ├── CPU/
│ │ ├── BufferAllocator.cpp
│ │ ├── BufferAllocator.h
│ │ ├── DecoderTensors.cpp
│ │ ├── DecoderTensors.h
│ │ ├── HybridLoader.cpp
│ │ ├── HybridLoader.h
│ │ ├── KvTensors.h
│ │ ├── KvTensorsCpu.cpp
│ │ ├── LargeBuffer.cpp
│ │ ├── LargeBuffer.h
│ │ ├── MlContext.h
│ │ ├── MlContextCpu.cpp
│ │ ├── ParallelForRunner.cpp
│ │ ├── ParallelForRunner.h
│ │ ├── Readme.txt
│ │ ├── Tensor.h
│ │ ├── TensorCpu.cpp
│ │ ├── mulMat.cpp
│ │ ├── mulMat.h
│ │ ├── mulMat.kernel.hpp
│ │ ├── mulMatImpl.avx2.cpp
│ │ ├── mulMatImpl.cpp
│ │ ├── mulMatImpl.h
│ │ ├── mulMatImpl.panel.cpp
│ │ ├── mulMatUtils.hpp
│ │ ├── simdUtils.cpp
│ │ └── simdUtils.h
│ ├── D3D/
│ │ ├── Binder.cpp
│ │ ├── Binder.h
│ │ ├── MappedResource.cpp
│ │ ├── MappedResource.h
│ │ ├── RenderDoc/
│ │ │ ├── renderDoc.cpp
│ │ │ ├── renderDoc.h
│ │ │ └── renderdoc_app.h
│ │ ├── createBuffer.cpp
│ │ ├── createBuffer.h
│ │ ├── createDevice.cpp
│ │ ├── createDevice.h
│ │ ├── device.h
│ │ ├── downloadBuffer.cpp
│ │ ├── downloadBuffer.h
│ │ ├── enums.cpp
│ │ ├── enums.h
│ │ ├── listGPUs.cpp
│ │ ├── listGPUs.h
│ │ ├── sGpuInfo.h
│ │ ├── shaderNames.cpp
│ │ ├── shaderNames.h
│ │ ├── shaders.cpp
│ │ └── shaders.h
│ ├── DllMain.cpp
│ ├── Hybrid/
│ │ ├── HybridContext.cpp
│ │ ├── HybridContext.h
│ │ ├── KeyValueDownloader.cpp
│ │ ├── KeyValueDownloader.h
│ │ └── Readme.txt
│ ├── MF/
│ │ ├── AudioBuffer.cpp
│ │ ├── AudioBuffer.h
│ │ ├── AudioCapture.cpp
│ │ ├── AudioCapture.h
│ │ ├── MediaFoundation.cpp
│ │ ├── PcmReader.cpp
│ │ ├── PcmReader.h
│ │ ├── loadAudioFile.cpp
│ │ ├── loadAudioFile.h
│ │ ├── mfStartup.cpp
│ │ ├── mfStartup.h
│ │ ├── mfUtils.cpp
│ │ └── mfUtils.h
│ ├── ML/
│ │ ├── ConstantBuffer.cpp
│ │ ├── ConstantBuffer.h
│ │ ├── Context.ops.cpp
│ │ ├── DbgNanTest.cpp
│ │ ├── DbgNanTest.h
│ │ ├── Device.cpp
│ │ ├── Device.h
│ │ ├── LookupTables.cpp
│ │ ├── LookupTables.h
│ │ ├── LookupTablesData.cpp
│ │ ├── LookupTablesData.h
│ │ ├── LookupTablesData.inl
│ │ ├── MlContext.cpp
│ │ ├── MlContext.dbg.cpp
│ │ ├── MlContext.h
│ │ ├── Reshaper.cpp
│ │ ├── Reshaper.h
│ │ ├── TempBuffers.cpp
│ │ ├── TempBuffers.h
│ │ ├── Tensor.cpp
│ │ ├── Tensor.h
│ │ ├── TensorEx.cpp
│ │ ├── TensorEx.h
│ │ ├── TensorGpuViews.cpp
│ │ ├── TensorGpuViews.h
│ │ ├── TensorShape.cpp
│ │ ├── TensorShape.h
│ │ ├── TensorsArena.cpp
│ │ ├── TensorsArena.h
│ │ ├── mlUtils.cpp
│ │ ├── mlUtils.h
│ │ ├── reshapedMultiply.h
│ │ ├── tensorOpsTests.cpp
│ │ ├── tensorOpsTests.h
│ │ ├── testUtils.cpp
│ │ ├── testUtils.h
│ │ └── testUtilsC.h
│ ├── Readme.txt
│ ├── Resource.rc
│ ├── Utils/
│ │ ├── CpuProfiler.cpp
│ │ ├── CpuProfiler.h
│ │ ├── DelayExecution.cpp
│ │ ├── DelayExecution.h
│ │ ├── GpuProfiler.cpp
│ │ ├── GpuProfiler.h
│ │ ├── GpuProfilerSimple.h
│ │ ├── LZ4/
│ │ │ ├── LICENSE
│ │ │ ├── lz4.c
│ │ │ └── lz4.h
│ │ ├── Logger.cpp
│ │ ├── Logger.h
│ │ ├── MurmurHash3.cpp
│ │ ├── MurmurHash3.h
│ │ ├── ProfileCollection.cpp
│ │ ├── ProfileCollection.h
│ │ ├── ReadStream.h
│ │ ├── Trace/
│ │ │ ├── TraceStructures.cpp
│ │ │ ├── TraceStructures.h
│ │ │ ├── TraceWriter.cpp
│ │ │ ├── TraceWriter.h
│ │ │ ├── tracing.cpp
│ │ │ └── tracing.h
│ │ ├── miscUtils.cpp
│ │ ├── miscUtils.h
│ │ ├── parallelFor.cpp
│ │ └── parallelFor.h
│ ├── Whisper/
│ │ ├── ContextImpl.capture.cpp
│ │ ├── ContextImpl.cpp
│ │ ├── ContextImpl.diarize.cpp
│ │ ├── ContextImpl.h
│ │ ├── ContextImpl.misc.cpp
│ │ ├── DecoderInputBuffers.cpp
│ │ ├── DecoderInputBuffers.h
│ │ ├── DecoderResultBuffer.cpp
│ │ ├── DecoderResultBuffer.h
│ │ ├── KeyValueBuffers.cpp
│ │ ├── KeyValueBuffers.h
│ │ ├── Languages.cpp
│ │ ├── Languages.h
│ │ ├── MelInputTensor.cpp
│ │ ├── MelInputTensor.h
│ │ ├── MelStreamer.cpp
│ │ ├── MelStreamer.h
│ │ ├── ModelBuffers.clone.cpp
│ │ ├── ModelBuffers.cpp
│ │ ├── ModelBuffers.h
│ │ ├── ModelImpl.cpp
│ │ ├── ModelImpl.h
│ │ ├── ModelLoader.h
│ │ ├── Spectrogram.cpp
│ │ ├── Spectrogram.h
│ │ ├── TranscribeResult.h
│ │ ├── Vocabulary.cpp
│ │ ├── Vocabulary.h
│ │ ├── WhisperContext.cpp
│ │ ├── WhisperContext.h
│ │ ├── WhisperModel.cpp
│ │ ├── WhisperModel.h
│ │ ├── audioConstants.h
│ │ ├── iSpectrogram.h
│ │ ├── languageCodez.inl
│ │ ├── languageCodez.tsv
│ │ ├── loaderUtils.h
│ │ ├── melSpectrogram.cpp
│ │ ├── melSpectrogram.h
│ │ ├── sEncodeParams.h
│ │ ├── sModelParams.h
│ │ ├── sTokenData.h
│ │ ├── voiceActivityDetection.cpp
│ │ └── voiceActivityDetection.h
│ ├── Whisper.vcxproj
│ ├── Whisper.vcxproj.filters
│ ├── misc.natvis
│ ├── modelFactory.cpp
│ ├── modelFactory.h
│ ├── resource.h
│ ├── source/
│ │ ├── LICENSE
│ │ ├── Readme.txt
│ │ ├── ggml.c
│ │ ├── ggml.h
│ │ ├── whisper.cpp
│ │ └── whisper.h
│ ├── source.compat/
│ │ ├── Readme.txt
│ │ ├── convertThings.cpp
│ │ ├── convertThings.h
│ │ └── ggmlMsvc.c
│ ├── stdafx.cpp
│ ├── stdafx.h
│ ├── whisper.def
│ └── whisperCom.cpp
├── WhisperCpp.sln
├── WhisperNet/
│ ├── API/
│ │ ├── CaptureDeviceId.cs
│ │ ├── Parameters.cs
│ │ ├── SpecialTokens.cs
│ │ ├── eCaptureStatus.cs
│ │ ├── eGpuModelFlags.cs
│ │ ├── eLanguage.cs
│ │ ├── eLogLevel.cs
│ │ ├── eModelImplementation.cs
│ │ ├── eResultFlags.cs
│ │ ├── eSpeakerChannel.cs
│ │ ├── iAudioBuffer.cs
│ │ ├── iAudioReader.cs
│ │ ├── iMediaFoundation.cs
│ │ ├── iModel.cs
│ │ └── sCaptureParams.cs
│ ├── AssemblyInfo.cs
│ ├── AssemblyTitle.cs
│ ├── Callbacks.cs
│ ├── CaptureCallbacks.cs
│ ├── Context.cs
│ ├── ExtensionMethods.cs
│ ├── Internal/
│ │ ├── NativeLogger.cs
│ │ ├── iContext.cs
│ │ ├── iTranscribeResult.cs
│ │ ├── sCaptureCallbacks.cs
│ │ ├── sCaptureDevice.cs
│ │ ├── sFullParams.cs
│ │ ├── sLoadModelCallbacks.cs
│ │ ├── sLoggerSetup.cs
│ │ ├── sModelSetup.cs
│ │ └── sProgressSink.cs
│ ├── Library.cs
│ ├── Readme.md
│ ├── WhisperNet.csproj
│ └── WhisperNet.nuspec
└── WhisperPS/
├── Commands/
│ ├── ExportBase.cs
│ ├── ExportSubrip.cs
│ ├── ExportText.cs
│ ├── ExportWebVtt.cs
│ ├── FormatSegments.cs
│ ├── ListAdapters.cs
│ ├── LoadModel.cs
│ ├── TranscribeBase.cs
│ └── TranscribeFile.cs
├── Internal/
│ ├── MarshalEx.cs
│ ├── NativeLogger.cs
│ ├── iTranscribeResult.cs
│ ├── sCaptureDevice.cs
│ ├── sFullParams.cs
│ ├── sLoadModelCallbacks.cs
│ ├── sModelSetup.cs
│ └── sProgressSink.cs
├── Library.cs
├── Properties/
│ └── AssemblyTitle.cs
├── Readme.md
├── Types/
│ ├── Model.cs
│ ├── Segment.cs
│ └── Transcription.cs
├── Utils/
│ ├── CommandLogger.cs
│ └── MiscUtils.cs
├── WhisperPS.csproj
├── WhisperPS.psd1
├── app.config
└── packages.config
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
.vs/
ComLightLib/x64/
Whisper/x64/
x64/
Tools/CompressShaders/bin/
Tools/CompressShaders/obj/
Whisper/D3D/shaderData-Debug.inl
Whisper/D3D/shaderData-Release.inl
WhisperNet/bin/
WhisperNet/obj/
Examples/TranscribeCS/bin/
Examples/TranscribeCS/obj/
*.aps
*.json
*.user
Examples/MicrophoneCS/obj/
Examples/MicrophoneCS/bin/
Tools/PerfSummary/bin/
Tools/PerfSummary/obj/
packages/
WhisperPS/obj/
WhisperPS/bin/
Tools/CompressTables/bin/
Tools/CompressTables/obj/
================================================
FILE: ComLightLib/ComLightLib.vcxproj
================================================
Debug
x64
Release
x64
15.0
{52F486E7-830C-45D8-BE47-E76B5AAB2772}
Win32Proj
ComLightLib
10.0
StaticLibrary
true
v143
Unicode
StaticLibrary
false
v143
true
Unicode
true
$(Platform)\$(Configuration)\
false
$(Platform)\$(Configuration)\
NotUsing
Level3
Disabled
true
_DEBUG;_LIB;%(PreprocessorDefinitions)
true
stdcpp20
AdvancedVectorExtensions
Windows
true
NotUsing
Level3
MaxSpeed
true
true
true
NDEBUG;_LIB;%(PreprocessorDefinitions)
true
stdcpp20
AdvancedVectorExtensions
Windows
true
true
true
================================================
FILE: ComLightLib/ComLightLib.vcxproj.filters
================================================
================================================
FILE: ComLightLib/Exception.hpp
================================================
#pragma once
namespace ComLight
{
class Exception : public std::runtime_error
{
// I don't like C++ exceptions too much, but for some cases they are useful.
// You can throw ComLight::Exception from constructor, or from FinalConstruct() method, the library will catch & return the code from the class factory function.
// Unfortunately, for interface methods this doesn't work, the C++ parts of the library can't catch them without very complex trickery like code generation.
// You can still use this class in methods, but you'll need to catch them manually near the API boundary or the app will crash.
// C++ doesn't have an ABI, the framework can't catch C++ exception across the modules.
const HRESULT m_code;
public:
Exception( HRESULT hr ) : runtime_error( "ComLight HRESULT exception" ), m_code( hr ) { }
HRESULT code() const { return m_code; }
};
}
================================================
FILE: ComLightLib/Readme.txt
================================================
Copy-pasted from there:
https://github.com/Const-me/ComLightInterop/tree/master/ComLightLib
With only a few minor changes.
================================================
FILE: ComLightLib/client/CComPtr.hpp
================================================
#pragma once
namespace ComLight
{
// COM smart pointer, very comparable to CComPtr from ATL
template
class CComPtr
{
I* p;
void callAddRef() const
{
if( nullptr == p )
return;
p->AddRef();
}
public:
// Construct with nullptr
CComPtr() : p( nullptr ) { }
// Release the pointer
void release()
{
if( nullptr == p )
return;
p->Release();
p = nullptr;
}
~CComPtr()
{
release();
}
// Attach without AddRef()
void attach( I* raw )
{
release();
p = raw;
}
// Detach without Release(), set this pointer to nullptr
I* detach()
{
I* const result = p;
p = nullptr;
return result;
}
// Detach without Release() and place to the specified address, set this pointer to nullptr
template
void detach( Other** pp )
{
// If the argument points to a non-empty object, release the old instance: would leak memory otherwise.
if( nullptr != *pp )
( *pp )->Release();
( *pp ) = detach();
}
// Set and AddRef()
void assign( I* raw )
{
release();
attach( raw );
callAddRef();
}
void swap( CComPtr& that )
{
std::swap( p, that.p );
}
// Set and AddRef()
CComPtr( I* raw ) : p( raw )
{
callAddRef();
}
// Set and AddRef()
CComPtr( const CComPtr& that ) : CComPtr( that.p ) { }
// Move constructor
CComPtr( CComPtr&& that ) : p( that.p ) { that.p = nullptr; }
// Set and AddRef()
void operator=( I* raw )
{
assign( raw );
}
// Set and AddRef()
void operator=( const CComPtr& that )
{
assign( that.p );
}
// Move assignment operator, destroys the other one
void operator=( CComPtr&& that )
{
attach( that.detach() );
}
operator I*( ) const { return p; }
I* operator -> () const { return p; }
I** operator &() { return &p; }
operator bool() const { return nullptr != p; }
};
}
================================================
FILE: ComLightLib/comLightClient.h
================================================
#pragma once
#include "comLightCommon.h"
#include "client/CComPtr.hpp"
#include "utils/typeTraits.hpp"
namespace ComLight
{
namespace details
{
template
inline constexpr void** castDoublePointerToVoid( T** pp )
{
static_assert( pointersAssignable(), "IID_PPV_ARGS macro should be used with IUnknown interfaces" );
return reinterpret_cast( pp );
}
}
}
#ifdef IID_PPV_ARGS
#undef IID_PPV_ARGS
#endif
#define IID_PPV_ARGS( pp ) decltype( **pp )::iid, ::ComLight::details::castDoublePointerToVoid( pp )
================================================
FILE: ComLightLib/comLightCommon.h
================================================
#pragma once
#include "hresult.h"
#ifdef _MSC_VER
#include
#else
#include "pal/guiddef.h"
using LPCTSTR = const char*;
#endif
#include "unknwn.h"
================================================
FILE: ComLightLib/comLightServer.h
================================================
#pragma once
#include "comLightCommon.h"
#include "client/CComPtr.hpp"
#include "server/ObjectRoot.hpp"
#include "server/interfaceMap.h"
#include "server/Object.hpp"
#include "server/freeThreadedMarshaller.h"
#ifdef _MSC_VER
// On Windows, it's controlled by library.def module definition file. There's __declspec(dllexport), but it adds underscore, I don't like that.
#define DLLEXPORT extern "C"
#else
#define DLLEXPORT extern "C" __attribute__((visibility("default")))
#endif
================================================
FILE: ComLightLib/hresult.h
================================================
#pragma once
#include
#ifdef _MSC_VER
#include
#include
#else
#include "pal/hresult.h"
#endif
#define CHECK( hr ) { const HRESULT __hr = ( hr ); if( FAILED( __hr ) ) return __hr; }
#ifndef _MSC_VER
inline constexpr HRESULT HRESULT_FROM_WIN32( int c )
{
return c < 0 ? c : ( ( 0xFFFF & c ) | 0x80070000 );
}
constexpr HRESULT OLE_E_BLANK = _HRESULT_TYPEDEF_( 0x80040007 );
constexpr HRESULT E_BOUNDS = _HRESULT_TYPEDEF_( 0x8000000BL );
constexpr int ERROR_HANDLE_EOF = 38;
constexpr int ERROR_ALREADY_INITIALIZED = 1247;
#endif
constexpr HRESULT E_EOF = HRESULT_FROM_WIN32( ERROR_HANDLE_EOF );
constexpr HRESULT E_ALREADY_INITIALIZED = HRESULT_FROM_WIN32( ERROR_ALREADY_INITIALIZED );
================================================
FILE: ComLightLib/pal/guiddef.h
================================================
#pragma once
#include
#include
#ifndef GUID_DEFINED
#define GUID_DEFINED
#endif
struct GUID
{
uint32_t Data1;
uint16_t Data2;
uint16_t Data3;
std::array Data4;
constexpr inline bool operator==( const GUID& that ) const
{
return Data1 == that.Data1 && Data2 == that.Data2 && Data3 == that.Data3 && Data4 == that.Data4;
}
};
using REFIID = const GUID&;
================================================
FILE: ComLightLib/pal/hresult.h
================================================
#pragma once
#include
using HRESULT = int32_t;
#define _HRESULT_TYPEDEF_(_sc) ((HRESULT)_sc)
#define SEVERITY_ERROR 1
#define FACILITY_CONTROL 10
inline constexpr HRESULT MAKE_SCODE( uint32_t sev, uint32_t fac, uint32_t code )
{
return (HRESULT)( ( (uint32_t)( sev ) << 31 ) | ( (unsigned long)( fac ) << 16 ) | ( (unsigned long)( code ) ) );
};
// ==== Copy-pasted from coreclr-master\src\pal\inc\rt\palrt.h ====
#define S_OK _HRESULT_TYPEDEF_(0x00000000L)
#define S_FALSE _HRESULT_TYPEDEF_(0x00000001L)
#define E_NOTIMPL _HRESULT_TYPEDEF_(0x80004001L)
#define E_NOINTERFACE _HRESULT_TYPEDEF_(0x80004002L)
#define E_UNEXPECTED _HRESULT_TYPEDEF_(0x8000FFFFL)
#define E_OUTOFMEMORY _HRESULT_TYPEDEF_(0x8007000EL)
#define E_INVALIDARG _HRESULT_TYPEDEF_(0x80070057L)
#define E_POINTER _HRESULT_TYPEDEF_(0x80004003L)
#define E_HANDLE _HRESULT_TYPEDEF_(0x80070006L)
#define E_ABORT _HRESULT_TYPEDEF_(0x80004004L)
#define E_FAIL _HRESULT_TYPEDEF_(0x80004005L)
#define E_ACCESSDENIED _HRESULT_TYPEDEF_(0x80070005L)
#define E_PENDING _HRESULT_TYPEDEF_(0x8000000AL)
#define DISP_E_PARAMNOTFOUND _HRESULT_TYPEDEF_(0x80020004L)
#define DISP_E_TYPEMISMATCH _HRESULT_TYPEDEF_(0x80020005L)
#define DISP_E_BADVARTYPE _HRESULT_TYPEDEF_(0x80020008L)
#define DISP_E_OVERFLOW _HRESULT_TYPEDEF_(0x8002000AL)
#define DISP_E_DIVBYZERO _HRESULT_TYPEDEF_(0x80020012L)
#define CLASS_E_CLASSNOTAVAILABLE _HRESULT_TYPEDEF_(0x80040111L)
#define CLASS_E_NOAGGREGATION _HRESULT_TYPEDEF_(0x80040110L)
#define CO_E_CLASSSTRING _HRESULT_TYPEDEF_(0x800401F3L)
#define MK_E_SYNTAX _HRESULT_TYPEDEF_(0x800401E4L)
#define STG_E_INVALIDFUNCTION _HRESULT_TYPEDEF_(0x80030001L)
#define STG_E_FILENOTFOUND _HRESULT_TYPEDEF_(0x80030002L)
#define STG_E_PATHNOTFOUND _HRESULT_TYPEDEF_(0x80030003L)
#define STG_E_WRITEFAULT _HRESULT_TYPEDEF_(0x8003001DL)
#define STG_E_FILEALREADYEXISTS _HRESULT_TYPEDEF_(0x80030050L)
#define STG_E_ABNORMALAPIEXIT _HRESULT_TYPEDEF_(0x800300FAL)
#define NTE_BAD_UID _HRESULT_TYPEDEF_(0x80090001L)
#define NTE_BAD_HASH _HRESULT_TYPEDEF_(0x80090002L)
#define NTE_BAD_KEY _HRESULT_TYPEDEF_(0x80090003L)
#define NTE_BAD_LEN _HRESULT_TYPEDEF_(0x80090004L)
#define NTE_BAD_DATA _HRESULT_TYPEDEF_(0x80090005L)
#define NTE_BAD_SIGNATURE _HRESULT_TYPEDEF_(0x80090006L)
#define NTE_BAD_VER _HRESULT_TYPEDEF_(0x80090007L)
#define NTE_BAD_ALGID _HRESULT_TYPEDEF_(0x80090008L)
#define NTE_BAD_FLAGS _HRESULT_TYPEDEF_(0x80090009L)
#define NTE_BAD_TYPE _HRESULT_TYPEDEF_(0x8009000AL)
#define NTE_BAD_KEY_STATE _HRESULT_TYPEDEF_(0x8009000BL)
#define NTE_BAD_HASH_STATE _HRESULT_TYPEDEF_(0x8009000CL)
#define NTE_NO_KEY _HRESULT_TYPEDEF_(0x8009000DL)
#define NTE_NO_MEMORY _HRESULT_TYPEDEF_(0x8009000EL)
#define NTE_SIGNATURE_FILE_BAD _HRESULT_TYPEDEF_(0x8009001CL)
#define NTE_FAIL _HRESULT_TYPEDEF_(0x80090020L)
#define CRYPT_E_HASH_VALUE _HRESULT_TYPEDEF_(0x80091007L)
#define TYPE_E_SIZETOOBIG _HRESULT_TYPEDEF_(0x800288C5L)
#define TYPE_E_DUPLICATEID _HRESULT_TYPEDEF_(0x800288C6L)
#define STD_CTL_SCODE(n) MAKE_SCODE(SEVERITY_ERROR, FACILITY_CONTROL, n)
#define CTL_E_OVERFLOW STD_CTL_SCODE(6)
#define CTL_E_OUTOFMEMORY STD_CTL_SCODE(7)
#define CTL_E_DIVISIONBYZERO STD_CTL_SCODE(11)
#define CTL_E_OUTOFSTACKSPACE STD_CTL_SCODE(28)
#define CTL_E_FILENOTFOUND STD_CTL_SCODE(53)
#define CTL_E_DEVICEIOERROR STD_CTL_SCODE(57)
#define CTL_E_PERMISSIONDENIED STD_CTL_SCODE(70)
#define CTL_E_PATHFILEACCESSERROR STD_CTL_SCODE(75)
#define CTL_E_PATHNOTFOUND STD_CTL_SCODE(76)
#define INET_E_CANNOT_CONNECT _HRESULT_TYPEDEF_(0x800C0004L)
#define INET_E_RESOURCE_NOT_FOUND _HRESULT_TYPEDEF_(0x800C0005L)
#define INET_E_OBJECT_NOT_FOUND _HRESULT_TYPEDEF_(0x800C0006L)
#define INET_E_DATA_NOT_AVAILABLE _HRESULT_TYPEDEF_(0x800C0007L)
#define INET_E_DOWNLOAD_FAILURE _HRESULT_TYPEDEF_(0x800C0008L)
#define INET_E_CONNECTION_TIMEOUT _HRESULT_TYPEDEF_(0x800C000BL)
#define INET_E_UNKNOWN_PROTOCOL _HRESULT_TYPEDEF_(0x800C000DL)
#define DBG_PRINTEXCEPTION_C _HRESULT_TYPEDEF_(0x40010006L)
// ==== Done pasting ====
inline constexpr bool SUCCEEDED( HRESULT hr )
{
return hr >= 0;
}
inline constexpr bool FAILED( HRESULT hr )
{
return hr < 0;
}
================================================
FILE: ComLightLib/server/Object.hpp
================================================
#pragma once
#include
#include "../comLightClient.h"
#include "../utils/typeTraits.hpp"
#include "../Exception.hpp"
namespace ComLight
{
namespace details
{
GENERATE_HAS_MEMBER( implQueryInterface );
GENERATE_HAS_MEMBER( implAddRef );
GENERATE_HAS_MEMBER( implRelease );
}
// Outer class of objects, implements IUnknown methods, also the class factory. The type argument must be your class implementing your interfaces, inherited from ObjectRoot
template
class Object : public T
{
public:
Object() = default;
template
Object( Args&& ... args ) : T{ std::forward( args )... } {};
inline virtual ~Object() override { }
// Implement IUnknown methods
HRESULT COMLIGHTCALL QueryInterface( REFIID riid, void** ppvObject ) override
{
static_assert( details::has_member_implQueryInterface::value, "Your object class must inherit from ComLight::ObjectRoot" );
if( nullptr == ppvObject )
return E_POINTER;
if( T::implQueryInterface( riid, ppvObject ) )
return S_OK;
if( T::queryExtraInterfaces( riid, ppvObject ) )
return S_OK;
if( riid == IUnknown::iid() )
{
ComLight::IUnknown* unk = T::getUnknown();
unk->AddRef();
*ppvObject = unk;
return S_OK;
}
return E_NOINTERFACE;
}
uint32_t COMLIGHTCALL AddRef() override
{
static_assert( details::has_member_implAddRef::value, "Your object class must inherit from ComLight::ObjectRoot" );
return T::implAddRef();
}
uint32_t COMLIGHTCALL Release() override
{
static_assert( details::has_member_implRelease::value, "Your object class must inherit from ComLight::ObjectRoot" );
const uint32_t ret = T::implRelease();
if( 0 == ret )
{
T::FinalRelease();
delete this;
}
return ret;
}
// Create a new object on the heap, store in smart pointer
static inline HRESULT create( CComPtr