Skip to content

Commit

Permalink
Merge pull request #2 from cyberway/cyberway-abi
Browse files Browse the repository at this point in the history
Add Cyberway events support #1
  • Loading branch information
soft-bagel-93 authored Dec 4, 2019
2 parents 6b88630 + 74e992d commit 0d93b29
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/clang/AST/DeclCXX.h
Original file line number Diff line number Diff line change
Expand Up @@ -728,10 +728,12 @@ class CXXRecordDecl : public RecordDecl {
bool isEosioContract() const { return hasAttr<EosioContractAttr>(); }
bool isEosioAction() const { return hasAttr<EosioActionAttr>(); }
bool isEosioTable() const { return hasAttr<EosioTableAttr>(); }
bool isEosioEvent() const { return hasAttr<EosioEventAttr>(); }
bool isEosioIgnore() const { return hasAttr<EosioIgnoreAttr>(); }
bool hasEosioRicardian() const { return hasAttr<EosioRicardianAttr>(); }
EosioActionAttr* getEosioActionAttr() const { return getAttr<EosioActionAttr>(); }
EosioTableAttr* getEosioTableAttr() const { return getAttr<EosioTableAttr>(); }
EosioEventAttr* getEosioEventAttr() const { return getAttr<EosioEventAttr>(); }
EosioContractAttr* getEosioContractAttr() const { return getAttr<EosioContractAttr>(); }
EosioRicardianAttr* getEosioRicardianAttr() const { return getAttr<EosioRicardianAttr>(); }

Expand Down
8 changes: 8 additions & 0 deletions include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,14 @@ def EosioTable : InheritableAttr {
let Documentation = [EosioTableDocs];
}

def EosioEvent : InheritableAttr {
let Spellings = [CXX11<"eosio", "event">, GNU<"eosio_event">];
let Args = [StringArgument<"name", 1>];
let Subjects = SubjectList<[CXXRecord]>;
let MeaningfulToClassTemplateDefinition = 1;
let Documentation = [EosioEventDocs];
}

def CXX11NoReturn : InheritableAttr {
let Spellings = [CXX11<"", "noreturn", 200809>];
let Subjects = SubjectList<[Function], ErrorDiag>;
Expand Down
7 changes: 7 additions & 0 deletions include/clang/Basic/AttrDocs.td
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,13 @@ The ``eosio::table`` attribute marks a record as being an eosio table.
}];
}

def EosioEventDocs : Documentation {
let Category = DocCatFunction;
let Content = [{
The ``eosio::event`` attribute marks a record as being an eosio event.
}];
}

def NoSplitStackDocs : Documentation {
let Category = DocCatFunction;
let Content = [{
Expand Down
15 changes: 15 additions & 0 deletions lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,18 @@ static void handleEosioTableAttribute(Sema &S, Decl *D, const AttributeList &AL)
AL.getAttributeSpellingListIndex()));
}

static void handleEosioEventAttribute(Sema &S, Decl *D, const AttributeList &AL) {
// Handle the cases where the attribute has a text message.
StringRef Str, Replacement;
if (AL.isArgExpr(0) && AL.getArgAsExpr(0) &&
!S.checkStringLiteralArgumentAttr(AL, 0, Str))
return;

D->addAttr(::new (S.Context)
EosioEventAttr(AL.getRange(), S.Context, Str,
AL.getAttributeSpellingListIndex()));
}

/// Applies the given attribute to the Decl without performing any
/// additional semantic checking.
template <typename AttrType>
Expand Down Expand Up @@ -5931,6 +5943,9 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
case AttributeList::AT_EosioTable:
handleEosioTableAttribute(S, D, AL);
break;
case AttributeList::AT_EosioEvent:
handleEosioEventAttribute(S, D, AL);
break;
case AttributeList::AT_EosioWasmABI:
handleEosioABIAttribute(S, D, AL);
break;
Expand Down

0 comments on commit 0d93b29

Please sign in to comment.