[vala/0.42] vala: Add CodeNode.copy_attribute_*() helper methods
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.42] vala: Add CodeNode.copy_attribute_*() helper methods
- Date: Mon, 26 Nov 2018 09:11:52 +0000 (UTC)
commit eae25744d10eab39584d20d6273f9f3345c2caee
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Nov 8 12:45:24 2018 +0100
vala: Add CodeNode.copy_attribute_*() helper methods
Provides an easy way to copy a specific attribute argument from another
code node if the source has it set.
vala/valacodenode.vala | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
---
diff --git a/vala/valacodenode.vala b/vala/valacodenode.vala
index e8ab35725..e0320d02f 100644
--- a/vala/valacodenode.vala
+++ b/vala/valacodenode.vala
@@ -328,6 +328,70 @@ public abstract class Vala.CodeNode {
a.add_argument (argument, value.to_string ());
}
+ /**
+ * Copy the string value of the specified attribute argument if available.
+ *
+ * @param source codenode to copy from
+ * @param attribute attribute name
+ * @param argument argument name
+ * @return true if successful
+ */
+ public bool copy_attribute_string (CodeNode source, string attribute, string argument) {
+ if (source.has_attribute_argument (attribute, argument)) {
+ set_attribute_string (attribute, argument, source.get_attribute_string (attribute,
argument));
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Copy the integer value of the specified attribute argument if available.
+ *
+ * @param source codenode to copy from
+ * @param attribute attribute name
+ * @param argument argument name
+ * @return true if successful
+ */
+ public bool copy_attribute_integer (CodeNode source, string attribute, string argument) {
+ if (source.has_attribute_argument (attribute, argument)) {
+ set_attribute_integer (attribute, argument, source.get_attribute_integer (attribute,
argument));
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Copy the double value of the specified attribute argument if available.
+ *
+ * @param source codenode to copy from
+ * @param attribute attribute name
+ * @param argument argument name
+ * @return true if successful
+ */
+ public bool copy_attribute_double (CodeNode source, string attribute, string argument) {
+ if (source.has_attribute_argument (attribute, argument)) {
+ set_attribute_double (attribute, argument, source.get_attribute_double (attribute,
argument));
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Copy the boolean value of the specified attribute argument if available.
+ *
+ * @param source codenode to copy from
+ * @param attribute attribute name
+ * @param argument argument name
+ * @return true if successful
+ */
+ public bool copy_attribute_bool (CodeNode source, string attribute, string argument) {
+ if (source.has_attribute_argument (attribute, argument)) {
+ set_attribute_bool (attribute, argument, source.get_attribute_bool (attribute,
argument));
+ return true;
+ }
+ return false;
+ }
+
/**
* Returns the attribute cache at the specified index.
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]