Skip to content

Commit

Permalink
Feature/com helper (#606)
Browse files Browse the repository at this point in the history
* Added Result definitions to the slang.h

* Removed slang-result.h and added slang-com-helper.h

* Move slang-com-ptr.h to be publically available.

* Add SLANG_IUNKNOWN macros to simplify implementing interfaces.
Use the SLANG_IUNKNOWN macros to in slang.c

* Removed slang-defines.h added outstanding defines to slang.h

* Include slang-com-ptr.h and slang-com-helper.h in archives built with CI.

* Use spaces instead of tabs on appveyor.yml

* Put operator== and != for Guid in global namespace.

* Fix binary windows archive to have all the slang headers.
  • Loading branch information
jsmall-zzz authored Jun 22, 2018
1 parent 4fa0111 commit 4bbd0e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 6 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,18 @@ after_build:
$env:SLANG_DEPLOY_PLATFORM = "win32"
}
$env:SLANG_BINARY_ARCHIVE = "slang-$($env:SLANG_VERSION)-$($env:SLANG_DEPLOY_PLATFORM).zip"
$env:SLANG_SOURCE_ARCHIVE = "slang-$($env:SLANG_VERSION)-source.zip"
7z a "$env:SLANG_BINARY_ARCHIVE" slang.h
7z a "$env:SLANG_BINARY_ARCHIVE" slang-com-helper.h
7z a "$env:SLANG_BINARY_ARCHIVE" slang-com-ptr.h
7z a "$env:SLANG_BINARY_ARCHIVE" bin\*\*\slang.dll
7z a "$env:SLANG_BINARY_ARCHIVE" bin\*\*\slang.lib
7z a "$env:SLANG_BINARY_ARCHIVE" bin\*\*\slang-glslang.dll
7z a "$env:SLANG_BINARY_ARCHIVE" bin\*\*\slangc.exe
7z a "$env:SLANG_BINARY_ARCHIVE" docs\*.md
$env:SLANG_SOURCE_ARCHIVE = "slang-$($env:SLANG_VERSION)-source.zip"
7z a "$env:SLANG_SOURCE_ARCHIVE" slang.h
7z a "$env:SLANG_SOURCE_ARCHIVE" slang-com-helper.h
7z a "$env:SLANG_SOURCE_ARCHIVE" slang-com-ptr.h
Expand Down
11 changes: 7 additions & 4 deletions slang-com-helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ typedef SlangResult Result;
// Alias SlangUUID to Slang::Guid
typedef SlangUUID Guid;

SLANG_FORCE_INLINE bool operator==(const Guid& aIn, const Guid& bIn)
} // namespace Slang

// Operator == and != for Guid/SlangUUID

SLANG_FORCE_INLINE bool operator==(const Slang::Guid& aIn, const Slang::Guid& bIn)
{
using namespace Slang;
// Use the largest type the honors the alignment of Guid
typedef uint32_t CmpType;
union GuidCompare
Expand All @@ -53,12 +58,11 @@ SLANG_FORCE_INLINE bool operator==(const Guid& aIn, const Guid& bIn)
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) | (a[3] ^ b[3])) == 0;
}

SLANG_FORCE_INLINE bool operator!=(const Guid& a, const Guid& b)
SLANG_FORCE_INLINE bool operator!=(const Slang::Guid& a, const Slang::Guid& b)
{
return !(a == b);
}


/* !!!!!!!! Macros to simplify implementing COM interfaces !!!!!!!!!!!!!!!!!!!!!!!!!!!! */

/* Assumes underlying implementation has a member m_refCount that is initialized to 0 and can have ++ and -- operate on it.
Expand Down Expand Up @@ -101,7 +105,6 @@ SLANG_NO_THROW uint32_t SLANG_MCALL release() \
SLANG_IUNKNOWN_ADD_REF \
SLANG_IUNKNOWN_RELEASE

} // namespace Slang
#endif // defined(__cplusplus)

#endif

0 comments on commit 4bbd0e7

Please sign in to comment.