From bf45251b6ef1230ffdbd79319b9c4a60c5ae6913 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Fri, 8 Jun 2012 15:12:53 -0700 Subject: [PATCH] Split CYLast into CYSetLast (eol) and CYGetLast. --- List.hpp | 24 +++++++++++++++++------- Parser.hpp | 4 ++-- Replace.cpp | 2 +- 3 files changed, 20 insertions(+), 10 deletions(-) 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; } -- 2.49.0