[gnome-calculator] GCalc: renamed GErrorResult and ErrorResult to MathErrorResult and ErrorResult
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator] GCalc: renamed GErrorResult and ErrorResult to MathErrorResult and ErrorResult
- Date: Thu, 17 Oct 2019 19:08:17 +0000 (UTC)
commit 30946bba58267233a3ad83be1ad744d59cb37b20
Author: Daniel Espinosa <esodan gmail com>
Date: Thu Oct 17 11:47:44 2019 -0500
GCalc: renamed GErrorResult and ErrorResult to MathErrorResult and ErrorResult
gcalc/gcalc-assign.vala | 2 +-
gcalc/gcalc-error-result.vala | 20 +++++++++++++++++---
gcalc/gcalc-expression.vala | 2 +-
gcalc/gcalc-gmath-equation.vala | 4 ++--
gcalc/gcalc-gsolver.vala | 6 +++---
gcalc/gcalc-gterm.vala | 2 +-
...rror-result.vala => gcalc-math-error-result.vala} | 20 ++++++--------------
gcalc/gcalc-polynomial.vala | 2 +-
gcalc/meson.build | 4 ++--
9 files changed, 34 insertions(+), 28 deletions(-)
---
diff --git a/gcalc/gcalc-assign.vala b/gcalc/gcalc-assign.vala
index b456ca86..06620f9a 100644
--- a/gcalc/gcalc-assign.vala
+++ b/gcalc/gcalc-assign.vala
@@ -38,7 +38,7 @@ public class GCalc.Assign : Expression, MathOperator, MathBinaryOperator, MathAs
try {
res = new GResult (evaluate ());
} catch (GLib.Error e) {
- res = new GErrorResult ("Invalid expression in Assignment: %s".printf (e.message));
+ res = new ErrorResult ("Invalid expression in Assignment: %s".printf (e.message));
}
return res;
}
diff --git a/gcalc/gcalc-error-result.vala b/gcalc/gcalc-error-result.vala
index 365c3d54..70cbc02f 100644
--- a/gcalc/gcalc-error-result.vala
+++ b/gcalc/gcalc-error-result.vala
@@ -1,4 +1,4 @@
-/* gcalc-error-result.vala
+/* gcalc-gerror-result.vala
*
* Copyright (C) 2018 Daniel Espinosa <esodan gmail com>
*
@@ -18,7 +18,21 @@
* Authors:
* Daniel Espinosa <esodan gmail com>
*/
-public interface GCalc.ErrorResult : Object, Result {
- public abstract string message { get; }
+/**
+ * An implementation of {@link MathErrorResult}
+ */
+public class GCalc.ErrorResult : Object, Result, MathErrorResult {
+ private string msg = "";
+ private MathExpression _expression;
+
+ public ErrorResult (string msg) {
+ this.msg = msg;
+ _expression = new GErrorExpression ();
+ }
+ // Result
+ public MathExpression expression { get { return _expression; } }
+ public string to_string () { return msg; }
+ // ErrorResult
+ public string message { get { return msg; } }
}
diff --git a/gcalc/gcalc-expression.vala b/gcalc/gcalc-expression.vala
index f5b90fbf..764ebbe9 100644
--- a/gcalc/gcalc-expression.vala
+++ b/gcalc/gcalc-expression.vala
@@ -34,7 +34,7 @@ public class GCalc.Expression : Object, MathExpression {
return s;
}
internal virtual Result solve () {
- return new GErrorResult ("Invalid expression");
+ return new ErrorResult ("Invalid expression");
}
}
diff --git a/gcalc/gcalc-gmath-equation.vala b/gcalc/gcalc-gmath-equation.vala
index 2a94e88a..1136aea3 100644
--- a/gcalc/gcalc-gmath-equation.vala
+++ b/gcalc/gcalc-gmath-equation.vala
@@ -24,11 +24,11 @@ public class GCalc.GMathEquation : Expression, MathEquation {
internal override Result solve () {
Result res = null;
if (expressions.get_n_items () == 0) {
- return new GErrorResult ("No expressions found in equation");
+ return new ErrorResult ("No expressions found in equation");
}
var e = expressions.get_item (0) as MathExpression;
if (e == null) {
- res = new GErrorResult ("Invalid expression in equation");
+ res = new ErrorResult ("Invalid expression in equation");
} else {
res = e.solve ();
}
diff --git a/gcalc/gcalc-gsolver.vala b/gcalc/gcalc-gsolver.vala
index 6bcc83f8..7efd0398 100644
--- a/gcalc/gcalc-gsolver.vala
+++ b/gcalc/gcalc-gsolver.vala
@@ -32,15 +32,15 @@ public class GCalc.GSolver : Object, Solver {
try {
p.parse (str, equation_manager);
if (equation_manager.equations.get_n_items () == 0) {
- return new GErrorResult ("No equations found after parsing");
+ return new ErrorResult ("No equations found after parsing");
}
var eq = equation_manager.equations.get_item (0) as MathEquation;
if (eq == null) {
- return new GErrorResult ("No equations found after parsing");
+ return new ErrorResult ("No equations found after parsing");
}
res = eq.solve ();
} catch (GLib.Error e) {
- res = new GErrorResult ("Solving fails: %s".printf (e.message));
+ res = new ErrorResult ("Solving fails: %s".printf (e.message));
}
return res;
}
diff --git a/gcalc/gcalc-gterm.vala b/gcalc/gcalc-gterm.vala
index 9c7eaf72..599a114d 100644
--- a/gcalc/gcalc-gterm.vala
+++ b/gcalc/gcalc-gterm.vala
@@ -25,7 +25,7 @@ public class GCalc.GTerm : Expression, Term {
var e = evaluate ();
res = new GResult (e) as Result;
} catch (GLib.Error err) {
- res = new GErrorResult ("Term evaluation fails: %s".printf (err.message));
+ res = new ErrorResult ("Term evaluation fails: %s".printf (err.message));
}
return res;
}
diff --git a/gcalc/gcalc-gerror-result.vala b/gcalc/gcalc-math-error-result.vala
similarity index 63%
rename from gcalc/gcalc-gerror-result.vala
rename to gcalc/gcalc-math-error-result.vala
index 92b9bd53..0c93bab0 100644
--- a/gcalc/gcalc-gerror-result.vala
+++ b/gcalc/gcalc-math-error-result.vala
@@ -1,4 +1,4 @@
-/* gcalc-gerror-result.vala
+/* gcalc-error-result.vala
*
* Copyright (C) 2018 Daniel Espinosa <esodan gmail com>
*
@@ -18,18 +18,10 @@
* Authors:
* Daniel Espinosa <esodan gmail com>
*/
-public class GCalc.GErrorResult : Object, Result, ErrorResult {
- private string msg = "";
- private MathExpression _expression;
-
- public GErrorResult (string msg) {
- this.msg = msg;
- _expression = new GErrorExpression ();
- }
- // Result
- public MathExpression expression { get { return _expression; } }
- public string to_string () { return msg; }
- // ErrorResult
- public string message { get { return msg; } }
+/**
+ * A kind of result returned when there was an error in a solving operation
+ */
+public interface GCalc.MathErrorResult : Object, Result {
+ public abstract string message { get; }
}
diff --git a/gcalc/gcalc-polynomial.vala b/gcalc/gcalc-polynomial.vala
index f41289f6..b012b343 100644
--- a/gcalc/gcalc-polynomial.vala
+++ b/gcalc/gcalc-polynomial.vala
@@ -25,7 +25,7 @@ public class GCalc.Polynomial : Expression, MathPolynomial {
var e = evaluate ();
res = new GResult (e) as Result;
} catch (GLib.Error err) {
- res = new GErrorResult ("Polynomial solving fails: %s".printf (err.message));
+ res = new ErrorResult ("Polynomial solving fails: %s".printf (err.message));
}
return res;
}
diff --git a/gcalc/meson.build b/gcalc/meson.build
index f101f4b1..85024570 100644
--- a/gcalc/meson.build
+++ b/gcalc/meson.build
@@ -59,6 +59,7 @@ gcalc_sources = files([
'gcalc-assign.vala',
'gcalc-constant.vala',
'gcalc-division.vala',
+ 'gcalc-error-result.vala',
'gcalc-expression.vala',
'gcalc-expression-container.vala',
'gcalc-expression-hash-map.vala',
@@ -78,8 +79,6 @@ gcalc_sources = files([
'gcalc-function-sqrt.vala',
'gcalc-function-tan.vala',
'gcalc-function-tanh.vala',
- 'gcalc-error-result.vala',
- 'gcalc-gerror-result.vala',
'gcalc-gmath-equation.vala',
'gcalc-gmath-equation-manager.vala',
'gcalc-gminus.vala',
@@ -100,6 +99,7 @@ gcalc_sources = files([
'gcalc-math-division.vala',
'gcalc-math-equation.vala',
'gcalc-math-equation-manager.vala',
+ 'gcalc-math-error-result.vala',
'gcalc-math-expression.vala',
'gcalc-math-function.vala',
'gcalc-math-operator.vala',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]