[libabckit] add cpp api to abckit_status

Issue: IB557P

Change-Id: Ibafef481adba13071205802c49d51045c5ac509d

Change-Id: Ibfcc1136ec5f759d6313dfd68019671490acdc33
Signed-off-by: ermolaevavarvara <ermolaeva.varvara@huawei-partners.com>
This commit is contained in:
ermolaevavarvara 2024-11-12 18:49:05 +03:00
parent 7646c9c8f2
commit 82450d02cd
40 changed files with 2047 additions and 139 deletions

View File

@ -829,7 +829,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.
INPUT = "$(ABCKIT_PROJECT_ROOT)/include/c/"
INPUT = "$(ABCKIT_PROJECT_ROOT)/include/"
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses

View File

@ -451,16 +451,6 @@ struct AbckitGraphApi {
*/
bool (*bbCheckDominance)(AbckitBasicBlock *basicBlock, AbckitBasicBlock *dominator);
/**
* @brief Enumerates basic blocks successing to the given `basicBlock`, invoking callback `cb` for each basic block.
* @return None.
* @param [ in ] basicBlock - Basic block to be inspected.
* @param [ in, out ] data - Pointer to the user-defined data that will be passed to the callback `cb` each time
* it is invoked.
* @param [ in ] cb - Callback that will be invoked.
* @note Set `ABCKIT_STATUS_BAD_ARGUMENT` error if `basicBlock` is NULL.
* @note Set `ABCKIT_STATUS_BAD_ARGUMENT` error if `cb` is NULL.
*/
/**
* @brief Enumerates basic blocks dominating to the given `basicBlock`, invoking callback `cb` for each basic block.
* @return None.

View File

@ -20,25 +20,76 @@
namespace abckit::arkts {
/**
* @brief Annotation
*/
class Annotation : public core::Annotation {
// To access private constructor.
// We restrict constructors in order to prevent C/C++ API mix-up by user.
/// @brief to access private constructor
friend class arkts::Class;
/// @brief to access private constructor
friend class arkts::Function;
public:
/**
* @brief Construct a new Annotation object
* @param other
*/
Annotation(const Annotation &other) = default;
/**
* @brief Constructor
* @param other
* @return Annotation&
*/
Annotation &operator=(const Annotation &other) = default;
/**
* @brief Construct a new Annotation object
* @param other
*/
Annotation(Annotation &&other) = default;
/**
* @brief Constructor
* @param other
* @return Annotation&
*/
Annotation &operator=(Annotation &&other) = default;
// CC-OFFNXT(G.FMT.02) project code style
/**
* @brief Construct a new Annotation object
* @param coreOther
*/
explicit Annotation(const core::Annotation &coreOther) : core::Annotation(coreOther) {};
/**
* @brief Destroy the Annotation object
*/
~Annotation() override = default;
/**
* @brief Add element
* @param val
* @param name
* @return arkts::Annotation&
*/
arkts::Annotation &AddElement(const abckit::Value &val, const std::string &name);
/**
* @brief add and get element
* @param val
* @param name
* @return arkts::AnnotationElement
*/
arkts::AnnotationElement AddAndGetElement(const abckit::Value &val, const std::string_view name);
/**
* @brief add and get element impl
* @param params
* @return AbckitCoreAnnotationElement*
*/
AbckitCoreAnnotationElement *AddAndGetElementImpl(AbckitArktsAnnotationElementCreateParams *params);
// Other API.

View File

@ -20,24 +20,61 @@
namespace abckit::arkts {
/**
* @brief AnnotationElement
*/
class AnnotationElement : public core::AnnotationElement {
// To access private constructor.
// We restrict constructors in order to prevent C/C++ API mix-up by user.
/// @brief to access private constructor
friend class arkts::Class;
/// @brief to access private constructor
friend class arkts::Function;
/// @brief to access private constructor
friend class arkts::Annotation;
public:
/**
* @brief Construct a new Annotation Element object
* @param other
*/
AnnotationElement(const AnnotationElement &other) = default;
/**
* @brief Constructor
* @param other
* @return AnnotationElement&
*/
AnnotationElement &operator=(const AnnotationElement &other) = default;
/**
* @brief Construct a new Annotation Element object
* @param other
*/
AnnotationElement(AnnotationElement &&other) = default;
/**
* @brief Constructor
* @param other
* @return AnnotationElement&
*/
AnnotationElement &operator=(AnnotationElement &&other) = default;
// CC-OFFNXT(G.FMT.02) project code style
/**
* @brief Construct a new Annotation Element object
* @param coreOther
*/
explicit AnnotationElement(const core::AnnotationElement &coreOther) : core::AnnotationElement(coreOther) {};
/**
* @brief Destroy the Annotation Element object
*/
~AnnotationElement() override = default;
/**
* @brief Get the Name object
* @return std::string_view
*/
std::string_view GetName() const;
// Other API.

View File

@ -20,21 +20,53 @@
namespace abckit::arkts {
/**
* @brief AnnotationInterface
*/
class AnnotationInterface : public core::AnnotationInterface {
// To access private constructor.
// We restrict constructors in order to prevent C/C++ API mix-up by user.
/// @brief to access private constructor
friend class arkts::Class;
/// @brief to access private constructor
friend class arkts::Function;
public:
/**
* @brief Construct a new Annotation Interface object
* @param other
*/
AnnotationInterface(const AnnotationInterface &other) = default;
/**
* @brief Constructor
* @param other
* @return AnnotationInterface&
*/
AnnotationInterface &operator=(const AnnotationInterface &other) = default;
/**
* @brief Construct a new Annotation Interface object
* @param other
*/
AnnotationInterface(AnnotationInterface &&other) = default;
/**
* @brief Constructor
* @param other
* @return AnnotationInterface&
*/
AnnotationInterface &operator=(AnnotationInterface &&other) = default;
// CC-OFFNXT(G.FMT.02) project code style
/**
* @brief Construct a new Annotation Interface object
* @param coreOther
*/
explicit AnnotationInterface(const core::AnnotationInterface &coreOther) : core::AnnotationInterface(coreOther) {};
/**
* @brief Destroy the Annotation Interface object
*/
~AnnotationInterface() override = default;
// Other API.
// ...

View File

@ -20,22 +20,56 @@
namespace abckit::arkts {
/**
* @brief AnnotationInterfaceField
*/
class AnnotationInterfaceField : public core::AnnotationInterfaceField {
// To access private constructor.
// We restrict constructors in order to prevent C/C++ API mix-up by user.
/// @brief to access private constructor
friend class arkts::Annotation;
/// @brief to access private constructor
friend class arkts::AnnotationInterface;
public:
/**
* @brief Construct a new Annotation Interface Field object
*
* @param other
*/
AnnotationInterfaceField(const AnnotationInterfaceField &other) = default;
/**
* @brief Constructor
* @param other
* @return AnnotationInterfaceField&
*/
AnnotationInterfaceField &operator=(const AnnotationInterfaceField &other) = default;
/**
* @brief Construct a new Annotation Interface Field object
* @param other
*/
AnnotationInterfaceField(AnnotationInterfaceField &&other) = default;
/**
* @brief Constructor
* @param other
* @return AnnotationInterfaceField&
*/
AnnotationInterfaceField &operator=(AnnotationInterfaceField &&other) = default;
// CC-OFFNXT(G.FMT.02) project code style
/**
* @brief Construct a new Annotation Interface Field object
* @param coreOther
*/
explicit AnnotationInterfaceField(const core::AnnotationInterfaceField &coreOther)
: core::AnnotationInterfaceField(coreOther) {};
/**
* @brief Destroy the Annotation Interface Field object
*/
~AnnotationInterfaceField() override = default;
// Other API.
// ...

View File

@ -20,17 +20,47 @@
namespace abckit::arkts {
/**
* @brief Class
*/
class Class final : public core::Class {
// To access private constructor.
// We restrict constructors in order to prevent C/C++ API mix-up by user.
/// @brief to access private constructor
friend class Module;
/// @brief to access private constructor
friend class Namespace;
public:
/**
* @brief Construct a new Class object
* @param other
*/
Class(const Class &other) = default;
/**
* @brief Constructor
* @param other
* @return Class&
*/
Class &operator=(const Class &other) = default;
/**
* @brief Construct a new Class object
* @param other
*/
Class(Class &&other) = default;
/**
* @brief Constructor
* @param other
* @return Class&
*/
Class &operator=(Class &&other) = default;
/**
* @brief Destroy the Class object
*/
~Class() override = default;
// Other API.
// ...

View File

@ -20,17 +20,46 @@
namespace abckit::arkts {
/**
* @brief ExportDescriptor
*/
class ExportDescriptor final : public core::ExportDescriptor {
// To access private constructor.
// We restrict constructors in order to prevent C/C++ API mix-up by user.
/// @brief to access private constructor
friend class core::Module;
/// @brief to access private constructor
friend class arkts::Module;
public:
/**
* @brief Construct a new Export Descriptor object
* @param other
*/
ExportDescriptor(const ExportDescriptor &other) = default;
/**
* @brief Constructor
* @param other
* @return ExportDescriptor&
*/
ExportDescriptor &operator=(const ExportDescriptor &other) = default;
/**
* @brief Construct a new Export Descriptor object
* @param other
*/
ExportDescriptor(ExportDescriptor &&other) = default;
/**
* @brief Constructor
* @param other
* @return ExportDescriptor&
*/
ExportDescriptor &operator=(ExportDescriptor &&other) = default;
/**
* @brief Destroy the Export Descriptor object
*/
~ExportDescriptor() override = default;
// Other API.
// ...

View File

@ -20,16 +20,44 @@
namespace abckit::arkts {
/**
* @brief Field
*/
class Field final : public core::Field {
// To access private constructor.
// We restrict constructors in order to prevent C/C++ API mix-up by user.
/// @brief to access private constructor
friend class abckit::core::Field;
public:
/**
* @brief Construct a new Field object
* @param other
*/
Field(const Field &other) = default;
/**
* @brief Constructor
* @param other
* @return Field&
*/
Field &operator=(const Field &other) = default;
/**
* @brief Construct a new Field object
* @param other
*/
Field(Field &&other) = default;
/**
* @brief Constructor
* @param other
* @return Field&
*/
Field &operator=(Field &&other) = default;
/**
* @brief Destroy the Field object
*/
~Field() override = default;
// Other API.
// ...

View File

@ -20,22 +20,58 @@
namespace abckit::arkts {
/**
* @brief Function
*/
class Function final : public core::Function {
// To access private constructor.
// We restrict constructors in order to prevent C/C++ API mix-up by user.
/// @brief to access private constructor
friend class Class;
public:
/**
* @brief Construct a new Function object
* @param other
*/
Function(const Function &other) = default;
/**
* @brief Constructor
* @param other
* @return Function&
*/
Function &operator=(const Function &other) = default;
/**
* @brief Construct a new Function object
* @param other
*/
Function(Function &&other) = default;
/**
* @brief Constructor
* @param other
* @return Function&
*/
Function &operator=(Function &&other) = default;
// CC-OFFNXT(G.FMT.02) project code style
/**
* @brief Construct a new Function object
* @param coreOther
*/
explicit Function(const core::Function &coreOther) : core::Function(coreOther) {};
/**
* @brief Destroy the Function object
*/
~Function() override = default;
/**
* @brief Add annotation
* @param iface
* @return arkts::Function&
*/
arkts::Function &AddAnnotation(const arkts::AnnotationInterface &iface);
// Other API.

View File

@ -20,16 +20,44 @@
namespace abckit::arkts {
/**
* @brief ImportDescriptor
*/
class ImportDescriptor final : public core::ImportDescriptor {
// To access private constructor.
// We restrict constructors in order to prevent C/C++ API mix-up by user.
/// @brief to access private constructor
friend class abckit::File;
public:
/**
* @brief Construct a new Import Descriptor object
* @param other
*/
ImportDescriptor(const ImportDescriptor &other) = default;
/**
* @brief Constructor
* @param other
* @return ImportDescriptor&
*/
ImportDescriptor &operator=(const ImportDescriptor &other) = default;
/**
* @brief Construct a new Import Descriptor object
* @param other
*/
ImportDescriptor(ImportDescriptor &&other) = default;
/**
* @brief Constructor
* @param other
* @return ImportDescriptor&
*/
ImportDescriptor &operator=(ImportDescriptor &&other) = default;
/**
* @brief Destroy the Import Descriptor object
*/
~ImportDescriptor() override = default;
// Other API.
// ...

View File

@ -20,16 +20,45 @@
namespace abckit::arkts {
/**
* @brief Module
*/
class Module final : public core::Module {
// To access private constructor.
// We restrict constructors in order to prevent C/C++ API mix-up by user.
/// @brief to access private constructor
friend class abckit::File;
public:
/**
* @brief Construct a new Module object
* @param other
*/
Module(const Module &other) = default;
/**
* @brief Constructor
* @param other
* @return Module&
*/
Module &operator=(const Module &other) = default;
/**
* @brief Construct a new Module object
* @param other
*/
Module(Module &&other) = default;
/**
* @brief Constructor
* @param other
* @return Module&
*/
Module &operator=(Module &&other) = default;
/**
* @brief Destroy the Module object
*/
~Module() override = default;
// Other API.
// ...

View File

@ -20,16 +20,42 @@
namespace abckit::arkts {
/**
* @brief Namespace
*/
class Namespace final : public core::Namespace {
// To access private constructor.
// We restrict constructors in order to prevent C/C++ API mix-up by user.
/// @brief to access private constructor
friend class Module;
public:
/**
* @brief Constructor
* @param other
*/
Namespace(const Namespace &other) = default;
/**
* @brief Consructor
* @param other
* @return Namespace&
*/
Namespace &operator=(const Namespace &other) = default;
/**
* @brief Construct a new Namespace object
* @param other
*/
Namespace(Namespace &&other) = default;
/**
* @brief Constructor
* @param other
* @return Namespace&
*/
Namespace &operator=(Namespace &&other) = default;
/**
* @brief Destroy the Namespace object
*/
~Namespace() override = default;
// Other API's.

View File

@ -24,46 +24,117 @@ namespace abckit {
// Interface to provide global API-related features,
// a base for every API class defined
/**
* @brief Entity
*/
class Entity {
protected:
public:
/**
* @brief Constructor
* @param other
*/
Entity(const Entity &other) = default;
/**
* @brief Constructor
* @param other
* @return Entity
*/
Entity &operator=(const Entity &other) = default;
/**
* @brief Constructor
* @param other
*/
Entity(Entity &&other) = default;
/**
* @brief Constructor
* @param other
* @return Entity
*/
Entity &operator=(Entity &&other) = default;
Entity() = default;
virtual ~Entity() = default;
/**
* @brief Get api config
* @return ApiConfig
*/
virtual const ApiConfig *GetApiConfig() const = 0;
};
// View - value semantics
/**
* @brief View
*/
template <typename T>
class View : public Entity {
public:
/**
* Operator ==
* @param rhs
* @return bool
*/
bool operator==(const View<T> &rhs)
{
return GetView() == rhs.GetView();
}
protected:
/**
* Constructor
* @param ...a
*/
template <typename... Args>
explicit View(Args &&...a) : view_(std::forward<Args>(a)...)
{
}
// Can move and copy views
/**
* @brief Constructor
* @param other
*/
View(const View &other) = default;
/**
* @brief Constructor
* @param other
* @return View
*/
View &operator=(const View &other) = default;
/**
* @brief Constructor
* @param other
*/
View(View &&other) = default;
/**
* @brief Constructor
* @param other
* @return View
*/
View &operator=(View &&other) = default;
protected:
~View() override = default;
/**
* Get view
* @return T
*/
T GetView() const
{
return view_;
}
/**
* Set view
* @param newView
*/
void SetView(T newView)
{
view_ = newView;
@ -74,31 +145,63 @@ private:
};
// Resource - ptr semantics
/**
* @brief Resource
*/
template <typename T>
class Resource : public Entity {
public:
// No copy for resources
/**
* @brief Deleted constructor
* @param other
*/
Resource(Resource &other) = delete;
/**
* @brief Deleted constructor
* @return Resource&
* @param other
*/
Resource &operator=(Resource &other) = delete;
protected:
/**
* @brief Constructor
* @param d
* @param ...a
*/
template <typename... Args>
explicit Resource(std::unique_ptr<IResourceDeleter> d, Args &&...a)
: deleter_(std::move(d)), resource_(std::forward<Args>(a)...)
{
}
/**
* @brief Constructor
* @param ...a
*/
template <typename... Args>
explicit Resource(Args &&...a) : resource_(std::forward<Args>(a)...)
{
}
// Resources are movable
/**
* @brief Constructor
* @param other
*/
Resource(Resource &&other)
{
released_ = false;
resource_ = other.ReleaseResource();
};
/**
* @brief
* @param other
* @return Resource&
*/
Resource &operator=(Resource &&other)
{
released_ = false;
@ -106,23 +209,39 @@ protected:
return *this;
};
/**
* @brief Release resource
* @return `T`
*/
T ReleaseResource()
{
released_ = true;
return resource_;
}
/**
* @brief Get resource
* @return `T`
*/
T GetResource() const
{
return resource_;
}
/**
* @brief Destructor
*/
~Resource() override
{
if (!released_) {
deleter_->DeleteResource();
}
};
/**
* @brief Set deleter
* @param deleter
*/
void SetDeleter(std::unique_ptr<IResourceDeleter> deleter)
{
deleter_ = std::move(deleter);

View File

@ -25,24 +25,90 @@
namespace abckit {
/**
* @brief BasicBlock
*/
class BasicBlock final : public View<AbckitBasicBlock *> {
// To access private constructor.
// We restrict constructors in order to prevent C/C++ API mix-up by user.
/// @brief to access private constructor
friend class Graph;
public:
/**
* @brief Constructor
* @param other
*/
BasicBlock(const BasicBlock &other) = default;
/**
* @brief Constructor
* @param other
* @return BasicBlock&
*/
BasicBlock &operator=(const BasicBlock &other) = default;
/**
* @brief Constructor
* @param other
*/
BasicBlock(BasicBlock &&other) = default;
/**
* @brief Constructor
* @param other
* @return BasicBlock&
*/
BasicBlock &operator=(BasicBlock &&other) = default;
/**
* @brief Destructor
*/
~BasicBlock() override = default;
/**
* @brief Get the Succ Count object
* @return uint64_t
*/
uint64_t GetSuccCount() const;
/**
* @brief Get the Succ By Idx object
* @param idx
* @return BasicBlock
*/
BasicBlock GetSuccByIdx(int idx) const;
/**
* @brief Get the Succs object
* @return std::vector<BasicBlock>
*/
std::vector<BasicBlock> GetSuccs() const;
/**
* @brief
* @param inst
* @return BasicBlock&
*/
BasicBlock &AddInstFront(const Instruction &inst);
/**
* @brief
* @param inst
* @return BasicBlock&
*/
BasicBlock &AddInstBack(const Instruction &inst);
/**
* @brief Get the Instructions object
* @return std::vector<Instruction>
*/
std::vector<Instruction> GetInstructions() const;
/**
* @brief Get the First Inst object
*
* @return Instruction
*/
Instruction GetFirstInst() const;
protected:

View File

@ -69,6 +69,9 @@ class ExportDescriptor;
// Class containing pointers to underlying C API's,
// hides C implementation from C++ API user
/**
* @brief ApiConfig
*/
class ApiConfig final {
// Befrend with all core entities so they have an access to config
friend DynamicIsa;
@ -82,40 +85,95 @@ class ApiConfig final {
friend Literal;
friend LiteralArray;
/// \relates abckit::core::Module
friend core::Module;
/// \relates abckit::core::Namespace
friend core::Namespace;
/// \relates abckit::core::Class
friend core::Class;
/// \relates abckit::core::Function
friend core::Function;
/// \relates abckit::core::Field
friend core::Field;
/// \relates abckit::core::Annotation
friend core::Annotation;
/// \relates abckit::core::AnnotationInterface
friend core::AnnotationInterface;
/// \relates abckit::core::AnnotationElement
friend core::AnnotationElement;
/// \relates abckit::core::AnnotationInterfaceField
friend core::AnnotationInterfaceField;
/// \relates abckit::core::ImportDescriptor
friend core::ImportDescriptor;
/// \relates abckit::core::ExportDescriptor
friend core::ExportDescriptor;
/// \relates abckit::arkts::Module
friend arkts::Module;
/// \relates abckit::arkts::Namespace
friend arkts::Namespace;
/// \relates abckit::arkts::Class
friend arkts::Class;
/// \relates abckit::arkts::Function
friend arkts::Function;
/// \relates abckit::arkts::Field
friend arkts::Field;
/// \relates abckit::arkts::Annotation
friend arkts::Annotation;
/// \relates abckit::arkts::AnnotationInterface
friend arkts::AnnotationInterface;
/// \relates abckit::arkts::AnnotationElement
friend arkts::AnnotationElement;
/// \relates abckit::arkts::AnnotationInterfaceField
friend arkts::AnnotationInterfaceField;
/// \relates abckit::arkts::ImportDescriptor
friend arkts::ImportDescriptor;
/// \relates abckit::arkts::ExportDescriptor
friend arkts::ExportDescriptor;
/**
* Check error
* @param conf
*/
friend void CheckError(const ApiConfig *conf);
public:
/**
* @brief Deleted constructor
* @param other
*/
ApiConfig(const ApiConfig &other) = delete;
/**
* @brief Deleted constructor
* @param other
* @return ApiConfig
*/
ApiConfig &operator=(const ApiConfig &other) = delete;
/**
* @brief Deleted constructor
* @param other
*/
ApiConfig(ApiConfig &&other) = delete;
/**
* @brief Deleted constructor
* @param other
* @return ApiConfig
*/
ApiConfig &operator=(ApiConfig &&other) = delete;
/**
* @brief Destructor
*/
~ApiConfig() = default;
protected:
/**
* @brief Constructor
* @param eh - unique ptr to IErrorHandler
*/
explicit ApiConfig(std::unique_ptr<IErrorHandler> eh)
: cApi_(AbckitGetApiImpl(ABCKIT_VERSION_RELEASE_1_0_0)),
cIapi_(AbckitGetInspectApiImpl(ABCKIT_VERSION_RELEASE_1_0_0)),

View File

@ -21,22 +21,58 @@
namespace abckit::core {
/**
* @brief Annotation
*/
class Annotation : public View<AbckitCoreAnnotation *> {
/// @brief core::Function
friend class core::Function;
/// @brief arkts::Function
friend class arkts::Function;
/// @brief core::Class
friend class core::Class;
/// @brief arkts::Class
friend class arkts::Class;
public:
/**
* @brief Construct a new Annotation object
* @param other
*/
Annotation(const Annotation &other) = default;
/**
* @brief Constructor
* @param other
* @return Annotation&
*/
Annotation &operator=(const Annotation &other) = default;
/**
* @brief Construct a new Annotation object
* @param other
*/
Annotation(Annotation &&other) = default;
/**
* @brief Constructor
* @param other
* @return Annotation&
*/
Annotation &operator=(Annotation &&other) = default;
/**
* @brief Destroy the Annotation object
*/
~Annotation() override = default;
// Core API's.
// ...
/**
* @brief Get the Interface object
* @return core::AnnotationInterface
*/
core::AnnotationInterface GetInterface()
{
AnnotationInterface iface(GetApiConfig()->cIapi_->annotationGetInterface(GetView()), GetApiConfig());
@ -49,6 +85,10 @@ private:
const ApiConfig *conf_;
protected:
/**
* @brief Get the Api Config object
* @return const ApiConfig*
*/
const ApiConfig *GetApiConfig() const override
{
return conf_;

View File

@ -22,32 +22,72 @@
namespace abckit::core {
/**
* @brief AnnotationElement
*/
class AnnotationElement : public View<AbckitCoreAnnotationElement *> {
/// @brief core::Annotation
friend class core::Annotation;
/// @brief arkts::Annotation
friend class arkts::Annotation;
/// @brief core::Module
friend class core::Module;
/// @brief arkts::Module
friend class arkts::Module;
public:
/**
* @brief Constructor
* @param other
*/
AnnotationElement(const AnnotationElement &other) = default;
/**
* @brief Constructor
* @param other
* @return this
*/
AnnotationElement &operator=(const AnnotationElement &other) = default;
/**
* @brief Destructor
*/
~AnnotationElement() override = default;
// Core API's.
// ...
private:
/**
* Constructor
* @param conf
* @param anne
*/
AnnotationElement(AbckitCoreAnnotationElement *anne, const ApiConfig *conf) : View(anne), conf_(conf) {};
const ApiConfig *conf_;
protected:
/**
* @brief Constructor
* @param other
*/
AnnotationElement(AnnotationElement &&other) = default;
/**
* @brief Constructor
* @param other
* @return this
*/
AnnotationElement &operator=(AnnotationElement &&other) = default;
/**
* @brief Get the Api Config object
* @return const ApiConfig*
*/
const ApiConfig *GetApiConfig() const override
{
return conf_;
}
private:
AnnotationElement(AbckitCoreAnnotationElement *anne, const ApiConfig *conf) : View(anne), conf_(conf) {};
const ApiConfig *conf_;
};
} // namespace abckit::core

View File

@ -24,21 +24,60 @@
namespace abckit::core {
/**
* @brief AnnotationInterface
*/
class AnnotationInterface : public View<AbckitCoreAnnotationInterface *> {
/// @brief core::Annotation
friend class core::Annotation;
/// @brief core::Module
friend class core::Module;
public:
/**
* @brief Construct a new Annotation Interface object
* @param other
*/
AnnotationInterface(const AnnotationInterface &other) = default;
/**
* @brief Constructor
* @param other
* @return AnnotationInterface&
*/
AnnotationInterface &operator=(const AnnotationInterface &other) = default;
/**
* @brief Construct a new Annotation Interface object
* @param other
*/
AnnotationInterface(AnnotationInterface &&other) = default;
/**
* @brief Constructor
* @param other
* @return AnnotationInterface&
*/
AnnotationInterface &operator=(AnnotationInterface &&other) = default;
/**
* @brief Destroy the Annotation Interface object
*/
~AnnotationInterface() override = default;
// Core API's.
// ...
/**
* @brief Get the Name object
* @return std::string_view
*/
std::string_view GetName();
/**
* @brief Get the Fields object
* @return std::vector<AnnotationInterfaceField>
*/
std::vector<AnnotationInterfaceField> GetFields();
private:
@ -58,6 +97,10 @@ private:
const ApiConfig *conf_;
protected:
/**
* @brief Get the Api Config object
* @return const ApiConfig*
*/
const ApiConfig *GetApiConfig() const override
{
return conf_;

View File

@ -22,22 +22,58 @@
namespace abckit::core {
/**
* @brief AnnotationInterfaceField
*/
class AnnotationInterfaceField : public View<AbckitCoreAnnotationInterfaceField *> {
/// @brief core::Annotation
friend class core::Annotation;
/// @brief arkts::Annotation
friend class arkts::Annotation;
/// @brief core::AnnotationInterface
friend class core::AnnotationInterface;
/// @brief arkts::AnnotationInterface
friend class arkts::AnnotationInterface;
public:
/**
* @brief Construct a new Annotation Interface Field object
* @param other
*/
AnnotationInterfaceField(const AnnotationInterfaceField &other) = default;
/**
* @brief Constructor
* @param other
* @return AnnotationInterfaceField&
*/
AnnotationInterfaceField &operator=(const AnnotationInterfaceField &other) = default;
/**
* @brief Construct a new Annotation Interface Field object
* @param other
*/
AnnotationInterfaceField(AnnotationInterfaceField &&other) = default;
/**
* @brief Constructor
* @param other
* @return AnnotationInterfaceField&
*/
AnnotationInterfaceField &operator=(AnnotationInterfaceField &&other) = default;
/**
* @brief Destroy the Annotation Interface Field object
*/
~AnnotationInterfaceField() override = default;
// Core API's.
// ...
/**
* @brief Get the Name object
* @return std::string_view
*/
std::string_view GetName();
private:
@ -46,6 +82,10 @@ private:
const ApiConfig *conf_;
protected:
/**
* @brief Get the Api Config object
* @return const ApiConfig*
*/
const ApiConfig *GetApiConfig() const override
{
return conf_;

View File

@ -24,23 +24,72 @@
namespace abckit::core {
/**
* @brief Class
*/
class Class : public View<AbckitCoreClass *> {
// To access private constructor.
// We restrict constructors in order to prevent C/C++ API mix-up by user.
/// @brief to access private constructor
friend class Module;
/// @brief to access private constructor
friend class Namespace;
/// @brief to access private constructor
friend class Function;
public:
/**
* @brief Construct a new Class object
* @param other
*/
Class(const Class &other) = default;
/**
* @brief Constructor
* @param other
* @return Class&
*/
Class &operator=(const Class &other) = default;
/**
* @brief Construct a new Class object
* @param other
*/
Class(Class &&other) = default;
/**
* @brief Constructor
* @param other
* @return Class&
*/
Class &operator=(Class &&other) = default;
/**
* @brief Destroy the Class object
*/
~Class() override = default;
/**
* @brief Get Class name
* @return std::string_view
*/
std::string_view GetName() const;
/**
* @brief Get the All Methods object
* @return std::vector<core::Function>
*/
std::vector<core::Function> GetAllMethods() const;
/**
* @brief Get the Annotations object
* @return std::vector<core::Annotation>
*/
std::vector<core::Annotation> GetAnnotations() const;
/**
* @brief EnumerateMethods
* @param cb
*/
void EnumerateMethods(const std::function<bool(core::Function)> &cb) const;
// Core API's.

View File

@ -22,20 +22,54 @@
namespace abckit::core {
/**
* @brief ExportDescriptor
*/
class ExportDescriptor : public View<AbckitCoreExportDescriptor *> {
// To access private constructor.
// We restrict constructors in order to prevent C/C++ API mix-up by user.
/// @brief to access private constructor
friend class abckit::File;
/// @brief to access private constructor
friend class abckit::core::Module;
/// @brief to access private constructor
friend class abckit::arkts::Module;
public:
/**
* @brief Construct a new Export Descriptor object
* @param other
*/
ExportDescriptor(const ExportDescriptor &other) = default;
/**
* @brief Constructor
* @param other
* @return ExportDescriptor&
*/
ExportDescriptor &operator=(const ExportDescriptor &other) = default;
/**
* @brief Construct a new Export Descriptor object
* @param other
*/
ExportDescriptor(ExportDescriptor &&other) = default;
/**
* @brief Constructor
* @param other
* @return ExportDescriptor&
*/
ExportDescriptor &operator=(ExportDescriptor &&other) = default;
/**
* @brief Destroy the Export Descriptor object
*/
~ExportDescriptor() override = default;
/**
* @brief Get the Name object
* @return std::string_view
*/
std::string_view GetName() const;
// Core API's.
@ -46,6 +80,10 @@ private:
const ApiConfig *conf_;
protected:
/**
* @brief Get the Api Config object
* @return const ApiConfig*
*/
const ApiConfig *GetApiConfig() const override
{
return conf_;

View File

@ -20,17 +20,46 @@
namespace abckit::core {
/**
* @brief Field
*/
class Field : public View<AbckitCoreField *> {
// To access private constructor.
// We restrict constructors in order to prevent C/C++ API mix-up by user.
/// @brief to access private constructor
friend class Module;
/// @brief to access private constructor
friend class Namespace;
public:
/**
* @brief Construct a new Field object
* @param other
*/
Field(const Field &other) = default;
/**
* @brief Constructor
* @param other
* @return Field&
*/
Field &operator=(const Field &other) = default;
/**
* @brief Construct a new Field object
* @param other
*/
Field(Field &&other) = default;
/**
* @brief Constructor
* @param other
* @return Field&
*/
Field &operator=(Field &&other) = default;
/**
* @brief Destroy the Field object
*/
~Field() override = default;
// Core API's.
@ -41,6 +70,10 @@ private:
const ApiConfig *conf_;
protected:
/**
* @brief Get the Api Config object
* @return const ApiConfig*
*/
const ApiConfig *GetApiConfig() const override
{
return conf_;

View File

@ -25,28 +25,92 @@
namespace abckit::core {
/**
* @brief Function
*/
class Function : public View<AbckitCoreFunction *> {
// To access private constructor.
// We restrict constructors in order to prevent C/C++ API mix-up by user.
/// @brief to access private constructor
friend class core::Class;
/// @brief to access private constructor
friend class core::Module;
/// @brief to access private constructor
friend class abckit::Instruction;
public:
/**
* @brief Construct a new Function object
* @param other
*/
Function(const Function &other) = default;
/**
* @brief Constructor
* @param other
* @return Function&
*/
Function &operator=(const Function &other) = default;
/**
* @brief Construct a new Function object
* @param other
*/
Function(Function &&other) = default;
/**
* @brief Constructor
* @param other
* @return Function&
*/
Function &operator=(Function &&other) = default;
/**
* @brief Destroy the Function object
*/
~Function() override = default;
/**
* @brief Get the Graph object
* @return Graph
*/
Graph GetGraph() const;
/**
* @brief Set the Graph object
* @param graph
*/
void SetGraph(const Graph &graph);
/**
* @brief Get the name
* @return std::string_view
*/
std::string_view GetName() const;
/**
* @brief Get the annotation
* @return std::vector<core::Annotation>
*/
std::vector<core::Annotation> GetAnnotations() const;
/**
* @brief is static
* @return bool
*/
bool IsStatic() const;
// Core API's.
/**
* @brief Get the Module object
* @return core::Module
*/
core::Module GetModule() const;
/**
* @brief Get the Parent Class object
*
* @return core::Class
*/
core::Class GetParentClass() const;
private:

View File

@ -22,24 +22,63 @@
namespace abckit::core {
/**
* @brief ImportDescriptor
*/
class ImportDescriptor : public View<AbckitCoreImportDescriptor *> {
// To access private constructor.
// We restrict constructors in order to prevent C/C++ API mix-up by user.
/// @brief to access private constructor
friend class abckit::File;
/// @brief to access private constructor
friend class abckit::core::Module;
/// @brief to access private constructor
friend class abckit::arkts::Module;
/// @brief to access private constructor
friend class abckit::DynamicIsa;
public:
/**
* @brief Construct a new Import Descriptor object
* @param other
*/
ImportDescriptor(const ImportDescriptor &other) = default;
/**
* @brief Constructor
* @param other
* @return ImportDescriptor&
*/
ImportDescriptor &operator=(const ImportDescriptor &other) = default;
/**
* @brief Construct a new Import Descriptor object
* @param other
*/
ImportDescriptor(ImportDescriptor &&other) = default;
/**
* @brief Constructor
* @param other
* @return ImportDescriptor&
*/
ImportDescriptor &operator=(ImportDescriptor &&other) = default;
/**
* @brief Destroy the Import Descriptor object
*/
~ImportDescriptor() override = default;
/**
* @brief Get the Name object
* @return std::string_view
*/
std::string_view GetName() const;
// Core API's.
/**
* @brief Get the Imported Module object
* @return core::Module
*/
core::Module GetImportedModule() const;
private:
@ -47,6 +86,10 @@ private:
const ApiConfig *conf_;
protected:
/**
* @brief Get the Api Config object
* @return const ApiConfig*
*/
const ApiConfig *GetApiConfig() const override
{
return conf_;

View File

@ -24,29 +24,110 @@
namespace abckit::core {
/**
* @brief Module
*/
class Module : public View<AbckitCoreModule *> {
// To access private constructor.
// We restrict constructors in order to prevent C/C++ API mix-up by user.
/// @brief to access private constructor
friend class abckit::File;
/// @brief to access private constructor
friend class abckit::core::Function;
/// @brief to access private constructor
friend class abckit::core::ImportDescriptor;
public:
/**
* @brief Construct a new Module object
* @param other
*/
Module(const Module &other) = default;
/**
* @brief Constructor
* @param other
* @return Module&
*/
Module &operator=(const Module &other) = default;
/**
* @brief Construct a new Module object
* @param other
*/
Module(Module &&other) = default;
/**
* @brief Constructor
* @param other
* @return Module&
*/
Module &operator=(Module &&other) = default;
/**
* @brief Destroy the Module object
*/
~Module() override = default;
/**
* @brief Get the Classes name
* @return std::string_view
*/
std::string_view GetName() const;
/**
* @brief Get the Classes object
* @return std::vector<core::Class>
*/
std::vector<core::Class> GetClasses() const;
/**
* @brief Get the Top Level Functions object
* @return std::vector<core::Function>
*/
std::vector<core::Function> GetTopLevelFunctions() const;
/**
* @brief Get the Annotation Interfaces object
* @return std::vector<core::AnnotationInterface>
*/
std::vector<core::AnnotationInterface> GetAnnotationInterfaces() const;
/**
* @brief Get the Namespaces object
*
* @return std::vector<core::Namespace>
*/
std::vector<core::Namespace> GetNamespaces() const;
/**
* @brief Get the Imports object
* @return std::vector<core::ImportDescriptor>
*/
std::vector<core::ImportDescriptor> GetImports() const;
/**
* @brief Get the Exports object
*
* @return std::vector<core::ExportDescriptor>
*/
std::vector<core::ExportDescriptor> GetExports() const;
/**
* @brief EnumerateTopLevelFunctions
* @param cb
*/
void EnumerateTopLevelFunctions(const std::function<bool(core::Function)> &cb) const;
/**
* @brief EnumerateClasses
* @param cb
*/
void EnumerateClasses(const std::function<bool(core::Class)> &cb) const;
/**
* @brief EnumerateImports
* @param cb
*/
void EnumerateImports(const std::function<bool(core::ImportDescriptor)> &cb) const;
// Core API's.

View File

@ -22,18 +22,52 @@
namespace abckit::core {
/**
* @brief Namespace
*/
class Namespace : public View<AbckitCoreNamespace *> {
// To access private constructor.
// We restrict constructors in order to prevent C/C++ API mix-up by user.
/// @brief to access private constructor
friend class abckit::File;
/// @brief to access private constructor
friend class Module;
public:
/**
* @brief Construct a new Namespace object
* @param other
*/
Namespace(const Namespace &other) = default;
/**
* @brief
* @param other
* @return Namespace&
*/
Namespace &operator=(const Namespace &other) = default;
/**
* @brief Construct a new Namespace object
* @param other
*/
Namespace(Namespace &&other) = default;
/**
* @brief
* @param other
* @return Namespace&
*/
Namespace &operator=(Namespace &&other) = default;
/**
* @brief Destroy the Namespace object
*/
~Namespace() override = default;
/**
* @brief Get the Name object
* @return std::string_view
*/
std::string_view GetName() const
{
AbckitString *abcName = GetApiConfig()->cIapi_->namespaceGetName(GetView());
@ -51,6 +85,10 @@ private:
const ApiConfig *conf_;
protected:
/**
* @brief Get the Api Config object
* @return const ApiConfig*
*/
const ApiConfig *GetApiConfig() const override
{
return conf_;

View File

@ -25,24 +25,81 @@ namespace abckit {
class Graph;
// Third type of Entity? Or just a view?
/**
* @brief DynamicIsa
*/
class DynamicIsa final {
// To access private constructor.
// We restrict constructors in order to prevent C/C++ API mix-up by user.
/**
* Field to access private constructor
*/
friend class Graph;
public:
/**
* @brief Deleted constructor
* @param other
*/
DynamicIsa(const DynamicIsa &other) = delete;
/**
* @brief Deleted constructor
* @param other
* @return DynamicIsa
*/
DynamicIsa &operator=(const DynamicIsa &other) = delete;
/**
* @brief Deleted constructor
* @param other
*/
DynamicIsa(DynamicIsa &&other) = delete;
/**
* @brief Deleted constructor
* @param other
* @return DynamicIsa
*/
DynamicIsa &operator=(DynamicIsa &&other) = delete;
/**
* @brief Destructor
*/
~DynamicIsa() = default;
// Rvalue annotated so we can call it only in callchain context
/**
* @brief Creates instruction with opcode LOAD_STRING. This instruction loads the string `str` into `acc`.
* @param str to load
* @return `Instruction`
*/
Instruction CreateLoadString(const std::string &str) &&;
/**
* @brief Creates instruction with opcode TRYLDGLOBALBYNAME. Loads the global variable of the name `string`.
* If the global variable `string` does not exist, an exception is thrown.
* @param str to load
* @return `Instruction`
*/
Instruction CreateTryldglobalbyname(const std::string &str) &&;
/**
* @brief Creates instruction with opcode CALLARG1. This instruction invokes the function object stored in `acc`
* with `input0` argument
* @param [ in ] acc - Inst containing function object.
* @param [ in ] input0 - Inst containing argument.
* @return `Instruction`
*/
Instruction CreateCallArg1(const Instruction &acc, const Instruction &input0) &&;
// Other dynamic API methods declarations
/**
* @brief Get the Import Descriptor object
* @param inst
* @return core::ImportDescriptor
*/
core::ImportDescriptor GetImportDescriptor(const Instruction &inst);
private:

View File

@ -29,6 +29,9 @@
namespace abckit {
/**
* @brief File
*/
class File final : public Resource<AbckitFile *> {
private:
class FileDeleter final : public IResourceDeleter {
@ -51,21 +54,65 @@ private:
};
public:
/**
* @brief Constructor
* @param path
*/
explicit File(const char *path) : File(std::string(path)) {};
/**
* @brief Constructor
* @param path
*/
explicit File(const std::string &path) : File(path, std::make_unique<DefaultErrorHandler>()) {}
/**
* @brief Deleted constructor
* @param file
*/
File(const File &file) = delete;
/**
* @brief Deleted constructor
* @param file
* @return File
*/
File &operator=(const File &file) = delete;
/**
* @brief Deleted constructor
* @param file
*/
File(File &&file) = delete;
/**
* @brief Deleted constructor
* @param file
* @return File
*/
File &operator=(File &&file) = delete;
/**
* @brief Constructor
* @param path
* @param eh
*/
File(const std::string &path, std::unique_ptr<IErrorHandler> eh)
: Resource(AbckitGetApiImpl(ABCKIT_VERSION_RELEASE_1_0_0)->openAbc(path.c_str())), conf_(std::move(eh))
{
CheckError(&conf_);
SetDeleter(std::make_unique<FileDeleter>(&conf_, *this));
}
/**
* @brief Destructor
*/
~File() override = default;
/**
* @brief Creates value item `AbckitValue` containing the given boolean value `value`.
* @param val
* @return `Value`
*/
abckit::Value CreateValueU1(bool val)
{
AbckitValue *value = GetApiConfig()->cMapi_->createValueU1(GetResource(), val);
@ -73,6 +120,11 @@ public:
return abckit::Value(value, GetApiConfig());
}
/**
* @brief Creates value item containing the given double value `value`.
* @param val
* @return `Value`
*/
abckit::Value CreateValueDouble(double val)
{
AbckitValue *value = GetApiConfig()->cMapi_->createValueDouble(GetResource(), val);
@ -80,6 +132,11 @@ public:
return abckit::Value(value, GetApiConfig());
}
/**
* @brief Creates value item containing the given bool value `value`.
* @param val
* @return `Value`
*/
abckit::Literal CreateLiteralBool(bool val)
{
AbckitLiteral *literal = GetApiConfig()->cMapi_->createLiteralBool(GetResource(), val);
@ -87,6 +144,11 @@ public:
return abckit::Literal(literal, GetApiConfig());
}
/**
* @brief Creates value item containing the given bool value `value`.
* @param val
* @return `Value`
*/
abckit::Literal CreateLiteralDouble(double val)
{
AbckitLiteral *literal = GetApiConfig()->cMapi_->createLiteralDouble(GetResource(), val);
@ -94,6 +156,11 @@ public:
return abckit::Literal(literal, GetApiConfig());
}
/**
* @brief Creates literal containing the given double value `value`.
* @param val
* @return `Literal`
*/
abckit::Literal CreateLiteralU32(double val)
{
AbckitLiteral *literal = GetApiConfig()->cMapi_->createLiteralU32(GetResource(), val);
@ -101,6 +168,11 @@ public:
return abckit::Literal(literal, GetApiConfig());
}
/**
* @brief Creates literal containing the given literal array `litarr`.
* @param val
* @return `Literal`
*/
abckit::Literal CreateLiteralLiteralArray(const abckit::LiteralArray &val)
{
AbckitLiteral *literal = GetApiConfig()->cMapi_->createLiteralLiteralArray(GetResource(), val.GetView());
@ -108,23 +180,48 @@ public:
return abckit::Literal(literal, GetApiConfig());
}
/**
* @brief Creates literal array value item with size `size` from the given value items array `value`.
* @param literals
* @return `LiteralArray`
*/
abckit::LiteralArray CreateLiteralArray(const std::vector<abckit::Literal> &literals) const;
/**
* @brief Writes `file` to the specified `path`.
* @param path - path to file
*/
void WriteAbc(const std::string &path)
{
GetApiConfig()->cApi_->writeAbc(GetResource(), path.c_str());
CheckError(GetApiConfig());
}
// Returns a vector of core::Module's in a particular file
/**
* @brief Returns a vector of core::Module's in a particular file
* @return vector of `Module`.
*/
std::vector<core::Module> GetModules() const;
// Returns all functions in a file (consider to delete for mainenace reasons)
/**
* @brief Returns all functions in a file (consider to delete for mainenace reasons)
* @return vector of `Function`.
*/
std::vector<core::Function> GetAllFunctions() const;
/**
* @brief EnumerateModules
* @param cb
*/
void EnumerateModules(const std::function<bool(core::Module)> &cb) const;
// Other API.
protected:
/**
* @brief Get api config
* @return ApiConfig
*/
const ApiConfig *GetApiConfig() const override
{
return &conf_;

View File

@ -26,28 +26,77 @@
namespace abckit {
/**
* @brief Graph
*/
class Graph final : public Resource<AbckitGraph *> {
// To access private constructor.
// We restrict constructors in order to prevent C/C++ API mix-up by user.
/// @brief To access private constructor
friend class core::Function;
/// @brief To access private constructor
friend class DynamicIsa;
/// @brief To access private constructor
friend class StaticIsa;
public:
/**
* @brief Deleted constructor
* @param other
*/
Graph(const Graph &other) = delete;
/**
* @brief Deleted constructor
* @param other
* @return Graph
*/
Graph &operator=(const Graph &other) = delete;
/**
* @brief Constructor
* @param other
*/
Graph(Graph &&other) = default;
/**
* @brief Constructor
* @param other
* @return Graph
*/
Graph &operator=(Graph &&other) = default;
/**
* @brief Destructor
*/
~Graph() override = default;
/**
* @brief Get start basic block
* @return `BasicBlock`
*/
BasicBlock GetStartBb() const;
/**
* @brief Get blocks RPO
* @return vector of `BasicBlock`
*/
std::vector<BasicBlock> GetBlocksRPO() const;
/**
* @brief Get dyn isa
* @return `DynamicIsa`
*/
DynamicIsa DynIsa()
{
return DynamicIsa(*this);
}
/**
* @brief Get static isa
* @return `StatIsa`
*/
StaticIsa StatIsa()
{
return StaticIsa(*this);
@ -57,6 +106,10 @@ public:
// ...
protected:
/**
* @brief Get api config
* @return `ApiConfig`
*/
const ApiConfig *GetApiConfig() const override
{
return conf_;
@ -65,13 +118,45 @@ protected:
private:
class GraphDeleter final : public IResourceDeleter {
public:
/**
* @brief Constructor
* @param conf
* @param graph
*/
GraphDeleter(const ApiConfig *conf, const Graph &graph) : conf_(conf), deleterGraph_(graph) {};
/**
* @brief Deleted constructor
* @param other
*/
GraphDeleter(const GraphDeleter &other) = delete;
/**
* @brief Deleted constructor
* @param other
*/
GraphDeleter &operator=(const GraphDeleter &other) = delete;
/**
* @brief Deleted constructor
* @param other
*/
GraphDeleter(GraphDeleter &&other) = delete;
/**
* @brief Deleted constructor
* @param other
*/
GraphDeleter &operator=(GraphDeleter &&other) = delete;
/**
* @brief Destructor
*/
~GraphDeleter() override = default;
/**
* @brief Delete resource
*/
void DeleteResource() override
{
conf_->cApi_->destroyGraph(deleterGraph_.GetResource());

View File

@ -20,35 +20,112 @@
namespace abckit {
/**
* @brief Instruction
*/
class Instruction final : public View<AbckitInst *> {
// To access private constructor.
// We restrict constructors in order to prevent C/C++ API mix-up by user.
/// @brief To access private constructor
friend class BasicBlock;
/// @brief To access private constructor
friend class StaticIsa;
/// @brief To access private constructor
friend class DynamicIsa;
public:
/**
* @brief Construct a new Instruction object
* @param other
*/
Instruction(const Instruction &other) = default;
/**
* @brief Constructor
* @param other
* @return Instruction
*/
Instruction &operator=(const Instruction &other) = default;
/**
* @brief Constructor
* @param other
*/
Instruction(Instruction &&other) = default;
/**
* @brief Constructor
* @param other
* @return Instruction
*/
Instruction &operator=(Instruction &&other) = default;
/**
* @brief Destructor
*/
~Instruction() override = default;
/**
* @brief Inserts `newInst` instruction after `ref` instruction into `ref`'s basic block.
* @param inst
* @return Instruction&
*/
Instruction &InsertAfter(const Instruction &inst);
/**
* @brief Inserts `newInst` instruction before `ref` instruction into `ref`'s basic block.
* @param inst
* @return Instruction&
*/
Instruction &InsertBefore(const Instruction &inst);
/**
* @brief Get the Opcode Dyn object
* @return AbckitIsaApiDynamicOpcode
*/
AbckitIsaApiDynamicOpcode GetOpcodeDyn() const;
/**
* @brief Get the Opcode Stat object
* @return AbckitIsaApiStaticOpcode
*/
AbckitIsaApiStaticOpcode GetOpcodeStat() const;
/**
* @brief Get the String object
* @return std::string_view
*/
std::string_view GetString() const;
/**
* @brief Get the Next object
* @return Instruction
*/
Instruction GetNext() const;
/**
* @brief Get the Function object
* @return core::Function
*/
core::Function GetFunction() const;
protected:
/**
* @brief Get the Api Config object
* @return const ApiConfig*
*/
const ApiConfig *GetApiConfig() const override
{
return conf_;
}
private:
/**
* @brief Construct a new Instruction object
* @param inst
* @param conf
*/
Instruction(AbckitInst *inst, const ApiConfig *conf) : View(inst), conf_(conf) {};
const ApiConfig *conf_;
};

View File

@ -21,20 +21,62 @@
namespace abckit {
/**
* @brief Literal
*/
class Literal : public View<AbckitLiteral *> {
/// @brief abckit::File
friend class abckit::File;
public:
/**
* @brief Construct a new Literal object
* @param other
*/
Literal(const Literal &other) = default;
/**
* @brief Constructor
* @param other
* @return Literal&
*/
Literal &operator=(const Literal &other) = default;
/**
* @brief Construct a new Literal object
* @param other
*/
Literal(Literal &&other) = default;
/**
* @brief Constructor
* @param other
* @return Literal&
*/
Literal &operator=(Literal &&other) = default;
/**
* @brief Destroy the Literal object
*/
~Literal() override = default;
/**
* @brief Get the Bool object
* @return bool
*/
bool GetBool() const;
/**
* @brief Get the Literal Array object
* @return abckit::LiteralArray
*/
abckit::LiteralArray GetLiteralArray() const;
protected:
/**
* @brief Get the Api Config object
* @return const ApiConfig*
*/
const ApiConfig *GetApiConfig() const override
{
return conf_;

View File

@ -20,18 +20,53 @@
namespace abckit {
/**
* @brief LiteralArray
*/
class LiteralArray : public View<AbckitLiteralArray *> {
/// @brief abckit::File
friend class abckit::File;
/// @brief abckit::Literal
friend class abckit::Literal;
public:
/**
* @brief Construct a new Literal Array object
* @param other
*/
LiteralArray(const LiteralArray &other) = default;
/**
* @brief Constructor
* @param other
* @return LiteralArray&
*/
LiteralArray &operator=(const LiteralArray &other) = default;
/**
* @brief Construct a new Literal Array object
* @param other
*/
LiteralArray(LiteralArray &&other) = default;
/**
* @brief Constructor
* @param other
* @return LiteralArray&
*/
LiteralArray &operator=(LiteralArray &&other) = default;
/**
* @brief Destroy the Literal Array object
*
*/
~LiteralArray() override = default;
protected:
/**
* @brief Get the Api Config object
* @return const ApiConfig*
*/
const ApiConfig *GetApiConfig() const override
{
return conf_;

View File

@ -20,17 +20,50 @@
namespace abckit {
/**
* @brief Type
*/
class Type : public View<AbckitType *> {
/// @brief abckit::File
friend class abckit::File;
public:
/**
* @brief Construct a new Type object
* @param other
*/
Type(const Type &other) = default;
/**
* @brief Constructor
* @param other
* @return Type&
*/
Type &operator=(const Type &other) = default;
/**
* @brief Construct a new Type object
* @param other
*/
Type(Type &&other) = default;
/**
* @brief Constructor
* @param other
* @return Type&
*/
Type &operator=(Type &&other) = default;
/**
* @brief Destroy the Type object
*/
~Type() override = default;
protected:
/**
* @brief Get the Api Config object
* @return const ApiConfig*
*/
const ApiConfig *GetApiConfig() const override
{
return conf_;

View File

@ -67,12 +67,25 @@ public:
}
};
#else
/**
* @brief Exception
*/
class Exception {
public:
/**
* @brief Constructor
* @param e - status
*/
explicit Exception(AbckitStatus e) : whatMessage_(StatusToString(e)) {}
// CC-OFFNXT(G.NAM.03) made to be compatible with std::runtime_error::what method
const char *what() const noexcept // NOLINT(readability-identifier-naming)
// NOLINT(readability-identifier-naming)
/**
* @brief What
* @return string
*/
const char *What() const noexcept
{
// CC-OFFNXT(G.STD.04) made to be compatible with std::runtime_error::what method
return whatMessage_.c_str();
@ -83,27 +96,97 @@ private:
};
#endif
/**
* @brief IErrorHandler
*/
class IErrorHandler {
public:
/**
* Сonstructor
*/
IErrorHandler() = default;
/**
* @brief Constructor
* @param other
*/
IErrorHandler(const IErrorHandler &other) = default;
/**
* @brief Constructor
* @param other
* @return IErrorHandler
*/
IErrorHandler &operator=(const IErrorHandler &other) = default;
/**
* @brief Constructor
* @param other
*/
IErrorHandler(IErrorHandler &&other) = default;
/**
* @brief Constructor
* @param other
* @return IErrorHandler
*/
IErrorHandler &operator=(IErrorHandler &&other) = default;
/**
* @brief Destructor
*/
virtual ~IErrorHandler() = default;
//! @cond Doxygen_Suppress
virtual void HandleError(Exception &&e) = 0;
//! @endcond
};
/**
* @brief DefaultErrorHandler
*/
class DefaultErrorHandler final : public IErrorHandler {
public:
/**
* Сonstructor
*/
DefaultErrorHandler() = default;
/**
* @brief Constructor
* @param other
*/
DefaultErrorHandler(const DefaultErrorHandler &other) = default;
/**
* @brief Constructor
* @param other
* @return DefaultErrorHandler
*/
DefaultErrorHandler &operator=(const DefaultErrorHandler &other) = default;
/**
* @brief Constructor
* @param other
*/
DefaultErrorHandler(DefaultErrorHandler &&other) = default;
/**
* @brief Constructor
* @param other
* @return DefaultErrorHandler
*/
DefaultErrorHandler &operator=(DefaultErrorHandler &&other) = default;
/**
* @brief Destructor
*/
~DefaultErrorHandler() override = default;
/**
* Handle error
* @param e - exception
*/
void HandleError([[maybe_unused]] Exception &&e) override
{
// Default behaviour - do nothing.
@ -114,27 +197,96 @@ public:
}
};
/**
* @brief IResourceDeleter
*/
class IResourceDeleter {
public:
/**
* Сonstructor
*/
IResourceDeleter() = default;
/**
* @brief Constructor
* @param other
*/
IResourceDeleter(const IResourceDeleter &other) = default;
/**
* @brief Constructor
* @param other
* @return IResourceDeleter
*/
IResourceDeleter &operator=(const IResourceDeleter &other) = default;
/**
* @brief Constructor
* @param other
*/
IResourceDeleter(IResourceDeleter &&other) = default;
/**
* @brief Constructor
* @param other
* @return IResourceDeleter
*/
IResourceDeleter &operator=(IResourceDeleter &&other) = default;
/**
* @brief Destructor
*/
virtual ~IResourceDeleter() = default;
//! @cond Doxygen_Suppress
virtual void DeleteResource() = 0;
//! @endcond
};
/**
* @brief DefaultResourceDeleter
*/
class DefaultResourceDeleter final : public IResourceDeleter {
public:
/**
* Сonstructor
*/
DefaultResourceDeleter() = default;
/**
* @brief Constructor
* @param other
*/
DefaultResourceDeleter(const DefaultResourceDeleter &other) = default;
/**
* @brief Constructor
* @param other
* @return `DefaultResourceDeleter`
*/
DefaultResourceDeleter &operator=(const DefaultResourceDeleter &other) = default;
/**
* @brief Constructor
* @param other
*/
DefaultResourceDeleter(DefaultResourceDeleter &&other) = default;
/**
* @brief Constructor
* @param other
* @return `DefaultResourceDeleter`
*/
DefaultResourceDeleter &operator=(DefaultResourceDeleter &&other) = default;
/**
* Destructor
*/
~DefaultResourceDeleter() override = default;
/**
* @brief Delete resource
*/
void DeleteResource() override
{ /* Do nothing by default. Debug log here, probably? */
}

View File

@ -20,18 +20,53 @@
namespace abckit {
/**
* @brief Value
*/
class Value : public View<AbckitValue *> {
/// @brief abckit::File
friend class abckit::File;
/// @brief abckit::core::Annotation
friend class abckit::core::Annotation;
/// @brief abckit::arkts::Annotation
friend class abckit::arkts::Annotation;
public:
/**
* @brief Construct a new Value object
* @param other
*/
Value(const Value &other) = default;
/**
* @brief Constructor
* @param other
* @return Value&
*/
Value &operator=(const Value &other) = default;
/**
* @brief Construct a new Value object
* @param other
*/
Value(Value &&other) = default;
/**
* @brief Constructor
* @param other
* @return Value&
*/
Value &operator=(Value &&other) = default;
/**
* @brief Destroy the Value object
*/
~Value() override = default;
/**
* @brief Get the U1 value
* @return bool
*/
bool GetU1() const
{
bool ret = GetApiConfig()->cIapi_->valueGetU1(GetView());
@ -39,6 +74,10 @@ public:
return ret;
}
/**
* @brief Get the Double object
* @return double
*/
double GetDouble() const
{
double ret = GetApiConfig()->cIapi_->valueGetDouble(GetView());
@ -47,6 +86,10 @@ public:
}
protected:
/**
* @brief Get the Api Config object
* @return const ApiConfig*
*/
const ApiConfig *GetApiConfig() const override
{
return conf_;

View File

@ -31,22 +31,52 @@ def get_args():
action='store_true',
default=False,
help=f'Print list of implemented API and exit')
parser.add_argument(
'--cppapi',
action='store_true',
default=False,
help=f'Fill table with tests for cpp api')
parser.add_argument(
'--capi',
action='store_true',
default=False,
help=f'Fill table with tests for c api')
return parser.parse_args()
args = get_args()
API_PATTERN = r'^[\w,\d,_, ,*]+\(\*([\w,\d,_]+)\)\(.*'
PUBLIC_API_PATTERN = r'^(?!explicit)(.+) (?!~)[\&\*]*(?!operator)(.+)\(.*'
domain_patterns = [r'struct Abckit\S*Api\s\{', r'struct Abckit\S*ApiStatic\s\{', r'struct Abckit\S*ApiDynamic\s\{']
libabckit_dir = os.path.join(script_dir, '..')
specs = ['public:', 'private:', 'protected:']
libabckit_dir = script_dir.rsplit('/', 1)[0]
abckit_tests = os.path.join(libabckit_dir, 'tests')
sources = {
'include/c/ir_core.h',
'include/c/metadata_core.h',
'include/c/extensions/arkts/metadata_arkts.h',
'include/c/extensions/js/metadata_js.h',
'src/include_v2/c/isa/isa_static.h',
'include/c/isa/isa_dynamic.h',
'include/c/abckit.h'
c_sources = {
'include/c',
'src/include_v2/c/isa'
}
c_tests = {
'tests/canary',
'tests/helpers',
'tests/internal',
'tests/null_args_tests',
'tests/sanitizers',
'tests/scenarios',
'tests/scenarios_c_api_clean',
'tests/stress',
'tests/ut tests/wrong_ctx_tests',
'tests/wrong_mode_tests'
}
cpp_sources = {
'include/cpp'
}
cpp_tests = {
'tests/cpp/tests',
'tests/mock',
}
TS = 'TS'
@ -56,63 +86,6 @@ ARKTS2 = 'ArkTS2'
NO_ABC = 'NoABC'
def check(cond, msg=''):
if not cond:
raise Exception(msg)
class API:
def __init__(self, name, domain):
self.name = name
self.domain = domain
self.dynamic_positive_tests = 0
self.static_positive_tests = 0
self.arkts1_tests = 0
self.arkts2_tests = 0
self.js_tests = 0
self.ts_tests = 0
self.no_abc_tests = 0
self.positive_tests = 0
self.negative_tests = 0
self.negative_nullptr_tests = 0
self.negative_ctx_tests = 0
self.negative_mode_tests = 0
self.other_tests = 0
def domain_match(line):
for pattern in domain_patterns:
if re.fullmatch(pattern, line.strip()):
return line
return None
def update_domain(old_domain, l):
new_domain = domain_match(l.strip())
if not new_domain:
return old_domain
return re.search(r'struct Abckit(.*)\s\{', new_domain.strip()).group(1)
def collect_api(path):
api = {}
domain = ''
with open(path) as f:
for l in f.readlines():
domain = update_domain(domain, l)
if not re.fullmatch(API_PATTERN, l.strip()):
continue
if re.fullmatch(r'^\/\/' + API_PATTERN, l.strip()):
continue
func_name = re.search(r'^[\w,\d,_, ,*]+\(\*([\w,\d,_]+)\)\(.*', l.strip()).group(1)
if func_name == 'cb':
continue
check(domain)
api[f'{domain}Impl::{func_name}'] = API(func_name, domain)
return api
def check_test_anno_line(line):
mul_lines = False
anno_line = False
@ -141,6 +114,7 @@ class Test:
self.abc_kind = ''
self.api = ''
self.category = ''
self.extension = 'c'
check('// Test:' in s, err)
s = s.replace('// Test:', '')
@ -148,7 +122,7 @@ class Test:
for entry in entries:
key, value = entry.strip().split('=')
if key == 'test-kind':
check(value in ['api', 'scenario', 'internal'], err)
check(value in ['api', 'scenario', 'internal', 'mock'], err)
self.kind = value
elif key == 'abc-kind':
check(value in [ARKTS1, ARKTS2, JS, TS, NO_ABC], err)
@ -166,13 +140,16 @@ class Test:
]
check(value in possible_values, err)
self.category = value
elif key == 'extension':
self.extension = value
else:
check(False, f'Wrong key: {key}')
check(self.kind, err)
check(self.extension, err)
check(self.abc_kind, err)
check(self.category, err)
if self.kind == 'api':
if self.kind == 'api' or self.kind == 'mock':
check(self.api, err)
@ -184,12 +161,12 @@ def is_first_test_line(line):
def get_test_from_annotation(api, annotation):
test = Test(annotation)
if 'api=' in annotation and test.api != 'ApiImpl::GetLastError':
if ('api=' in annotation or 'mock=' in annotation) and test.api != 'ApiImpl::GetLastError':
check(test.api in api, f'No such API: {test.api}')
return test
def collect_tests(path, api):
def collect_tests_from_path(path, api):
with open(path, 'r') as f:
lines = f.readlines()
it = iter(lines)
@ -227,9 +204,18 @@ def collect_tests(path, api):
return tests
def collect_tests(path, api):
tests = []
for dirpath, _, filenames in os.walk(f'{libabckit_dir}/{path}'):
for name in filenames:
if name.endswith('.cpp'):
tests += collect_tests_from_path(os.path.join(dirpath, name), api)
return tests
def get_tests_statistics(api, tests):
for test in tests:
if test.kind != 'api' or test.api == 'ApiImpl::GetLastError':
if (test.kind != 'api' and test.kind != 'mock') or test.api == 'ApiImpl::GetLastError':
continue
if test.abc_kind == ARKTS1:
api[test.api].arkts1_tests += 1
@ -261,31 +247,177 @@ def get_tests_statistics(api, tests):
return api
def main(api) :
tests = []
for dirpath, _, filenames in os.walk(abckit_tests):
for name in filenames:
if name.endswith('.cpp'):
tests += collect_tests(os.path.join(dirpath, name), api)
def check(cond, msg=''):
if not cond:
raise Exception(msg)
class API:
def __init__(self, name, domain, sig='', extension=''):
self.name = name
self.domain = domain
self.sig = sig
self.extension = extension
self.dynamic_positive_tests = 0
self.static_positive_tests = 0
self.arkts1_tests = 0
self.arkts2_tests = 0
self.js_tests = 0
self.ts_tests = 0
self.no_abc_tests = 0
self.positive_tests = 0
self.negative_tests = 0
self.negative_nullptr_tests = 0
self.negative_ctx_tests = 0
self.negative_mode_tests = 0
self.other_tests = 0
def next_line(it):
return next(it).strip()
def determine_doclet(it, line):
if not line or line.strip() != "/**":
return ''
line = next_line(it)
funс_declaration = ''
while not funс_declaration:
if line and line == '*/':
l = next_line(it)
if 'template <' in l:
return next_line(it)
return l
line = next_line(it)
def collect_api(path, extension):
apis = {}
domain = ''
with open(path, 'r') as f:
accsess = 'public:'
lines = f.readlines()
it = iter(lines)
while True:
if (line := next(it, None)) is None:
break
line = line.strip()
if line in specs:
accsess = line
signature = determine_doclet(it, line)
api_name = ''
if not signature:
continue
if re.search(r'struct Abckit(.*)Api(.*)\s\{', signature):
domain = re.search(r'struct Abckit(.*)\s\{', signature.strip()).group(1)
domain = f'{domain}Impl'
elif re.match(r'class .+ {', signature):
if match := re.search(r'class (.+) .+ : .+ {', signature, re.IGNORECASE):
domain = match.group(1)
elif match := re.search(r'class (.+) : .+ {', signature, re.IGNORECASE):
domain = match.group(1)
elif match := re.search(r'class (.+) (.+){', signature, re.IGNORECASE):
domain = match.group(1)
elif match := re.search(r'class (.+) {', signature, re.IGNORECASE):
domain = match.group(1)
elif (re.match(PUBLIC_API_PATTERN, signature)) and accsess == "public:":
if re.match(API_PATTERN, signature.strip()):
api_name = re.search(r'^[\w,\d,_, ,*]+\(\*([\w,\d,_]+)\)\(.*', signature.strip()).group(1)
elif 'operator' not in signature:
api_name = re.search(r'(.+) [\&\*]*(.+)\(', signature, re.IGNORECASE)
api_name = api_name.group(2) if api_name else ''
else:
continue
apis[f'{domain}::{api_name}'] = API(api_name, domain, signature, extension)
else:
continue
return apis
def collect_api_from_sources(sources, extension):
apis = {}
for src in sources:
for (dirpath, _, filenames) in os.walk(f'{libabckit_dir}/{src}'):
headers = list(filter(lambda f: re.fullmatch(r'(.+)(?<!_impl).h$', f), filenames))
for file in headers:
apis = dict(apis.items() | collect_api(os.path.join(dirpath, file), extension).items())
return apis
def print_cppapi_stat(tests_pathes, api, expected=0):
tests = []
for p in tests_pathes:
tests += list(filter(lambda t: t.extension == 'cpp', collect_tests(p, api)))
api = get_tests_statistics(api, tests)
csv = (
'api,dynamic_positive_tests,static_positive_tests,'
'arkts1_tests,arkts2_tests,js_tests,ts_tests,no_abc_tests,positive_tests,'
'negative_tests,negative_nullptr_tests,negative_ctx_tests,other_tests\n'
)
def scenario_lang(name):
return len(list(filter(lambda t: t.kind == 'scenario' and t.abc_kind == name, tests)))
def api_tests_kind(kind):
return list(filter(lambda t: t.kind == kind, tests))
def get_element(array, i):
if len(array) <= i:
return 0
return array[i]
mock_tests_apis = list(dict.fromkeys(t.api for t in api_tests_kind("mock")))
api_tests_apis = list(dict.fromkeys(t.api for t in api_tests_kind("api")))
internal_tests = list(filter(lambda t: t.kind == 'internal', tests))
csv = ''
for i in range(max(len(mock_tests_apis), len(api_tests_apis))):
csv += f'{get_element(mock_tests_apis, i)},{get_element(api_tests_apis, i)}\n'
with os.fdopen(os.open(os.path.join(libabckit_dir, 'scripts/abckit_cppapi_status.csv'),
os.O_CREAT | os.O_WRONLY | os.O_TRUNC, 0o755), 'w+') as f:
f.write(('mock_tests_apis,api_tests_apis\n'))
f.write(csv)
logging.debug(f'>>> CPP EXTENSION <<<\n')
logging.debug('Total API: %s/%s', len(api), expected)
logging.debug('')
logging.debug('Total Tests: %s', len(tests))
logging.debug('')
logging.debug('Total API\'S with api tests: %s/%s',
len(api_tests_apis), expected)
logging.debug('Total API\'S with mock tests: %s/%s',
len(mock_tests_apis), expected)
logging.debug('Total internal tests: %s',
len(internal_tests))
logging.debug('ArkTS1/ArkTS2/JS/TS scenario tests: %s/%s/%s/%s',
scenario_lang(ARKTS1), scenario_lang(ARKTS2), scenario_lang(JS), scenario_lang(TS))
logging.debug(f'\n------------------------------------------------------------------\n')
def print_capi_stat(tests_pathes, api) :
csv = ''
tests = []
for p in tests_pathes:
tests += list(filter(lambda t: t.extension == 'c', collect_tests(p, api)))
api = get_tests_statistics(api, tests)
for name in api:
csv += (
f'{name},{api[name].dynamic_positive_tests},{api[name].static_positive_tests},'
f'{name},{api[name].extension},{api[name].dynamic_positive_tests},{api[name].static_positive_tests},'
f'{api[name].arkts1_tests},{api[name].arkts2_tests},{api[name].js_tests},{api[name].ts_tests},'
f'{api[name].no_abc_tests},{api[name].positive_tests},{api[name].negative_tests},'
f'{api[name].negative_nullptr_tests},{api[name].negative_ctx_tests},{api[name].other_tests}\n'
)
with os.fdopen(os.open(os.path.join(libabckit_dir, 'scripts/abckit_status.csv'),
os.O_CREAT | os.O_WRONLY | os.O_TRUNC, 0o755), 'w') as f:
with os.fdopen(os.open(os.path.join(libabckit_dir, 'scripts/abckit_capi_status.csv'),
os.O_CREAT | os.O_WRONLY | os.O_TRUNC, 0o755), 'w+') as f:
f.write(('api,extension,dynamic_positive_tests,static_positive_tests,'
'arkts1_tests,arkts2_tests,js_tests,ts_tests,no_abc_tests,positive_tests,'
'negative_tests,negative_nullptr_tests,negative_ctx_tests,other_tests\n'))
f.write(csv)
def api_test_category(name):
@ -297,6 +429,8 @@ def main(api) :
def scenario_lang(name):
return len(list(filter(lambda t: t.kind == 'scenario' and t.abc_kind == name, tests)))
logging.debug('>>> C <<<\n')
logging.debug('Total API: %s', len(api))
logging.debug('')
logging.debug('Total Tests: %s', len(tests))
@ -319,14 +453,21 @@ def main(api) :
logging.debug('')
logging.debug('Internal tests: %s',
len(list(filter(lambda t: t.kind == 'internal', tests))))
logging.debug(f'\n------------------------------------------------------------------\n')
collected_api = {}
for src in sources:
collected_api = dict(collected_api.items() | collect_api(f'{libabckit_dir}/' + src).items())
cpp_api, c_api = {}, {}
if args.cppapi:
cpp_api = dict(cpp_api.items() | collect_api_from_sources(cpp_sources, 'cpp').items())
c_api = dict(c_api.items() | collect_api_from_sources(c_sources, 'c').items())
if args.print_implemented:
logging.debug('\n'.join(collected_api))
if args.cppapi:
logging.debug('\n'.join(cpp_api))
if args.capi:
logging.debug('\n'.join(c_api))
else:
main(collected_api)
if args.cppapi:
print_cppapi_stat(cpp_tests, cpp_api, len(c_api))
if args.capi:
print_capi_stat(c_tests, c_api)

44
libabckit/tests/README.md Normal file
View File

@ -0,0 +1,44 @@
## Tests annotations
Test annotations are needed to collect statistics during project development, so it is important to write them correctly \
The test annotation is cpp comment, consisted of tags and values for test description in format \
! // Test: {tag1}={value1}, {tag2}={value2}, ...
### test-kind tag
The kind of test:
* api
* mock
* internal
### api tag
api tag reflects the implemented api name which checks ypur test
api tag must be in format *api_group*::*api_name*
examples:
api=GraphApiImpl::bbCreateEmpty - for bbCreateEmpty api from GraphApiImpl struct \
api=DynamicIsa::CreateLoadString - for CreateLoadString method of DynamicIsa class
api name should be correct (without typos and *api_name* is api from *api_group*)
api tag is necessary if test-kind=api or test-kind=mock
### abc-kind tag
The type of abc:
* ArkTS1
* ArkTS2
* JS
* TS
* NoABC
### category tag
the category of test:
* positive
* negative
### extension tag:
Tested extension. Add this tag only to extension's tests, but not to c api tests
* cpp
There are examples of correct annotations:
// Test: test-kind=api, api=GraphApiImpl::bbCreateEmpty, abc-kind=ArkTS1, category=positive
// Test: test-kind=api, api=File::GetAllFunctions, abc-kind=ArkTS1, category=positive, extension=cpp

View File

@ -31,7 +31,7 @@ class LibAbcKitCppTest : public ::testing::Test {};
// NOLINTNEXTLINE(google-build-using-namespace)
using namespace abckit;
// Test: test-kind=internal, abc-kind=ArkTS1, category=internal
// Test: test-kind=api, api=BasicBlock::AddInstFront, abc-kind=ArkTS1, category=internal, extension=cpp
TEST_F(LibAbcKitCppTest, CppTest1)
{
auto output = helpers::ExecuteDynamicAbc(ABCKIT_ABC_DIR "cpp/tests/cpp_test_dynamic.abc", "cpp_test_dynamic");
@ -87,7 +87,7 @@ TEST_F(LibAbcKitCppTest, CppTest1)
"Func end: func_main_0\n"));
}
// Test: test-kind=internal, abc-kind=ArkTS1, category=internal
// Test: test-kind=api, api=Function::AddAnnotation, abc-kind=ArkTS1, category=positive, extension=cpp
TEST_F(LibAbcKitCppTest, CppTest2)
{
auto output = helpers::ExecuteDynamicAbc(ABCKIT_ABC_DIR "cpp/tests/cpp_test_dynamic.abc", "cpp_test_dynamic");
@ -151,7 +151,7 @@ TEST_F(LibAbcKitCppTest, CppTest2)
EXPECT_TRUE(helpers::Match(output, "foo logic\nbar logic\n"));
}
// Test: test-kind=internal, abc-kind=JS, category=internal
// Test: test-kind=api, api=File::CreateValueU1, abc-kind=ArkTS1, category=positive, extension=cpp
TEST_F(LibAbcKitCppTest, CppTest3)
{
abckit::File file(ABCKIT_ABC_DIR "cpp/tests/cpp_test_dynamic_js.abc");
@ -161,7 +161,7 @@ TEST_F(LibAbcKitCppTest, CppTest3)
file.WriteAbc(ABCKIT_ABC_DIR "cpp/tests/cpp_test_dynamic_js_modified_3.abc");
}
// Test: test-kind=internal, abc-kind=JS, category=internal
// Test: test-kind=api, api=File::CreateLiteralBool, abc-kind=ArkTS1, category=internal, extension=cpp
TEST_F(LibAbcKitCppTest, CppTest4)
{
abckit::File file(ABCKIT_ABC_DIR "cpp/tests/cpp_test_dynamic_js.abc");
@ -171,7 +171,7 @@ TEST_F(LibAbcKitCppTest, CppTest4)
file.WriteAbc(ABCKIT_ABC_DIR "cpp/tests/cpp_test_dynamic_js_modified_4.abc");
}
// Test: test-kind=internal, abc-kind=JS, category=internal
// Test: test-kind=api, api=File::CreateLiteralArray, abc-kind=ArkTS1, category=internal, extension=cpp
TEST_F(LibAbcKitCppTest, CppTest5)
{
abckit::File file(ABCKIT_ABC_DIR "cpp/tests/cpp_test_dynamic_js.abc");
@ -186,7 +186,7 @@ TEST_F(LibAbcKitCppTest, CppTest5)
file.WriteAbc(ABCKIT_ABC_DIR "cpp/tests/cpp_test_dynamic_js_modified_5.abc");
}
// Test: test-kind=internal, abc-kind=ArkTS1, category=internal
// Test: test-kind=api, api=Annotation::AddAndGetElement, abc-kind=ArkTS1, category=positive, extension=cpp
TEST_F(LibAbcKitCppTest, CppTest6)
{
abckit::File file(ABCKIT_ABC_DIR "cpp/tests/cpp_test_dynamic.abc");
@ -223,7 +223,7 @@ TEST_F(LibAbcKitCppTest, CppTest6)
file.WriteAbc(ABCKIT_ABC_DIR "cpp/tests/cpp_test_dynamic_mofdified_6.abc");
}
// Test: test-kind=internal, abc-kind=ArkTS1, category=internal
// Test: test-kind=api, api=Module::GetNamespaces, abc-kind=ArkTS1, category=positive, extension=cpp
TEST_F(LibAbcKitCppTest, CppTest7)
{
abckit::File file(ABCKIT_ABC_DIR "cpp/tests/cpp_test_dynamic.abc");
@ -240,7 +240,7 @@ TEST_F(LibAbcKitCppTest, CppTest7)
ASSERT_EQ(nsNames[0], "MyNamespace");
}
// Test: test-kind=internal, abc-kind=ArkTS1, category=internal
// Test: test-kind=api, api=AnnotationInterface::GetFields, abc-kind=ArkTS1, category=internal, extension=cpp
TEST_F(LibAbcKitCppTest, CppTest8)
{
abckit::File file(ABCKIT_ABC_DIR "cpp/tests/cpp_test_dynamic.abc");
@ -262,7 +262,7 @@ TEST_F(LibAbcKitCppTest, CppTest8)
ASSERT_EQ(annFieldNames[3U], "str");
}
// Test: test-kind=internal, abc-kind=ArkTS1, category=internal
// Test: test-kind=api, api=ImportDescriptor::GetName, abc-kind=ArkTS1, category=positive, extension=cpp
TEST_F(LibAbcKitCppTest, CppTest9)
{
abckit::File file(ABCKIT_ABC_DIR "cpp/tests/cpp_test_dynamic.abc");
@ -279,7 +279,7 @@ TEST_F(LibAbcKitCppTest, CppTest9)
ASSERT_EQ(importNames[0], "TsExport");
}
// Test: test-kind=internal, abc-kind=ArkTS1, category=internal
// Test: test-kind=api, api=Module::GetExports, abc-kind=ArkTS1, category=positive, extension=cpp
TEST_F(LibAbcKitCppTest, CppTest10)
{
abckit::File file(ABCKIT_ABC_DIR "cpp/tests/cpp_test_dynamic.abc");

View File

@ -22,7 +22,7 @@ namespace libabckit::test {
class LibAbcKitCppMockTest : public ::testing::Test {};
// Test: test-kind=internal, abc-kind=ArkTS1, category=internal
// Test: test-kind=mock, api=File::WriteAbc, abc-kind=ArkTS1, category=internal, extension=cpp
TEST_F(LibAbcKitCppMockTest, CppTestMockFile)
{
{