Re: [Cbor] building "enum" from CDDL map keys

Carsten Bormann <cabo@tzi.org> Mon, 15 March 2021 10:44 UTC

Return-Path: <cabo@tzi.org>
X-Original-To: cbor@ietfa.amsl.com
Delivered-To: cbor@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 429AF3A0BBA for <cbor@ietfa.amsl.com>; Mon, 15 Mar 2021 03:44:29 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.219
X-Spam-Level:
X-Spam-Status: No, score=-4.219 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PUgjijDwL2aq for <cbor@ietfa.amsl.com>; Mon, 15 Mar 2021 03:44:27 -0700 (PDT)
Received: from gabriel-vm-2.zfn.uni-bremen.de (gabriel-vm-2.zfn.uni-bremen.de [134.102.50.17]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id D1AF63A0BB2 for <cbor@ietf.org>; Mon, 15 Mar 2021 03:44:26 -0700 (PDT)
Received: from [192.168.217.118] (p5089a828.dip0.t-ipconnect.de [80.137.168.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gabriel-vm-2.zfn.uni-bremen.de (Postfix) with ESMTPSA id 4DzY2K1LkQzyZ5; Mon, 15 Mar 2021 11:44:25 +0100 (CET)
Content-Type: text/plain; charset=utf-8
Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <1301.1615756133@localhost>
Date: Mon, 15 Mar 2021 11:44:24 +0100
Cc: cbor@ietf.org
X-Mao-Original-Outgoing-Id: 637497864.573733-5d7cb09320b3e178cbc09b324805cb77
Content-Transfer-Encoding: quoted-printable
Message-Id: <D0440CFA-7295-46C3-8B38-C2755DAB314A@tzi.org>
References: <1301.1615756133@localhost>
To: Michael Richardson <mcr+ietf@sandelman.ca>
X-Mailer: Apple Mail (2.3608.120.23.2.4)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/awOqN4rexMuUCk8UGROlV_7NumE>
Subject: Re: [Cbor] building "enum" from CDDL map keys
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <cbor.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cbor>, <mailto:cbor-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor/>
List-Post: <mailto:cbor@ietf.org>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cbor>, <mailto:cbor-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 15 Mar 2021 10:44:29 -0000

On 2021-03-14, at 22:08, Michael Richardson <mcr+ietf@sandelman.ca> wrote:
> 
> 
>  enum whack_message_keys {
>     WHACK_STATUS = 1,
>     WHACK_SHUTDOWN=2,
>     WHACK_OPTIONS =3,
>     WHACK_CONNECTION=4
>     ...
>  };

cddlc 0.0.2 can do this:

$ cddlc -tenum test-data/whack.cddl
enum whack_message_keys {
  WHACK_STATUS = 1,
  WHACK_SHUTDOWN = 2,
  WHACK_OPTIONS = 3,
  WHACK_CONNECTION = 4,
};

I’m not sure whether keeping the key names undecorated is OK in all cases, but that’s maybe for a 0.0.3.

As usual,

	gem update cddlc

or
	gem install cddlc

if you haven’t used it before).

This is a banana version (it is intended to ripen after shipping), but it seems to work for me.

Grüße, Carsten