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

Carsten Bormann <cabo@tzi.org> Sun, 14 March 2021 21:29 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 97F903A15E1 for <cbor@ietfa.amsl.com>; Sun, 14 Mar 2021 14:29:59 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -6.919
X-Spam-Level:
X-Spam-Status: No, score=-6.919 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, 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 QfanAPxIrfFF for <cbor@ietfa.amsl.com>; Sun, 14 Mar 2021 14:29:56 -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 8DF563A15E0 for <cbor@ietf.org>; Sun, 14 Mar 2021 14:29:56 -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 4DzCPZ1Wz7zyWB; Sun, 14 Mar 2021 22:29:54 +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: Sun, 14 Mar 2021 22:29:53 +0100
Cc: cbor@ietf.org
X-Mao-Original-Outgoing-Id: 637450193.510119-7d803aec9759edde3e7fde617871bd9b
Content-Transfer-Encoding: quoted-printable
Message-Id: <22F7C719-8D3B-4CDA-A6F4-72128DD54EBE@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/lw2ZqsNzvg5QYXk-_JazhbCVk_E>
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: Sun, 14 Mar 2021 21:30:00 -0000

On 2021-03-14, at 22:08, Michael Richardson <mcr+ietf@sandelman.ca> wrote:
> 
> I looked through the cddl code, and I am not at all certain that CDDL has
> enough meta information about where the keys are used to be able to do this.
> I think that it's also possible to use the same key values in many places,
> and I even do this myself.

For each rule that defines a map, a tool could look at the keys used in that map and build a C enum from that.  This would require some conventions (i.e., the CDDL should look somewhat like yours), but it doesn’t sound too hard.

In my copious free time, I’ll see if I can hack this into the cddlc tool...

Grüße, Carsten