-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(schema): generate schema json, ref #149
- Loading branch information
Showing
9 changed files
with
101 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Copyright (c) Alpaca Core | ||
# SPDX-License-Identifier: MIT | ||
# | ||
set(tgt example-ac-local-gen-dummy-schema) | ||
add_executable(${tgt} | ||
e-gen-dummy-schema.cpp | ||
) | ||
target_link_libraries(${tgt} | ||
ac::schema | ||
aclp-dummy-baselib | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) Alpaca Core | ||
// SPDX-License-Identifier: MIT | ||
// | ||
#include <ac/dummy/DummyLoaderSchema.hpp> | ||
#include <ac/schema/GenerateLoaderSchemaDict.hpp> | ||
#include <iostream> | ||
|
||
int main() { | ||
auto d = ac::local::schema::generateLoaderSchema<acnl::ordered_json, ac::local::schema::DummyLoader>(); | ||
std::cout << d.dump(2) << std::endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) Alpaca Core | ||
// SPDX-License-Identifier: MIT | ||
// | ||
#pragma once | ||
#include "SchemaVisitor.hpp" | ||
#include <astl/tuple_util.hpp> | ||
|
||
namespace ac::local::schema { | ||
|
||
template <typename Dict, typename Schema> | ||
Dict generateLoaderSchema() { | ||
Dict dict; | ||
dict["id"] = Schema::id; | ||
dict["description"] = Schema::description; | ||
Struct_toSchema<typename Schema::Params>(dict["params"]); | ||
|
||
auto& is = dict["instances"]; | ||
astl::tuple::for_each(typename Schema::Instances{}, [&]<typename Instance>(Instance) { | ||
auto& i = is[Instance::id]; | ||
i["description"] = Instance::description; | ||
Struct_toSchema<typename Instance::Params>(i["params"]); | ||
auto& os = i["ops"]; | ||
astl::tuple::for_each(typename Instance::Interfaces{}, [&]<typename Interface>(Interface) { | ||
astl::tuple::for_each(typename Interface::Ops{}, [&]<typename Op>(Op) { | ||
auto& o = os[Op::id]; | ||
o["description"] = Op::description; | ||
Struct_toSchema<typename Op::Params>(o["params"]); | ||
Struct_toSchema<typename Op::Return>(o["return"]); | ||
}); | ||
}); | ||
}); | ||
|
||
return dict; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters