[gnome-calculator] GCalc: renamed Function to MathFunction
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator] GCalc: renamed Function to MathFunction
- Date: Thu, 17 Oct 2019 19:08:02 +0000 (UTC)
commit b50dcccca1f048576cfb00f3bec38b1f2f088c6c
Author: Daniel Espinosa <esodan gmail com>
Date: Thu Oct 17 11:32:57 2019 -0500
GCalc: renamed Function to MathFunction
gcalc/gcalc-expression-container.vala | 2 +-
gcalc/gcalc-gfunction.vala | 2 +-
gcalc/{gcalc-function.vala => gcalc-math-function.vala} | 4 ++--
gcalc/gcalc-parser.vala | 16 ++++++++--------
gcalc/gcalc-term.vala | 4 ++--
gcalc/meson.build | 2 +-
tests/gcalc-parsing.vala | 4 ++--
tests/gcalc-solving-basic.vala | 2 +-
8 files changed, 18 insertions(+), 18 deletions(-)
---
diff --git a/gcalc/gcalc-expression-container.vala b/gcalc/gcalc-expression-container.vala
index a3e82c1e..0d4fdfec 100644
--- a/gcalc/gcalc-expression-container.vala
+++ b/gcalc/gcalc-expression-container.vala
@@ -79,7 +79,7 @@ public class GCalc.ExpressionContainer : Gee.ArrayList<MathExpression>, GLib.Lis
if (e is Variable && ((Variable) e).name == name) {
return e;
}
- if (e is Function && ((Function) e).name == name) {
+ if (e is MathFunction && ((MathFunction) e).name == name) {
return e;
}
}
diff --git a/gcalc/gcalc-gfunction.vala b/gcalc/gcalc-gfunction.vala
index 558da0f9..86c74936 100644
--- a/gcalc/gcalc-gfunction.vala
+++ b/gcalc/gcalc-gfunction.vala
@@ -18,7 +18,7 @@
* Authors:
* Daniel Espinosa <esodan gmail com>
*/
-public class GCalc.GFunction : Expression, Function, Hashable {
+public class GCalc.GFunction : Expression, MathFunction, Hashable {
ExpressionContainer _param_types = new ExpressionContainer ();
internal ExpressionContainer param_types { get { return _param_types; } }
diff --git a/gcalc/gcalc-function.vala b/gcalc/gcalc-math-function.vala
similarity index 96%
rename from gcalc/gcalc-function.vala
rename to gcalc/gcalc-math-function.vala
index 3420c27f..0363b20f 100644
--- a/gcalc/gcalc-function.vala
+++ b/gcalc/gcalc-math-function.vala
@@ -1,4 +1,4 @@
-/* gcalc-function.vala
+/* gcalc-math-function.vala
*
* Copyright (C) 2018 Daniel Espinosa <esodan gmail com>
*
@@ -21,7 +21,7 @@
/**
* A Function as part of a {@link MathExpression}
*/
-public interface GCalc.Function : Object, MathExpression {
+public interface GCalc.MathFunction : Object, MathExpression {
/**
* Parameters used by the function, objects representing
* the expected types. See {@link verify_params}
diff --git a/gcalc/gcalc-parser.vala b/gcalc/gcalc-parser.vala
index cac2b1f0..babb1609 100644
--- a/gcalc/gcalc-parser.vala
+++ b/gcalc/gcalc-parser.vala
@@ -95,7 +95,7 @@ public class GCalc.Parser : Object {
}
} else if (n.down () == "def" && current == null) {
// FIXME: implement function definition
- } else if (n.down () == "def" && current is Function) {
+ } else if (n.down () == "def" && current is MathFunction) {
throw new ParserError.INVALID_TOKEN_ERROR ("Found an unexpected function definition expression");
} else {
var v = new GVariable (n) as MathExpression;
@@ -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 Function)) {
+ } else if (current is Term && current_parent is MathPolynomial && (top_parent is Group ||
top_parent is MathFunction)) {
current.expressions.add (cexp);
top_parent = current_parent;
current_parent = current;
@@ -236,7 +236,7 @@ public class GCalc.Parser : Object {
current = t2;
current_parent = exp2;
top_parent = g;
- } else if (current is Function) {
+ } else if (current is MathFunction) {
var fexp = new Polynomial ();
var t = new GTerm ();
fexp.expressions.add (t);
@@ -271,10 +271,10 @@ public class GCalc.Parser : Object {
break;
}
}
- if (par is Function) {
- if (!((Function) par).closed) {
+ if (par is MathFunction) {
+ if (!((MathFunction) par).closed) {
foundp = true;
- ((Function) par).closed = true;
+ ((MathFunction) 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 Function) && current_parent is Term && top_parent is
MathPolynomial) {
+ } else if ((current is Group || 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 Function)
+ if ((current is MathConstant || current is Variable || current is Group || 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 4391e2af..a2a8eadf 100644
--- a/gcalc/gcalc-term.vala
+++ b/gcalc/gcalc-term.vala
@@ -66,8 +66,8 @@ public interface GCalc.Term : Object, MathExpression {
current = evaluate_constants ((MathConstant) current, (MathConstant) ev, current_operator);
}
}
- } else if (e is Function) {
- var ev = ((Function) e).evaluate ();
+ } else if (e is MathFunction) {
+ var ev = ((MathFunction) e).evaluate ();
if (current == null) {
current = ev;
first = false;
diff --git a/gcalc/meson.build b/gcalc/meson.build
index 3bfef9f0..363fcc73 100644
--- a/gcalc/meson.build
+++ b/gcalc/meson.build
@@ -62,7 +62,6 @@ gcalc_sources = files([
'gcalc-expression.vala',
'gcalc-expression-container.vala',
'gcalc-expression-hash-map.vala',
- 'gcalc-function.vala',
'gcalc-function-acos.vala',
'gcalc-function-acosh.vala',
'gcalc-function-asin.vala',
@@ -102,6 +101,7 @@ gcalc_sources = files([
'gcalc-math-equation.vala',
'gcalc-math-equation-manager.vala',
'gcalc-math-expression.vala',
+ 'gcalc-math-function.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 6ee9df96..3557bd31 100644
--- a/tests/gcalc-parsing.vala
+++ b/tests/gcalc-parsing.vala
@@ -742,7 +742,7 @@ class Tests {
var t = p.expressions.get_item (0) as Term;
assert (t != null);
assert (t.expressions.get_n_items () == 1);
- var f = t.expressions.get_item (0) as Function;
+ var f = t.expressions.get_item (0) as MathFunction;
assert (f != null);
assert (f.expressions.get_n_items () == 1);
var p1 = f.expressions.get_item (0) as MathPolynomial;
@@ -868,7 +868,7 @@ class Tests {
assert (c2 != null);
var m2 = t1.expressions.get_item (3) as Multiply;
assert (m2 != null);
- var f1 = t1.expressions.get_item (4) as Function;
+ var f1 = t1.expressions.get_item (4) as MathFunction;
assert (f1 != null);
var t2 = e.expressions.get_item (1) as Term;
assert (t2 != null);
diff --git a/tests/gcalc-solving-basic.vala b/tests/gcalc-solving-basic.vala
index 2c949ce5..a2c1950e 100644
--- a/tests/gcalc-solving-basic.vala
+++ b/tests/gcalc-solving-basic.vala
@@ -689,7 +689,7 @@ class Tests {
assert (e != null);
var t = e.expressions.get_item (0) as Term;
assert (t != null);
- var f = t.expressions.get_item (0) as Function;
+ var f = t.expressions.get_item (0) as MathFunction;
assert (f != null);
assert (f.closed);
var res = f.evaluate () as MathConstant;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]