| eRPC Generator (erpcgen) Rev. 1.8.1 NXP Semiconductors

- Main Page
- Classes
- Files

- File List

Symbol.h
1 /*
2 * Copyright (c) 2014, Freescale Semiconductor, Inc.
3 * Copyright 2016 NXP
4 * All rights reserved.
5 *
6 *
7 * SPDX-License-Identifier: BSD-3-Clause
8 */
9
10 #ifndef _EMBEDDED_RPC__SYMBOL_H_
11 #define _EMBEDDED_RPC__SYMBOL_H_
12
13 #include "Annotation.h"
14 #include "AstNode.h"
15 #include "Token.h"
16
17 #include <vector>
18
20 // Classes
22
23 namespace erpcgen {
24
28 class Symbol
29 {
30 public:
34 enum symbol_type_t
35 {
36 kConstSymbol,
37 kEnumMemberSymbol,
38 kFunctionSymbol,
39 kInterfaceSymbol,
40 kProgramSymbol,
41 kStructMemberSymbol,
42 kTypenameSymbol,
43 kUnionCaseMemberSymbol,
44
45 kAliasTypeSymbol,
46 kArrayTypeSymbol,
47 kBuiltinTypeSymbol,
48 kEnumTypeSymbol,
49 kFunctionTypeSymbol,
50 kListTypeSymbol,
51 kStructTypeSymbol,
52 kUnionTypeSymbol
53 };
54
62 Symbol(symbol_type_t symType)
63 : m_symbolType(symType)
64 , m_name()
65 , m_location()
66 , m_annotations()
67 , m_mlComment("")
68 , m_ilComment("")
69 {
70 }
71
80 Symbol(symbol_type_t symType, const std::string &name)
81 : m_symbolType(symType)
82 , m_name(name)
83 , m_location()
84 , m_annotations()
85 , m_mlComment("")
86 , m_ilComment("")
87 {
88 }
89
98 Symbol(symbol_type_t symType, const Token &tok)
99 : m_symbolType(symType)
100 , m_name(tok.getStringValue())
101 , m_location(tok.getLocation())
102 , m_annotations()
103 , m_mlComment("")
104 , m_ilComment("")
105 {
106 }
107
111 virtual ~Symbol() {}
112
118 symbol_type_t getSymbolType() const { return m_symbolType; }
119
125 const std::string &getName() const { return m_name; }
126
132 void setName(const std::string &newName) { m_name = newName; }
133
139 token_loc_t &getLocation() { return m_location; }
140
146 void setLocation(const token_loc_t &loc) { m_location = loc; }
147
153 int getFirstLine() const { return m_location.m_firstLine; }
154
160 int getLastLine() const { return m_location.m_lastLine; }
161
167 virtual bool isBuiltin() const { return false; }
168
174 virtual std::string getDescription() const { return m_name; }
175
181 void addAnnotation(const Annotation &a) { m_annotations.push_back(a); }
182
188 std::string printAnnotations();
189
198 Annotation *findAnnotation(std::string name, Annotation::program_lang_t lang);
199
208 std::vector<Annotation *> getAnnotations(std::string name, Annotation::program_lang_t lang);
209
215 const std::vector<Annotation> &getAnnotations() const { return m_annotations; };
216
225 Value *getAnnValue(const std::string annName, Annotation::program_lang_t lang);
226
235 std::string getAnnStringValue(const std::string annName, Annotation::program_lang_t lang);
236
242 std::string getMlComment() { return m_mlComment; }
243
249 void setMlComment(std::string comment) { m_mlComment = comment; }
250
256 std::string getIlComment() { return m_ilComment; }
257
263 void setIlComment(std::string comment) { m_ilComment = comment; }
264
265 protected:
266 symbol_type_t m_symbolType;
267 std::string m_name;
268 token_loc_t m_location;
269 std::vector<Annotation> m_annotations;
270 std::string m_mlComment;
271 std::string m_ilComment;
272 };
273
274 } // namespace erpcgen
275
276 #endif // _EMBEDDED_RPC__SYMBOL_H_
erpcgen::Symbol::printAnnotations
std::string printAnnotations()
This function returns description about annotation.
Definition: Type.cpp:62
erpcgen::Annotation
Annotation class.
Definition: Annotation.h:28
erpcgen::Symbol::getMlComment
std::string getMlComment()
This function returns multiline comment for this symbol declared in IDL file.
Definition: Symbol.h:242
erpcgen::Symbol::Symbol
Symbol(symbol_type_t symType)
Constructor.
Definition: Symbol.h:62
erpcgen::Symbol::m_ilComment
std::string m_ilComment
Definition: Symbol.h:271
erpcgen::Symbol::getFirstLine
int getFirstLine() const
This function return first line from location of symbol.
Definition: Symbol.h:153
erpcgen::Symbol::isBuiltin
virtual bool isBuiltin() const
This function return "false" value as default for identify builtin type.
Definition: Symbol.h:167
erpcgen::token_loc_t::m_lastLine
int m_lastLine
Definition: Token.h:29
erpcgen::Symbol::getAnnValue
Value * getAnnValue(const std::string annName, Annotation::program_lang_t lang)
This function search and returns Value object for given annotation name.
Definition: Type.cpp:109
erpcgen::Symbol::getAnnStringValue
std::string getAnnStringValue(const std::string annName, Annotation::program_lang_t lang)
This function search and returns string for given annotation name.
Definition: Type.cpp:115
erpcgen::Symbol::getAnnotations
const std::vector< Annotation > & getAnnotations() const
Return all Symbol annotations.
Definition: Symbol.h:215
erpcgen::Symbol::m_name
std::string m_name
Definition: Symbol.h:267
erpcgen::Symbol::Symbol
Symbol(symbol_type_t symType, const Token &tok)
Constructor.
Definition: Symbol.h:98
erpcgen::token_loc_t::m_firstLine
int m_firstLine
Definition: Token.h:27
erpcgen::Symbol::setLocation
void setLocation(const token_loc_t &loc)
This function set location for symbol.
Definition: Symbol.h:146
erpcgen::Symbol
Base class for all named declarations in the IDL.
Definition: Symbol.h:28
erpcgen::Symbol::getLocation
token_loc_t & getLocation()
This function returns location for symbol.
Definition: Symbol.h:139
erpcgen::Symbol::m_symbolType
symbol_type_t m_symbolType
Definition: Symbol.h:266
Value
Abstract base class for values of arbitrary types.
Definition: Value.h:27
erpcgen::Symbol::m_annotations
std::vector< Annotation > m_annotations
Definition: Symbol.h:269
erpcgen::Symbol::getIlComment
std::string getIlComment()
This function returns inline comment for this symbol declared in IDL file.
Definition: Symbol.h:256
erpcgen::Symbol::m_location
token_loc_t m_location
Definition: Symbol.h:268
erpcgen::Symbol::m_mlComment
std::string m_mlComment
Definition: Symbol.h:270
erpcgen::Symbol::getName
const std::string & getName() const
This function returns symbol name.
Definition: Symbol.h:125
erpcgen::Token
Encapsulates all information about a token.
Definition: Token.h:60
erpcgen::Symbol::getDescription
virtual std::string getDescription() const
This function returns description about the symbol (symbol name).
Definition: Symbol.h:174
erpcgen::Symbol::getLastLine
int getLastLine() const
This function return last line from location of symbol.
Definition: Symbol.h:160
erpcgen::Symbol::setIlComment
void setIlComment(std::string comment)
This function set inline comment for this symbol declared in IDL file.
Definition: Symbol.h:263
erpcgen::Symbol::getSymbolType
symbol_type_t getSymbolType() const
This function returns symbol type.
Definition: Symbol.h:118
erpcgen::Symbol::setMlComment
void setMlComment(std::string comment)
This function set multiline comment for this symbol declared in IDL file.
Definition: Symbol.h:249
erpcgen::Symbol::setName
void setName(const std::string &newName)
This function set symbol name.
Definition: Symbol.h:132
erpcgen::Symbol::findAnnotation
Annotation * findAnnotation(std::string name, Annotation::program_lang_t lang)
Find annotation in the annotation list.
Definition: Type.cpp:82
erpcgen::Symbol::~Symbol
virtual ~Symbol()
Destructor.
Definition: Symbol.h:111
erpcgen::token_loc_t
Token location in the source file.
Definition: Token.h:25
erpcgen::Symbol::addAnnotation
void addAnnotation(const Annotation &a)
This function add annotation to vector of symbol annotations.
Definition: Symbol.h:181
erpcgen::Symbol::symbol_type_t
symbol_type_t
Supported symbol types.
Definition: Symbol.h:34
erpcgen
Definition: AstNode.h:26
erpcgen::Symbol::Symbol
Symbol(symbol_type_t symType, const std::string &name)
Constructor.
Definition: Symbol.h:80