6 Star 10 Fork 1.2K

Anton Soldatov/arkcompiler_runtime_core

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
annotation_data_accessor.h 2.91 KB
一键复制 编辑 原始数据 按行查看 历史
胡晓炜 提交于 2022-12-30 16:19 +08:00 . Auto format the protection macros in header files
/**
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* 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 LIBPANDAFILE_ANNOTATION_DATA_ACCESSOR_H
#define LIBPANDAFILE_ANNOTATION_DATA_ACCESSOR_H
#include "file.h"
#include "helpers.h"
#include "value.h"
namespace panda::panda_file {
class AnnotationDataAccessor {
public:
class Elem {
public:
Elem(const File &panda_file, File::EntityId name_id, uint32_t value)
: panda_file_(panda_file), name_id_(name_id), value_(value)
{
}
~Elem() = default;
NO_COPY_SEMANTIC(Elem);
NO_MOVE_SEMANTIC(Elem);
File::EntityId GetNameId() const
{
return name_id_;
}
ScalarValue GetScalarValue() const
{
return ScalarValue(panda_file_, value_);
}
ArrayValue GetArrayValue() const
{
return ArrayValue(panda_file_, File::EntityId(value_));
}
private:
const File &panda_file_;
File::EntityId name_id_;
uint32_t value_;
};
class Tag {
public:
explicit Tag(char item) : item_(item) {}
~Tag() = default;
NO_COPY_SEMANTIC(Tag);
NO_MOVE_SEMANTIC(Tag);
char GetItem() const
{
return item_;
}
private:
char item_;
};
AnnotationDataAccessor(const File &panda_file, File::EntityId annotation_id);
~AnnotationDataAccessor() = default;
NO_COPY_SEMANTIC(AnnotationDataAccessor);
NO_MOVE_SEMANTIC(AnnotationDataAccessor);
File::EntityId GetClassId() const
{
return File::EntityId(class_off_);
}
uint32_t GetCount() const
{
return count_;
}
Elem GetElement(size_t i) const;
Tag GetTag(size_t i) const;
size_t GetSize() const
{
return size_;
}
File::EntityId GetAnnotationId() const
{
return annotation_id_;
}
private:
static constexpr size_t COUNT_SIZE = sizeof(uint16_t);
static constexpr size_t VALUE_SIZE = sizeof(uint32_t);
static constexpr size_t TYPE_TAG_SIZE = sizeof(uint8_t);
const File &panda_file_;
File::EntityId annotation_id_;
uint32_t class_off_;
uint32_t count_;
Span<const uint8_t> elements_sp_ {nullptr, nullptr};
Span<const uint8_t> elements_tags_ {nullptr, nullptr};
size_t size_;
};
} // namespace panda::panda_file
#endif // LIBPANDAFILE_ANNOTATION_DATA_ACCESSOR_H
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/igelhaus/arkcompiler_runtime_core.git
git@gitee.com:igelhaus/arkcompiler_runtime_core.git
igelhaus
arkcompiler_runtime_core
arkcompiler_runtime_core
master

搜索帮助