-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fable: Fix excessive compilation duration
- Loading branch information
Showing
19 changed files
with
176 additions
and
86 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* Copyright 2023 Robert Bosch GmbH | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
/** | ||
* \file fable/make_schema.hpp | ||
* | ||
* This file provides a facade for the make_schema function which implements | ||
* a short-cut for the compiler which reduces the excessive resource | ||
* consumption of the actual implementation. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
|
||
#include <fable/fable_fwd.hpp> | ||
#include <fable/schema/array.hpp> // for Array<> | ||
#include <fable/schema/boolean.hpp> // for Boolean | ||
#include <fable/schema/confable.hpp> // for FromConfable | ||
#include <fable/schema/const.hpp> // for Const<> | ||
#include <fable/schema/duration.hpp> // for Duration<> | ||
#include <fable/schema/enum.hpp> // for Enum<> | ||
#include <fable/schema/ignore.hpp> // for Ignore | ||
#include <fable/schema/interface.hpp> // for Interface, Box | ||
#include <fable/schema/json.hpp> // for FromJson<> | ||
#include <fable/schema/map.hpp> // for Map<> | ||
#include <fable/schema/number.hpp> // for Number<> | ||
#include <fable/schema/optional.hpp> // for Optional<> | ||
#include <fable/schema/passthru.hpp> // for Passthru | ||
#include <fable/schema/path.hpp> // for Path | ||
#include <fable/schema/string.hpp> // for String | ||
#include <fable/schema/struct.hpp> // for Struct | ||
#include <fable/schema/variant.hpp> // for Variant | ||
#include <fable/schema/vector.hpp> // for Vector<> | ||
|
||
// It is important that this include comes after all the other ones, | ||
// so that it has access to ALL the previous definitions. | ||
#include <fable/schema/xmagic.hpp> // for make_prototype | ||
|
||
namespace fable { | ||
|
||
namespace schema { | ||
|
||
namespace details { | ||
|
||
/** | ||
* Implements the make_schema function for one datatype | ||
*/ | ||
template <typename T> | ||
struct make_schema_wrapper { | ||
static auto make_schema(T* ptr, std::string desc) { | ||
return ::fable::schema::make_schema_impl(ptr, desc); | ||
} | ||
}; | ||
|
||
} // namespace details | ||
|
||
/** | ||
* Returns the schema for a given datum and its description | ||
* | ||
* \param Ptr Pointer to the datum | ||
* \param desc Textual description of the datum | ||
* \return Schema for the datum | ||
*/ | ||
template <typename T> | ||
auto make_schema(T* ptr, std::string desc) { | ||
return details::make_schema_wrapper<T>::make_schema(ptr, desc); | ||
} | ||
|
||
/** | ||
* Returns the schema for a given datum and its description | ||
* | ||
* \param Ptr Pointer to the datum | ||
* \param proto Prototype of the data-value | ||
* \param desc Textual description of the datum | ||
* \return Schema for the datum | ||
* \note Those types which have a prototype, namely string & path | ||
* do not matter for the compile-time reduction | ||
*/ | ||
template <typename T, typename T2> | ||
auto make_schema(T* ptr, T2 proto, std::string desc) { | ||
return ::fable::schema::make_schema_impl(ptr, proto, desc); | ||
} | ||
|
||
} // namespace schema | ||
} // namespace fable |
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
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
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
Oops, something went wrong.