diff options
| author | Yong He <yonghe@outlook.com> | 2022-07-25 10:08:28 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-25 10:08:28 -0700 |
| commit | 9566e8af25f87ad034a984db9d847942e454a180 (patch) | |
| tree | 2f295bf2bf60c39fd35b6b634b903d574b4ca99e /source/slang/slang-lower-to-ir.cpp | |
| parent | 70147fc7ba6abe0b669363ed5adfd8d4d9545c3f (diff) | |
Allow `class` to implement COM interface, [DLLExport] (#2338)
* Allow `class` to implement COM interface, [DLLExport]
* Fix [COM] usage in tests and examples with UUIDs.
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-lower-to-ir.cpp')
| -rw-r--r-- | source/slang/slang-lower-to-ir.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index 81201f5f8..66f314d06 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -1153,7 +1153,15 @@ static void addLinkageDecoration( if (auto dllImportModifier = decl->findModifier<DllImportAttribute>()) { auto libraryName = dllImportModifier->modulePath; - builder->addDllImportDecoration(inst, libraryName.getUnownedSlice(), decl->getName()->text.getUnownedSlice()); + auto functionName = dllImportModifier->functionName.getLength() + ? dllImportModifier->functionName.getUnownedSlice() + : decl->getName()->text.getUnownedSlice(); + builder->addDllImportDecoration(inst, libraryName.getUnownedSlice(), functionName); + } + if (decl->findModifier<DllExportAttribute>()) + { + builder->addDllExportDecoration(inst, decl->getName()->text.getUnownedSlice()); + builder->addPublicDecoration(inst); } } @@ -2409,6 +2417,12 @@ ParameterDirection getParameterDirection(VarDeclBase* paramDecl) /// ParameterDirection getThisParamDirection(Decl* parentDecl, ParameterDirection defaultDirection) { + // The `this` parameter for a `class` is always `in`. + if (as<ClassDecl>(parentDecl->parentDecl)) + { + return kParameterDirection_In; + } + // Applications can opt in to a mutable `this` parameter, // by applying the `[mutating]` attribute to their // declaration. @@ -5917,6 +5931,12 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> addLinkageDecoration(context, irWitnessTable, inheritanceDecl, mangledName.getUnownedSlice()); + // If the witness table is for a COM interface, always keep it alive. + if (irWitnessTableBaseType->findDecoration<IRComInterfaceDecoration>()) + { + subBuilder->addPublicDecoration(irWitnessTable); + } + // TODO(JS): // Not clear what to do here around HLSLExportModifier. // In HLSL it only (currently) applies to functions, so perhaps do nothing is reasonable. @@ -6596,7 +6616,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> } if (auto comInterfaceAttr = decl->findModifier<ComInterfaceAttribute>()) { - subBuilder->addComInterfaceDecoration(irInterface); + subBuilder->addComInterfaceDecoration(irInterface, comInterfaceAttr->guid.getUnownedSlice()); } if (auto builtinAttr = decl->findModifier<BuiltinAttribute>()) { |
