From 2b99d5f24d891b887338af863f78a84a7231a7c1 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Wed, 7 Nov 2012 20:12:18 +0100 Subject: simplified/cleaned up undo operations on value stack * special undo tokens are private to the ValueStack class and automatically parameterized * undo_push() and undo_pop() methods hide the internals of pushing the undo tokens --- expressions.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'expressions.cpp') diff --git a/expressions.cpp b/expressions.cpp index 38af2fc..6999312 100644 --- a/expressions.cpp +++ b/expressions.cpp @@ -28,7 +28,7 @@ Expressions::push(gint64 number) push(OP_NUMBER); - undo.push(new UndoTokenPop(numbers)); + numbers.undo_pop(); return numbers.push(number); } @@ -40,7 +40,7 @@ Expressions::pop_num(int index) pop_op(); if (numbers.items() > 0) { n = numbers.pop(index); - undo.push(new UndoTokenPush(numbers, n, index)); + numbers.undo_push(n, index); } return n; @@ -67,7 +67,7 @@ Expressions::add_digit(gchar digit) Expressions::Operator Expressions::push(Expressions::Operator op) { - undo.push(new UndoTokenPop(operators)); + operators.undo_pop(); return operators.push(op); } @@ -90,7 +90,7 @@ Expressions::pop_op(int index) if (operators.items() > 0) { op = operators.pop(index); - undo.push(new UndoTokenPush(operators, op, index)); + operators.undo_push(op, index); } return op; -- cgit v1.2.3