Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[onert-micro] Update flatbuffer and schema header #13847

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions onert-micro/externals/flatbuffers/base.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
/*
* Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved
* Copyright 2017 Google Inc. All rights reserved.
*
* 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.
*/
#ifndef FLATBUFFERS_BASE_H_
#define FLATBUFFERS_BASE_H_

Expand Down
117 changes: 59 additions & 58 deletions onert-micro/externals/flatbuffers/code_generators.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
* Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved
* Copyright 2014 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -23,8 +22,7 @@

#include "flatbuffers/idl.h"

namespace flatbuffers
{
namespace flatbuffers {

// Utility class to assist in generating code through use of text templates.
//
Expand All @@ -39,27 +37,25 @@ namespace flatbuffers
// Output:
// void Foo() { printf("%s", "Foo"); }
// void Bar() { printf("%s", "Bar"); }
class CodeWriter
{
public:
CodeWriter(std::string pad = std::string()) : pad_(pad), cur_ident_lvl_(0), ignore_ident_(false)
{
}
class CodeWriter {
public:
CodeWriter(std::string pad = std::string())
: pad_(pad), cur_ident_lvl_(0), ignore_ident_(false) {}

// Clears the current "written" code.
void Clear()
{
void Clear() {
stream_.str("");
stream_.clear();
}

// Associates a key with a value. All subsequent calls to operator+=, where
// the specified key is contained in {{ and }} delimiters will be replaced by
// the given value.
void SetValue(const std::string &key, const std::string &value) { value_map_[key] = value; }
void SetValue(const std::string &key, const std::string &value) {
value_map_[key] = value;
}

std::string GetValue(const std::string &key) const
{
std::string GetValue(const std::string &key) const {
const auto it = value_map_.find(key);
return it == value_map_.end() ? "" : it->second;
}
Expand All @@ -76,15 +72,13 @@ class CodeWriter
// Increase ident level for writing code
void IncrementIdentLevel() { cur_ident_lvl_++; }
// Decrease ident level for writing code
void DecrementIdentLevel()
{
if (cur_ident_lvl_)
cur_ident_lvl_--;
void DecrementIdentLevel() {
if (cur_ident_lvl_) cur_ident_lvl_--;
}

void SetPadding(const std::string &padding) { pad_ = padding; }

private:
private:
std::map<std::string, std::string> value_map_;
std::stringstream stream_;
std::string pad_;
Expand All @@ -95,34 +89,38 @@ class CodeWriter
void AppendIdent(std::stringstream &stream);
};

class BaseGenerator
{
public:
class BaseGenerator {
public:
virtual bool generate() = 0;

static std::string NamespaceDir(const Parser &parser, const std::string &path,
const Namespace &ns, const bool dasherize = false);
const Namespace &ns,
const bool dasherize = false);

static std::string ToDasherizedCase(const std::string pascal_case);

std::string GeneratedFileName(const std::string &path, const std::string &file_name,
std::string GeneratedFileName(const std::string &path,
const std::string &file_name,
const IDLOptions &options) const;

protected:
BaseGenerator(const Parser &parser, const std::string &path, const std::string &file_name,
std::string qualifying_start, std::string qualifying_separator,
std::string default_extension)
: parser_(parser), path_(path), file_name_(file_name), qualifying_start_(qualifying_start),
qualifying_separator_(qualifying_separator), default_extension_(default_extension)
{
}
protected:
BaseGenerator(const Parser &parser, const std::string &path,
const std::string &file_name, std::string qualifying_start,
std::string qualifying_separator, std::string default_extension)
: parser_(parser),
path_(path),
file_name_(file_name),
qualifying_start_(qualifying_start),
qualifying_separator_(qualifying_separator),
default_extension_(default_extension) {}
virtual ~BaseGenerator() {}

// No copy/assign.
BaseGenerator &operator=(const BaseGenerator &);
BaseGenerator(const BaseGenerator &);

std::string NamespaceDir(const Namespace &ns, const bool dasherize = false) const;
std::string NamespaceDir(const Namespace &ns,
const bool dasherize = false) const;

static const char *FlatBuffersGeneratedWarning();

Expand All @@ -139,7 +137,8 @@ class BaseGenerator
// Ensure that a type is prefixed with its namespace even within
// its own namespace to avoid conflict between generated method
// names and similarly named classes or structs
std::string WrapInNameSpace(const Namespace *ns, const std::string &name) const;
std::string WrapInNameSpace(const Namespace *ns,
const std::string &name) const;

std::string WrapInNameSpace(const Definition &def) const;

Expand All @@ -153,23 +152,22 @@ class BaseGenerator
const std::string default_extension_;
};

struct CommentConfig
{
struct CommentConfig {
const char *first_line;
const char *content_line_prefix;
const char *last_line;
};

extern void GenComment(const std::vector<std::string> &dc, std::string *code_ptr,
const CommentConfig *config, const char *prefix = "");
extern void GenComment(const std::vector<std::string> &dc,
std::string *code_ptr, const CommentConfig *config,
const char *prefix = "");

class FloatConstantGenerator
{
public:
class FloatConstantGenerator {
public:
virtual ~FloatConstantGenerator() {}
std::string GenFloatConstant(const FieldDef &field) const;

private:
private:
virtual std::string Value(double v, const std::string &src) const = 0;
virtual std::string Inf(double v) const = 0;
virtual std::string NaN(double v) const = 0;
Expand All @@ -178,17 +176,19 @@ class FloatConstantGenerator
virtual std::string Inf(float v) const = 0;
virtual std::string NaN(float v) const = 0;

template <typename T> std::string GenFloatConstantImpl(const FieldDef &field) const;
template<typename T>
std::string GenFloatConstantImpl(const FieldDef &field) const;
};

class SimpleFloatConstantGenerator : public FloatConstantGenerator
{
public:
SimpleFloatConstantGenerator(const char *nan_number, const char *pos_inf_number,
class SimpleFloatConstantGenerator : public FloatConstantGenerator {
public:
SimpleFloatConstantGenerator(const char *nan_number,
const char *pos_inf_number,
const char *neg_inf_number);

private:
std::string Value(double v, const std::string &src) const FLATBUFFERS_OVERRIDE;
private:
std::string Value(double v,
const std::string &src) const FLATBUFFERS_OVERRIDE;
std::string Inf(double v) const FLATBUFFERS_OVERRIDE;
std::string NaN(double v) const FLATBUFFERS_OVERRIDE;

Expand All @@ -202,15 +202,16 @@ class SimpleFloatConstantGenerator : public FloatConstantGenerator
};

// C++, C#, Java like generator.
class TypedFloatConstantGenerator : public FloatConstantGenerator
{
public:
TypedFloatConstantGenerator(const char *double_prefix, const char *single_prefix,
const char *nan_number, const char *pos_inf_number,
class TypedFloatConstantGenerator : public FloatConstantGenerator {
public:
TypedFloatConstantGenerator(const char *double_prefix,
const char *single_prefix, const char *nan_number,
const char *pos_inf_number,
const char *neg_inf_number = "");

private:
std::string Value(double v, const std::string &src) const FLATBUFFERS_OVERRIDE;
private:
std::string Value(double v,
const std::string &src) const FLATBUFFERS_OVERRIDE;
std::string Inf(double v) const FLATBUFFERS_OVERRIDE;

std::string NaN(double v) const FLATBUFFERS_OVERRIDE;
Expand All @@ -229,6 +230,6 @@ class TypedFloatConstantGenerator : public FloatConstantGenerator
const std::string neg_inf_number_;
};

} // namespace flatbuffers
} // namespace flatbuffers

#endif // FLATBUFFERS_CODE_GENERATORS_H_
#endif // FLATBUFFERS_CODE_GENERATORS_H_
Loading