Skip to content

Commit 8ea705e

Browse files
authored
Upgrade Core and Blaze (#24)
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 7c1f4eb commit 8ea705e

252 files changed

Lines changed: 29318 additions & 925 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ jobs:
120120
- run: >
121121
cmake --install ./build --prefix ./build/dist --config Release --verbose
122122
--component sourcemeta_core_dev
123+
- run: >
124+
cmake --install ./build --prefix ./build/dist --config Release --verbose
125+
--component sourcemeta_blaze
126+
- run: >
127+
cmake --install ./build --prefix ./build/dist --config Release --verbose
128+
--component sourcemeta_blaze_dev
123129
- run: >
124130
cmake --install ./build --prefix ./build/dist --config Release --verbose
125131
--component sourcemeta_codegen

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ if(CODEGEN_INSTALL)
3232
endif()
3333

3434
find_package(Core REQUIRED)
35+
find_package(Blaze REQUIRED)
3536

3637
# Don't force downstream consumers on it
3738
if(PROJECT_IS_TOP_LEVEL)

DEPENDENCIES

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
vendorpull https://github.com/sourcemeta/vendorpull 1dcbac42809cf87cb5b045106b863e17ad84ba02
2-
core https://github.com/sourcemeta/core b6640a840bf149edca223c9129a71d64474e12fc
2+
core https://github.com/sourcemeta/core c43332629d71475f44d212f140effbf0a46c1492
3+
blaze https://github.com/sourcemeta/blaze b97dc7b6dca47917f40ff465efa5e068e16e8534

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ compile: .always
2828
--component sourcemeta_core
2929
$(CMAKE) --install ./build --prefix ./build/dist --config $(PRESET) --verbose \
3030
--component sourcemeta_core_dev
31+
$(CMAKE) --install ./build --prefix ./build/dist --config $(PRESET) --verbose \
32+
--component sourcemeta_blaze
33+
$(CMAKE) --install ./build --prefix ./build/dist --config $(PRESET) --verbose \
34+
--component sourcemeta_blaze_dev
3135
$(CMAKE) --install ./build --prefix ./build/dist --config $(PRESET) --verbose \
3236
--component sourcemeta_codegen
3337
$(CMAKE) --install ./build --prefix ./build/dist --config $(PRESET) --verbose \

cmake/FindBlaze.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
if(NOT Blaze_FOUND)
2+
if(CODEGEN_INSTALL)
3+
set(SOURCEMETA_BLAZE_INSTALL ON CACHE BOOL "enable installation")
4+
else()
5+
set(SOURCEMETA_BLAZE_INSTALL OFF CACHE BOOL "disable installation")
6+
endif()
7+
8+
add_subdirectory("${PROJECT_SOURCE_DIR}/vendor/blaze")
9+
include(Sourcemeta)
10+
set(Blaze_FOUND ON)
11+
endif()

config.cmake.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ if(NOT CODEGEN_COMPONENTS)
99
endif()
1010

1111
include(CMakeFindDependencyMacro)
12-
find_dependency(Core COMPONENTS regex json jsonschema alterschema)
12+
find_dependency(Core COMPONENTS regex json jsonschema)
13+
find_dependency(Blaze COMPONENTS alterschema)
1314

1415
foreach(component ${CODEGEN_COMPONENTS})
1516
if(component STREQUAL "ir")

src/generator/include/sourcemeta/codegen/generator_typescript.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class SOURCEMETA_CODEGEN_GENERATOR_EXPORT TypeScript {
2929
auto operator()(const IRReference &entry) -> void;
3030
auto operator()(const IRTuple &entry) -> void;
3131
auto operator()(const IRUnion &entry) -> void;
32+
auto operator()(const IRIntersection &entry) -> void;
3233

3334
private:
3435
// Exporting symbols that depends on the standard C++ library is considered

src/generator/typescript.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,4 +287,20 @@ auto TypeScript::operator()(const IRUnion &entry) -> void {
287287
this->output << ";\n";
288288
}
289289

290+
auto TypeScript::operator()(const IRIntersection &entry) -> void {
291+
this->output << "export type "
292+
<< mangle(this->prefix, entry.pointer, entry.symbol, this->cache)
293+
<< " =\n";
294+
295+
const char *separator{""};
296+
for (const auto &value : entry.values) {
297+
this->output << separator << " "
298+
<< mangle(this->prefix, value.pointer, value.symbol,
299+
this->cache);
300+
separator = " &\n";
301+
}
302+
303+
this->output << ";\n";
304+
}
305+
290306
} // namespace sourcemeta::codegen

src/ir/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ target_link_libraries(sourcemeta_codegen_ir PUBLIC
1212
target_link_libraries(sourcemeta_codegen_ir PUBLIC
1313
sourcemeta::core::jsonschema)
1414
target_link_libraries(sourcemeta_codegen_ir PRIVATE
15-
sourcemeta::core::alterschema)
15+
sourcemeta::blaze::alterschema)

src/ir/include/sourcemeta/codegen/ir.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ struct IRUnion : IRType {
5656
std::vector<IRType> values;
5757
};
5858

59+
/// @ingroup ir
60+
struct IRIntersection : IRType {
61+
std::vector<IRType> values;
62+
};
63+
5964
/// @ingroup ir
6065
struct IRObjectValue : IRType {
6166
bool required;
@@ -99,8 +104,8 @@ struct IRReference : IRType {
99104

100105
/// @ingroup ir
101106
using IREntity =
102-
std::variant<IRObject, IRScalar, IREnumeration, IRUnion, IRArray, IRTuple,
103-
IRImpossible, IRAny, IRReference>;
107+
std::variant<IRObject, IRScalar, IREnumeration, IRUnion, IRIntersection,
108+
IRArray, IRTuple, IRImpossible, IRAny, IRReference>;
104109

105110
/// @ingroup ir
106111
using IRResult = std::vector<IREntity>;

0 commit comments

Comments
 (0)