@@ -844,6 +844,27 @@ extern "C"
844
844
uint8_t data4[8 ];
845
845
};
846
846
847
+ // Place at the start of an interface with the guid.
848
+ // Guid should be specified as SLANG_COM_INTERFACE(0x00000000, 0x0000, 0x0000, { 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 })
849
+ // NOTE: it's the typical guid struct definition, without the surrounding {}
850
+ // It is not necessary to use the multiple parameters (we can wrap in parens), but this is simple.
851
+ #define SLANG_COM_INTERFACE (a, b, c, d0, d1, d2, d3, d4, d5, d6, d7 ) \
852
+ public: \
853
+ SLANG_FORCE_INLINE static const SlangUUID& getTypeGuid () \
854
+ { \
855
+ static const SlangUUID guid = { a, b, c, d0, d1, d2, d3, d4, d5, d6, d7 }; \
856
+ return guid; \
857
+ }
858
+
859
+ // Sometimes it's useful to associate a guid with a class to identify it. This macro can used for this,
860
+ // and the guid extracted via the getTypeGuid() function defined in the type
861
+ #define SLANG_CLASS_GUID (a, b, c, d0, d1, d2, d3, d4, d5, d6, d7 ) \
862
+ SLANG_FORCE_INLINE static const SlangUUID& getTypeGuid () \
863
+ { \
864
+ static const SlangUUID guid = { a, b, c, d0, d1, d2, d3, d4, d5, d6, d7 }; \
865
+ return guid; \
866
+ }
867
+
847
868
/* * Base interface for components exchanged through the API.
848
869
849
870
This interface definition is compatible with the COM `IUnknown`,
@@ -852,7 +873,8 @@ extern "C"
852
873
*/
853
874
struct ISlangUnknown
854
875
{
855
- public:
876
+ SLANG_COM_INTERFACE (0x00000000 , 0x0000 , 0x0000 , { 0xC0 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x46 })
877
+
856
878
virtual SLANG_NO_THROW SlangResult SLANG_MCALL queryInterface (SlangUUID const & uuid, void ** outObject) = 0;
857
879
virtual SLANG_NO_THROW uint32_t SLANG_MCALL addRef () = 0;
858
880
virtual SLANG_NO_THROW uint32_t SLANG_MCALL release () = 0;
@@ -865,19 +887,20 @@ extern "C"
865
887
uint32_t AddRef () { return addRef (); }
866
888
uint32_t Release () { return release (); }
867
889
};
868
- #define SLANG_UUID_ISlangUnknown { 0x00000000 , 0x0000 , 0x0000 , { 0xC0 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x46 } }
890
+ #define SLANG_UUID_ISlangUnknown ISlangUnknown::getTypeGuid ()
869
891
870
892
/* * A "blob" of binary data.
871
893
872
894
This interface definition is compatible with the `ID3DBlob` and `ID3D10Blob` interfaces.
873
895
*/
874
896
struct ISlangBlob : public ISlangUnknown
875
897
{
876
- public:
898
+ SLANG_COM_INTERFACE (0x8BA5FB08 , 0x5195 , 0x40e2 , { 0xAC , 0x58 , 0x0D , 0x98 , 0x9C , 0x3A , 0x01 , 0x02 })
899
+
877
900
virtual SLANG_NO_THROW void const * SLANG_MCALL getBufferPointer () = 0 ;
878
901
virtual SLANG_NO_THROW size_t SLANG_MCALL getBufferSize () = 0 ;
879
902
};
880
- #define SLANG_UUID_ISlangBlob { 0x8BA5FB08 , 0x5195 , 0x40e2 , { 0xAC , 0x58 , 0x0D , 0x98 , 0x9C , 0x3A , 0x01 , 0x02 } }
903
+ #define SLANG_UUID_ISlangBlob ISlangBlob::getTypeGuid ()
881
904
882
905
/* * A (real or virtual) file system.
883
906
@@ -892,7 +915,8 @@ extern "C"
892
915
893
916
struct ISlangFileSystem : public ISlangUnknown
894
917
{
895
- public:
918
+ SLANG_COM_INTERFACE (0x003A09FC , 0x3A4D , 0x4BA0 , { 0xAD , 0x60 , 0x1F , 0xD8 , 0x63 , 0xA9 , 0x15 , 0xAB })
919
+
896
920
/* * Load a file from `path` and return a blob of its contents
897
921
@param path The path to load from, as a null-terminated UTF-8 string.
898
922
@param outBlob A destination pointer to receive the blob of the file contents.
@@ -910,7 +934,7 @@ extern "C"
910
934
char const * path,
911
935
ISlangBlob** outBlob) = 0 ;
912
936
};
913
- #define SLANG_UUID_ISlangFileSystem { 0x003A09FC , 0x3A4D , 0x4BA0 , { 0xAD , 0x60 , 0x1F , 0xD8 , 0x63 , 0xA9 , 0x15 , 0xAB } }
937
+ #define SLANG_UUID_ISlangFileSystem ISlangFileSystem::getTypeGuid ()
914
938
915
939
916
940
typedef void(*SlangFuncPtr)(void );
@@ -920,7 +944,8 @@ extern "C"
920
944
*/
921
945
struct ISlangSharedLibrary : public ISlangUnknown
922
946
{
923
- public:
947
+ SLANG_COM_INTERFACE ( 0x9c9d5bc5 , 0xeb61 , 0x496f ,{ 0x80 , 0xd7 , 0xd1 , 0x47 , 0xc4 , 0xa2 , 0x37 , 0x30 })
948
+
924
949
/* * Get a function by name. If the library is unloaded will only return nullptr.
925
950
@param name The name of the function
926
951
@return The function pointer related to the name or nullptr if not found
@@ -935,11 +960,12 @@ extern "C"
935
960
*/
936
961
virtual SLANG_NO_THROW void * SLANG_MCALL findSymbolAddressByName (char const * name) = 0;
937
962
};
938
- #define SLANG_UUID_ISlangSharedLibrary { 0x9c9d5bc5 , 0xeb61 , 0x496f ,{ 0x80 , 0xd7 , 0xd1 , 0x47 , 0xc4 , 0xa2 , 0x37 , 0x30 } };
963
+ #define SLANG_UUID_ISlangSharedLibrary ISlangSharedLibrary::getTypeGuid ()
939
964
940
965
struct ISlangSharedLibraryLoader: public ISlangUnknown
941
966
{
942
- public:
967
+ SLANG_COM_INTERFACE (0x6264ab2b , 0xa3e8 , 0x4a06 , { 0x97 , 0xf1 , 0x49 , 0xbc , 0x2d , 0x2a , 0xb1 , 0x4d })
968
+
943
969
/* * Load a shared library. In typical usage the library name should *not* contain any platform
944
970
specific elements. For example on windows a dll name should *not* be passed with a '.dll' extension,
945
971
and similarly on linux a shared library should *not* be passed with the 'lib' prefix and '.so' extension
@@ -949,7 +975,7 @@ extern "C"
949
975
const char * path,
950
976
ISlangSharedLibrary** sharedLibraryOut) = 0 ;
951
977
};
952
- #define SLANG_UUID_ISlangSharedLibraryLoader { 0x6264ab2b , 0xa3e8 , 0x4a06 , { 0x97 , 0xf1 , 0x49 , 0xbc , 0x2d , 0x2a , 0xb1 , 0x4d } };
978
+ #define SLANG_UUID_ISlangSharedLibraryLoader ISlangSharedLibraryLoader::getTypeGuid ()
953
979
954
980
/* Type that identifies how a path should be interpreted */
955
981
typedef unsigned int SlangPathType;
@@ -973,7 +999,8 @@ extern "C"
973
999
*/
974
1000
struct ISlangFileSystemExt : public ISlangFileSystem
975
1001
{
976
- public:
1002
+ SLANG_COM_INTERFACE (0x5fb632d2 , 0x979d , 0x4481 , { 0x9f , 0xee , 0x66 , 0x3c , 0x3f , 0x14 , 0x49 , 0xe1 })
1003
+
977
1004
/* * Get a uniqueIdentity which uniquely identifies an object of the file system.
978
1005
979
1006
Given a path, returns a 'uniqueIdentity' which ideally is the same value for the same file on the file system.
@@ -1075,10 +1102,12 @@ extern "C"
1075
1102
void * userData) = 0;
1076
1103
};
1077
1104
1078
- #define SLANG_UUID_ISlangFileSystemExt { 0x5fb632d2 , 0x979d , 0x4481 , { 0x9f , 0xee , 0x66 , 0x3c , 0x3f , 0x14 , 0x49 , 0xe1 } }
1105
+ #define SLANG_UUID_ISlangFileSystemExt ISlangFileSystemExt::getTypeGuid ()
1079
1106
1080
1107
struct ISlangMutableFileSystem : public ISlangFileSystemExt
1081
1108
{
1109
+ SLANG_COM_INTERFACE (0xa058675c , 0x1d65 , 0x452a , { 0x84 , 0x58 , 0xcc , 0xde , 0xd1 , 0x42 , 0x71 , 0x5 })
1110
+
1082
1111
/* * Write the data specified with data and size to the specified path.
1083
1112
1084
1113
@param path The path for data to be saved to
@@ -1111,7 +1140,7 @@ extern "C"
1111
1140
const char * path) = 0 ;
1112
1141
};
1113
1142
1114
- #define SLANG_UUID_ISlangMutableFileSystem { 0xa058675c , 0x1d65 , 0x452a , { 0x84 , 0x58 , 0xcc , 0xde , 0xd1 , 0x42 , 0x71 , 0x5 } }
1143
+ #define SLANG_UUID_ISlangMutableFileSystem ISlangMutableFileSystem::getTypeGuid ()
1115
1144
1116
1145
/* Identifies different types of writer target*/
1117
1146
typedef unsigned int SlangWriterChannel;
@@ -1134,7 +1163,8 @@ extern "C"
1134
1163
*/
1135
1164
struct ISlangWriter : public ISlangUnknown
1136
1165
{
1137
- public:
1166
+ SLANG_COM_INTERFACE (0xec457f0e , 0x9add , 0x4e6b ,{ 0x85 , 0x1c , 0xd7 , 0xfa , 0x71 , 0x6d , 0x15 , 0xfd })
1167
+
1138
1168
/* * Begin an append buffer.
1139
1169
NOTE! Only one append buffer can be active at any time.
1140
1170
@param maxNumChars The maximum of chars that will be appended
@@ -1162,7 +1192,7 @@ extern "C"
1162
1192
virtual SLANG_NO_THROW SlangResult SLANG_MCALL setMode (SlangWriterMode mode) = 0;
1163
1193
};
1164
1194
1165
- #define SLANG_UUID_ISlangWriter { 0xec457f0e , 0x9add , 0x4e6b ,{ 0x85 , 0x1c , 0xd7 , 0xfa , 0x71 , 0x6d , 0x15 , 0xfd } };
1195
+ #define SLANG_UUID_ISlangWriter ISlangWriter::getTypeGuid ()
1166
1196
1167
1197
namespace slang {
1168
1198
struct IGlobalSession ;
@@ -2991,7 +3021,8 @@ namespace slang
2991
3021
*/
2992
3022
struct IGlobalSession : public ISlangUnknown
2993
3023
{
2994
- public:
3024
+ SLANG_COM_INTERFACE (0xc140b5fd , 0xc78 , 0x452e , { 0xba , 0x7c , 0x1a , 0x1e , 0x70 , 0xc7 , 0xf7 , 0x1c })
3025
+
2995
3026
/* * Create a new session for loading and compiling code.
2996
3027
*/
2997
3028
virtual SLANG_NO_THROW SlangResult SLANG_MCALL createSession (
@@ -3164,15 +3195,15 @@ namespace slang
3164
3195
char const * name) = 0;
3165
3196
};
3166
3197
3167
- #define SLANG_UUID_IGlobalSession { 0xc140b5fd , 0xc78 , 0x452e , { 0xba , 0x7c , 0x1a , 0x1e , 0x70 , 0xc7 , 0xf7 , 0x1c } };
3198
+ #define SLANG_UUID_IGlobalSession IGlobalSession::getTypeGuid ()
3168
3199
3169
3200
/* !
3170
3201
@brief A request for one or more compilation actions to be performed.
3171
3202
*/
3172
3203
struct ICompileRequest : public ISlangUnknown
3173
3204
{
3174
- public:
3175
-
3205
+ SLANG_COM_INTERFACE ( 0x96d33993 , 0x317c , 0x4db5 , { 0xaf , 0xd8 , 0x66 , 0x6e , 0xe7 , 0x72 , 0x48 , 0xe2 } )
3206
+
3176
3207
/* * Set the filesystem hook to use for a compile request
3177
3208
3178
3209
The provided `fileSystem` will be used to load any files that
@@ -3716,7 +3747,7 @@ namespace slang
3716
3747
3717
3748
};
3718
3749
3719
- #define SLANG_UUID_ICompileRequest { 0x96d33993 , 0x317c , 0x4db5 , { 0xaf , 0xd8 , 0x66 , 0x6e , 0xe7 , 0x72 , 0x48 , 0xe2 } };
3750
+ #define SLANG_UUID_ICompileRequest ICompileRequest::getTypeGuid ()
3720
3751
3721
3752
/* * Description of a code generation target.
3722
3753
*/
@@ -3816,7 +3847,8 @@ namespace slang
3816
3847
*/
3817
3848
struct ISession : public ISlangUnknown
3818
3849
{
3819
- public:
3850
+ SLANG_COM_INTERFACE ( 0x67618701 , 0xd116 , 0x468f , { 0xab , 0x3b , 0x47 , 0x4b , 0xed , 0xce , 0xe , 0x3d } )
3851
+
3820
3852
/* * Get the global session thas was used to create this session.
3821
3853
*/
3822
3854
virtual SLANG_NO_THROW IGlobalSession* SLANG_MCALL getGlobalSession () = 0;
@@ -3905,7 +3937,7 @@ namespace slang
3905
3937
SlangCompileRequest** outCompileRequest) = 0;
3906
3938
};
3907
3939
3908
- #define SLANG_UUID_ISession { 0x67618701 , 0xd116 , 0x468f , { 0xab , 0x3b , 0x47 , 0x4b , 0xed , 0xce , 0xe , 0x3d } }
3940
+ #define SLANG_UUID_ISession ISession::getTypeGuid ()
3909
3941
3910
3942
/* * A component type is a unit of shader code layout, reflection, and linking.
3911
3943
@@ -3970,6 +4002,8 @@ namespace slang
3970
4002
*/
3971
4003
struct IComponentType : public ISlangUnknown
3972
4004
{
4005
+ SLANG_COM_INTERFACE (0x5bc42be8 , 0x5c50 , 0x4929 , { 0x9e , 0x5e , 0xd1 , 0x5e , 0x7c , 0x24 , 0x1 , 0x5f })
4006
+
3973
4007
/* * Get the runtime session that this component type belongs to.
3974
4008
*/
3975
4009
virtual SLANG_NO_THROW ISession* SLANG_MCALL getSession () = 0 ;
@@ -4073,14 +4107,14 @@ namespace slang
4073
4107
ISlangSharedLibrary** outSharedLibrary,
4074
4108
slang::IBlob** outDiagnostics = 0 ) = 0 ;
4075
4109
};
4076
- #define SLANG_UUID_IComponentType { 0x5bc42be8 , 0x5c50 , 0x4929 , { 0x9e , 0x5e , 0xd1 , 0x5e , 0x7c , 0x24 , 0x1 , 0x5f } };
4110
+ #define SLANG_UUID_IComponentType IComponentType::getTypeGuid ()
4077
4111
4078
4112
struct IEntryPoint : public IComponentType
4079
4113
{
4080
- public:
4114
+ SLANG_COM_INTERFACE ( 0x8f241361 , 0xf5bd , 0x4ca0 , { 0xa3 , 0xac , 0x2 , 0xf7 , 0xfa , 0x24 , 0x2 , 0xb8 })
4081
4115
};
4082
4116
4083
- #define SLANG_UUID_IEntryPoint { 0x8f241361 , 0xf5bd , 0x4ca0 , { 0xa3 , 0xac , 0x2 , 0xf7 , 0xfa , 0x24 , 0x2 , 0xb8 } }
4117
+ #define SLANG_UUID_IEntryPoint IEntryPoint::getTypeGuid ()
4084
4118
4085
4119
/* * A module is the granularity of shader code compilation and loading.
4086
4120
@@ -4097,13 +4131,14 @@ namespace slang
4097
4131
*/
4098
4132
struct IModule : public IComponentType
4099
4133
{
4100
- public:
4134
+ SLANG_COM_INTERFACE (0xc720e64 , 0x8722 , 0x4d31 , { 0x89 , 0x90 , 0x63 , 0x8a , 0x98 , 0xb1 , 0xc2 , 0x79 })
4135
+
4101
4136
virtual SLANG_NO_THROW SlangResult SLANG_MCALL findEntryPointByName (
4102
4137
char const * name,
4103
4138
IEntryPoint** outEntryPoint) = 0 ;
4104
4139
};
4105
4140
4106
- #define SLANG_UUID_IModule { 0xc720e64 , 0x8722 , 0x4d31 , { 0x89 , 0x90 , 0x63 , 0x8a , 0x98 , 0xb1 , 0xc2 , 0x79 } }
4141
+ #define SLANG_UUID_IModule IModule::getTypeGuid ()
4107
4142
4108
4143
/* * Argument used for specialization to types/values.
4109
4144
*/
0 commit comments