Skip to content

Commit 6eac0a2

Browse files
committed
WIP)
1 parent 63ccd87 commit 6eac0a2

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

samples/wamr/generated/sample.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

3-
#ifndef GENERATED_SAMPLE_HPP_HPP
4-
#define GENERATED_SAMPLE_HPP_HPP
3+
#ifndef GENERATED_SAMPLE_HPP
4+
#define GENERATED_SAMPLE_HPP
55

66
#include <cmcpp.hpp>
77

@@ -246,4 +246,4 @@ void void_func();
246246

247247
} // namespace host
248248

249-
#endif // GENERATED_SAMPLE_HPP_HPP
249+
#endif // GENERATED_SAMPLE_HPP

tools/wit-codegen/code_generator.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void CodeGenerator::generateHeader(const std::vector<InterfaceInfo> &interfaces,
2323

2424
// Generate header guard using just the filename (not full path)
2525
std::filesystem::path filepath(filename);
26-
std::string guard = "GENERATED_" + sanitize_identifier(filepath.filename().string()) + "_HPP";
26+
std::string guard = "GENERATED_" + sanitize_identifier(filepath.filename().string());
2727
std::transform(guard.begin(), guard.end(), guard.begin(), ::toupper);
2828

2929
out << "#pragma once\n\n";
@@ -123,9 +123,10 @@ void CodeGenerator::generateHeader(const std::vector<InterfaceInfo> &interfaces,
123123
}
124124
else
125125
{
126-
// Interface not found in registry - generate placeholder comment
127-
out << " // External interface not loaded: " << import << "\n";
128-
out << " // Host must provide implementations for functions from this interface\n";
126+
// Interface not found in registry - this is an error
127+
throw std::runtime_error("External interface not loaded: " + import +
128+
"\nPackage '" + package_spec + "' interface '" + interface_name +
129+
"' was not found in the registry. Make sure to load all dependent packages before generating code.");
129130
}
130131
}
131132
else
@@ -190,9 +191,10 @@ void CodeGenerator::generateHeader(const std::vector<InterfaceInfo> &interfaces,
190191
}
191192
else
192193
{
193-
// Interface not found in registry - generate placeholder comment
194-
out << " // External interface not loaded: " << export_name << "\n";
195-
out << " // Guest must implement functions from this interface\n";
194+
// Interface not found in registry - this is an error
195+
throw std::runtime_error("External interface not loaded: " + export_name +
196+
"\nPackage '" + package_spec + "' interface '" + interface_name +
197+
"' was not found in the registry. Make sure to load all dependent packages before generating code.");
196198
}
197199
}
198200
else

0 commit comments

Comments
 (0)