From: Jay Freeman (saurik) Date: Fri, 8 Jun 2012 22:12:53 +0000 (-0700) Subject: Split CYLast into CYSetLast (eol) and CYGetLast. X-Git-Tag: v0.9.458~13 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/bf45251b6ef1230ffdbd79319b9c4a60c5ae6913?ds=inline Split CYLast into CYSetLast (eol) and CYGetLast. --- diff --git a/List.hpp b/List.hpp index f4762f2..6fd0731 100644 --- a/List.hpp +++ b/List.hpp @@ -42,15 +42,25 @@ struct CYNext { }; template -Type_ *&CYLast(Type_ *&list) { +Type_ *&CYSetLast(Type_ *&list) { if (list == NULL) return list; - else { - Type_ *next(list); - while (next->next_ != NULL) - next = next->next_; - return next->next_; - } + + Type_ *next(list); + while (next->next_ != NULL) + next = next->next_; + return next->next_; +} + +template +Type_ *CYGetLast(Type_ *list) { + if (list == NULL) + return NULL; + + Type_ *next(list); + while (next->next_ != NULL) + next = next->next_; + return next; } #define CYForEach(value, list) \ diff --git a/Parser.hpp b/Parser.hpp index 57dd993..c26e6d2 100644 --- a/Parser.hpp +++ b/Parser.hpp @@ -430,7 +430,7 @@ struct CYBlock : } void AddPrev(CYStatement *statement) { - CYLast(statement) = statements_; + CYSetLast(statement) = statements_; statements_ = statement; } @@ -619,7 +619,7 @@ struct CYCompound : } void AddPrev(CYExpression *expression) { - CYLast(expression) = expressions_; + CYSetLast(expression) = expressions_; expressions_ = expression; } diff --git a/Replace.cpp b/Replace.cpp index c70aab8..3e06308 100644 --- a/Replace.cpp +++ b/Replace.cpp @@ -513,7 +513,7 @@ namespace cy { namespace Syntax { CYExpression *New::AddArgument(CYContext &context, CYExpression *value) { - CYLast(arguments_) = $ CYArgument(value); + CYSetLast(arguments_) = $ CYArgument(value); return this; }