[PATCH] osmo-ttcn3-hacks[master]: Osmocom_Types: Add bool2bit() and bool2bit_templ()

Harald Welte gerrit-no-reply at lists.osmocom.org
Fri Feb 16 17:43:57 UTC 2018


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/6527

to look at the new patch set (#3).

Osmocom_Types: Add bool2bit() and bool2bit_templ()

Those can be very handy to convert boolean values and templates
to the BIT1 type that is used a lot in Ericsson code.

Change-Id: I137595edabd2bbf5e6cf8bf9bdb73b3589c94c64
---
M library/Osmocom_Types.ttcn
1 file changed, 29 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/27/6527/3

diff --git a/library/Osmocom_Types.ttcn b/library/Osmocom_Types.ttcn
index a748bbc..a736e95 100644
--- a/library/Osmocom_Types.ttcn
+++ b/library/Osmocom_Types.ttcn
@@ -1,4 +1,7 @@
 module Osmocom_Types {
+
+	import from General_Types all;
+
 	type integer uint8_t (0..255) with { variant "unsigned 8 bit" };
 	type integer uint16_t (0..65535) with { variant "unsigned 16 bit" };
 	type integer uint24_t (0..16777215) with { variant "unsigned 24 bit" };
@@ -66,4 +69,30 @@
 		T.timeout;
 	}
 
+function bool2bit(boolean inp) return BIT1 {
+	if (inp) {
+		return '1'B;
+	} else {
+		return '0'B;
+	}
+}
+
+function bool2bit_tmpl(template boolean inp) return template BIT1 {
+	if (istemplatekind(inp, "omit")) {
+		return omit;
+	} else if (istemplatekind(inp, "*")) {
+		return *;
+	} else if (istemplatekind(inp, "?")) {
+	} else {
+		if (valueof(inp)) {
+			return '1'B;
+		} else {
+			return '0'B;
+		}
+	}
+	setverdict(fail, "Unsupported template");
+	self.stop;
+}
+
+
 } with { encode "RAW"; variant "FIELDORDER(msb)" }

-- 
To view, visit https://gerrit.osmocom.org/6527
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I137595edabd2bbf5e6cf8bf9bdb73b3589c94c64
Gerrit-PatchSet: 3
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder


More information about the gerrit-log mailing list