[gnome-calculator] GCalc: renamed Group to MathGroup
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator] GCalc: renamed Group to MathGroup
- Date: Thu, 17 Oct 2019 19:08:22 +0000 (UTC)
commit 5d58849d05bfb431f325662ae96b45f234577b16
Author: Daniel Espinosa <esodan gmail com>
Date: Thu Oct 17 11:53:52 2019 -0500
GCalc: renamed Group to MathGroup
gcalc/gcalc-ggroup.vala | 4 ++--
gcalc/{gcalc-group.vala => gcalc-math-group.vala} | 7 +++++--
gcalc/gcalc-parser.vala | 12 ++++++------
gcalc/gcalc-term.vala | 4 ++--
gcalc/meson.build | 2 +-
tests/gcalc-parsing.vala | 12 ++++++------
tests/gcalc-solving-basic.vala | 6 +++---
7 files changed, 25 insertions(+), 22 deletions(-)
---
diff --git a/gcalc/gcalc-ggroup.vala b/gcalc/gcalc-ggroup.vala
index 8b86f9d3..5684a13c 100644
--- a/gcalc/gcalc-ggroup.vala
+++ b/gcalc/gcalc-ggroup.vala
@@ -18,8 +18,8 @@
* Authors:
* Daniel Espinosa <esodan gmail com>
*/
-public class GCalc.GGroup : Expression, Group {
- internal Group.Level level { get; set; }
+public class GCalc.GGroup : Expression, MathGroup {
+ internal MathGroup.Level level { get; set; }
internal bool closed { get; set; }
internal override string to_string () {
string s = "";
diff --git a/gcalc/gcalc-group.vala b/gcalc/gcalc-math-group.vala
similarity index 91%
rename from gcalc/gcalc-group.vala
rename to gcalc/gcalc-math-group.vala
index ec7b8119..c93cd572 100644
--- a/gcalc/gcalc-group.vala
+++ b/gcalc/gcalc-math-group.vala
@@ -1,4 +1,4 @@
-/* gcalc-group.vala
+/* gcalc-math-group.vala
*
* Copyright (C) 2018 Daniel Espinosa <esodan gmail com>
*
@@ -18,7 +18,10 @@
* Authors:
* Daniel Espinosa <esodan gmail com>
*/
-public interface GCalc.Group : Object, MathExpression {
+/**
+ * A grouping math expression like parentesis
+ */
+public interface GCalc.MathGroup : Object, MathExpression {
public enum Level {
ONE,
TWO,
diff --git a/gcalc/gcalc-parser.vala b/gcalc/gcalc-parser.vala
index babb1609..1c67dd36 100644
--- a/gcalc/gcalc-parser.vala
+++ b/gcalc/gcalc-parser.vala
@@ -157,7 +157,7 @@ public class GCalc.Parser : Object {
current_parent.expressions.add (cexp);
expected.clear ();
current = cexp;
- } else if (current is Term && current_parent is MathPolynomial && (top_parent is Group ||
top_parent is MathFunction)) {
+ } else if (current is Term && current_parent is MathPolynomial && (top_parent is MathGroup ||
top_parent is MathFunction)) {
current.expressions.add (cexp);
top_parent = current_parent;
current_parent = current;
@@ -264,10 +264,10 @@ public class GCalc.Parser : Object {
bool foundp = false;
var par = current;
while (par != null) {
- if (par is Group) {
- if (!((Group) par).closed) {
+ if (par is MathGroup) {
+ if (!((MathGroup) par).closed) {
foundp = true;
- ((Group) par).closed = true;
+ ((MathGroup) par).closed = true;
break;
}
}
@@ -363,7 +363,7 @@ public class GCalc.Parser : Object {
current = opp;
current_parent = t;
expected.clear ();
- } else if ((current is Group || current is MathFunction) && current_parent is Term && top_parent is
MathPolynomial) {
+ } else if ((current is MathGroup || current is MathFunction) && current_parent is Term && top_parent is
MathPolynomial) {
// New term
var t = new GTerm ();
t.expressions.add (opp);
@@ -392,7 +392,7 @@ public class GCalc.Parser : Object {
if (current is MathOperator) {
throw new ParserError.INVALID_TOKEN_ERROR ("Found an unexpected expression for a multiply operator");
}
- if ((current is MathConstant || current is Variable || current is Group || current is MathFunction)
+ if ((current is MathConstant || current is Variable || current is MathGroup || current is MathFunction)
&& current_parent is Term && top_parent is MathPolynomial) {
current_parent.expressions.add (op);
current = op;
diff --git a/gcalc/gcalc-term.vala b/gcalc/gcalc-term.vala
index a2a8eadf..89f3a73d 100644
--- a/gcalc/gcalc-term.vala
+++ b/gcalc/gcalc-term.vala
@@ -56,8 +56,8 @@ public interface GCalc.Term : Object, MathExpression {
current = evaluate_constants ((MathConstant) current, (MathConstant) e, current_operator);
}
}
- } else if (e is Group) {
- var ev = ((Group) e).evaluate ();
+ } else if (e is MathGroup) {
+ var ev = ((MathGroup) e).evaluate ();
if (current == null) {
current = ev;
first = false;
diff --git a/gcalc/meson.build b/gcalc/meson.build
index 85024570..c07a3ec4 100644
--- a/gcalc/meson.build
+++ b/gcalc/meson.build
@@ -87,7 +87,6 @@ gcalc_sources = files([
'gcalc-gplus.vala',
'gcalc-gpow.vala',
'gcalc-gresult.vala',
- 'gcalc-group.vala',
'gcalc-ggroup.vala',
'gcalc-gsolver.vala',
'gcalc-gterm.vala',
@@ -102,6 +101,7 @@ gcalc_sources = files([
'gcalc-math-error-result.vala',
'gcalc-math-expression.vala',
'gcalc-math-function.vala',
+ 'gcalc-math-group.vala',
'gcalc-math-operator.vala',
'gcalc-math-polynomial.vala',
'gcalc-minus.vala',
diff --git a/tests/gcalc-parsing.vala b/tests/gcalc-parsing.vala
index 3557bd31..2de41f3c 100644
--- a/tests/gcalc-parsing.vala
+++ b/tests/gcalc-parsing.vala
@@ -525,7 +525,7 @@ class Tests {
var t = p.expressions.get_item (0) as Term;
assert (t != null);
assert (t.expressions.get_n_items () == 1);
- var g = t.expressions.get_item (0) as Group;
+ var g = t.expressions.get_item (0) as MathGroup;
assert (g != null);
assert (g.closed);
assert (g.expressions.get_n_items () == 1);
@@ -585,7 +585,7 @@ class Tests {
var t1 = p.expressions.get_item (0) as Term;
assert (t1 != null);
assert (t1.expressions.get_n_items () == 1);
- var g1 = t1.expressions.get_item (0) as Group;
+ var g1 = t1.expressions.get_item (0) as MathGroup;
assert (g1 != null);
assert (g1.closed);
assert (g1.expressions.get_n_items () == 1);
@@ -602,7 +602,7 @@ class Tests {
assert (t2.expressions.get_n_items () == 2);
var plus = t2.expressions.get_item (0) as Plus;
assert (plus != null);
- var g2 = t2.expressions.get_item (1) as Group;
+ var g2 = t2.expressions.get_item (1) as MathGroup;
assert (g2 != null);
assert (g2.closed);
assert (g2.expressions.get_n_items () == 1);
@@ -638,7 +638,7 @@ class Tests {
assert (c1 != null);
var m1 = t1.expressions.get_item (1) as Multiply;
assert (m1 != null);
- var g = t1.expressions.get_item (2) as Group;
+ var g = t1.expressions.get_item (2) as MathGroup;
assert (g != null);
assert (g.closed);
assert (g.expressions.get_n_items () == 1);
@@ -678,7 +678,7 @@ class Tests {
var t1 = p.expressions.get_item (0) as Term;
assert (t1 != null);
assert (t1.expressions.get_n_items () == 3);
- var g = t1.expressions.get_item (0) as Group;
+ var g = t1.expressions.get_item (0) as MathGroup;
assert (g != null);
assert (g.closed);
assert (g.expressions.get_n_items () == 1);
@@ -803,7 +803,7 @@ class Tests {
assert (c1 != null);
var pw = t.expressions.get_item (1) as Pow;
assert (pw != null);
- var g = t.expressions.get_item (2) as Group;
+ var g = t.expressions.get_item (2) as MathGroup;
assert (g != null);
assert (g.expressions.get_n_items () == 1);
var p1 = g.expressions.get_item (0) as MathPolynomial;
diff --git a/tests/gcalc-solving-basic.vala b/tests/gcalc-solving-basic.vala
index 5c3ce243..fb56d2dc 100644
--- a/tests/gcalc-solving-basic.vala
+++ b/tests/gcalc-solving-basic.vala
@@ -258,7 +258,7 @@ class Tests {
assert (e != null);
var t = e.expressions.get_item (0) as Term;
assert (t != null);
- var g = t.expressions.get_item (0) as Group;
+ var g = t.expressions.get_item (0) as MathGroup;
assert (g != null);
var res = g.evaluate () as MathConstant;
assert (res != null);
@@ -338,7 +338,7 @@ class Tests {
assert (e != null);
var t = e.expressions.get_item (0) as Term;
assert (t != null);
- var g = t.expressions.get_item (0) as Group;
+ var g = t.expressions.get_item (0) as MathGroup;
assert (g != null);
var res = g.evaluate () as MathConstant;
assert (res != null);
@@ -361,7 +361,7 @@ class Tests {
assert (e != null);
var t = e.expressions.get_item (0) as Term;
assert (t != null);
- var g = t.expressions.get_item (0) as Group;
+ var g = t.expressions.get_item (0) as MathGroup;
assert (g != null);
var res = g.evaluate () as MathConstant;
assert (res != null);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]