diff options
| author | Yong He <yonghe@outlook.com> | 2020-08-25 21:55:05 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-25 21:55:05 -0700 |
| commit | b8702dfb6d0e41515fa0f9f899d86b7935dfc3fd (patch) | |
| tree | 302e8e2bd8002de583101046bafeee4c16b2d7b7 /source/slang/slang-emit-cpp.cpp | |
| parent | 4804753d4a2ec389cc6ecd759f7ea712848fddf0 (diff) | |
Export witness table and RTTI objects in compiled libraries. (#1514)
* Export witness table objects in compiled code.
- Ensure that witness tables are preceeded with `extern "C"` modifier in the generated C++ code.
- RTTI objects use the mangled name of the type directly, so that can be queried using the type's mangled name directly from the resulting DLL.
- Expose `Linkage::getTypeConformanceWitnessMangledName` to return the mangled name of witness tables to the host.
- Ensure that all witness tables (including those for associated types) have proper mangled name.
* Fix GCC error in Slang generated code.
Diffstat (limited to 'source/slang/slang-emit-cpp.cpp')
| -rw-r--r-- | source/slang/slang-emit-cpp.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/source/slang/slang-emit-cpp.cpp b/source/slang/slang-emit-cpp.cpp index 0c2b4cd93..e7c90f657 100644 --- a/source/slang/slang-emit-cpp.cpp +++ b/source/slang/slang-emit-cpp.cpp @@ -1611,7 +1611,7 @@ void CPPSourceEmitter::emitWitnessTable(IRWitnessTable* witnessTable) _maybeEmitWitnessTableTypeDefinition(interfaceType); // Define a global variable for the witness table. - m_writer->emit("extern "); + m_writer->emit("extern \"C\" "); emitSimpleType(interfaceType); m_writer->emit(" "); m_writer->emit(getName(witnessTable)); @@ -1692,7 +1692,13 @@ void CPPSourceEmitter::emitInterface(IRInterfaceType* interfaceType) void CPPSourceEmitter::emitRTTIObject(IRRTTIObject* rttiObject) { - m_writer->emit("static TypeInfo "); + // Declare the type info object as `extern "C"` first. + m_writer->emit("extern \"C\" TypeInfo "); + m_writer->emit(getName(rttiObject)); + m_writer->emit(";\n"); + + // Now actually define the object. + m_writer->emit("TypeInfo "); m_writer->emit(getName(rttiObject)); m_writer->emit(" = {"); auto typeSizeDecoration = rttiObject->findDecoration<IRRTTITypeSizeDecoration>(); |
