CCAN Archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: ccan@lists.ozlabs.org
Subject: [PATCHv2 0/6] tcon extensions for easier typesafe wrapping
Date: Thu, 22 Oct 2015 17:47:33 +1100	[thread overview]
Message-ID: <1445496459-2948-1-git-send-email-david@gibson.dropbear.id.au> (raw)

ccan includes many modules which use macro wrappers to make typesafe
pseudo-templated versions of a basic algorithm or data structure.

This series implements several extensions to the tcon module to enable
yet another approach to this.  The advantage of this new method is
that it's able to store a variety of "template" information into a
type or variable declaration.  That means that a module using this
technique can implement typesafe wrappers which can obtain the type
information they need from that initial declaration avoiding the need
to respecify types or field members in multiple places.

The last two patches in the series apply this approach to the lstack
and lqueue modules, giving them a nicer typesafe interface.

Changes since v1:
  * More macros to access the normal tcon options for the type
    canaries built into TCON_CONTAINER
  * Macro ti directly access to the offset stored in a TCON_CONTAINER
  * TCON_CONTAINER stores the type canaries as the type itself, rather
    than a pointer to it.  That matches the rest of tcon better, and
    plays nicer in conjuction with total_order_cast() from the order
    module.
  * Fixed the problem that broke ccanlint.  It was a ": " where there
    should have been a " - ".  Really.

David Gibson (6):
  tcon: Add an alternate way of building type canaries
  tcon: Add tcon_sizeof() helper
  tcon: Encode integer values into "type" canaries
  tcon: Encode information on container members in "type" canaries
  lstack: Streamline interface with TCON_CONTAINER
  lqueue: Streamline interface with TCON_CONTAINER

 ccan/aga/bfs.c                               |  18 +-
 ccan/aga/dfs.c                               |  18 +-
 ccan/lqueue/_info                            |   8 +-
 ccan/lqueue/lqueue.h                         | 154 ++++++++--------
 ccan/lqueue/test/run.c                       |  44 ++---
 ccan/lstack/_info                            |   8 +-
 ccan/lstack/lstack.h                         | 141 ++++++++-------
 ccan/lstack/test/run.c                       |  31 ++--
 ccan/tcon/_info                              |   5 +
 ccan/tcon/tcon.h                             | 252 +++++++++++++++++++++++++++
 ccan/tcon/test/compile_fail-container1.c     |  39 +++++
 ccan/tcon/test/compile_fail-container1w.c    |  35 ++++
 ccan/tcon/test/compile_fail-container2.c     |  39 +++++
 ccan/tcon/test/compile_fail-container2w.c    |  35 ++++
 ccan/tcon/test/compile_fail-container3.c     |  40 +++++
 ccan/tcon/test/compile_fail-container3w.c    |  36 ++++
 ccan/tcon/test/compile_fail-container4.c     |  40 +++++
 ccan/tcon/test/compile_fail-container4w.c    |  36 ++++
 ccan/tcon/test/compile_fail-tcon_cast_wrap.c |  25 +++
 ccan/tcon/test/compile_fail-wrap.c           |  20 +++
 ccan/tcon/test/compile_ok-sizeof.c           |  35 ++++
 ccan/tcon/test/compile_ok-value.c            |  51 ++++++
 ccan/tcon/test/compile_ok-void.c             |   6 +
 ccan/tcon/test/compile_ok.c                  |  11 ++
 ccan/tcon/test/run-container.c               |  59 +++++++
 ccan/tcon/test/run-wrap.c                    |  18 ++
 26 files changed, 1015 insertions(+), 189 deletions(-)
 create mode 100644 ccan/tcon/test/compile_fail-container1.c
 create mode 100644 ccan/tcon/test/compile_fail-container1w.c
 create mode 100644 ccan/tcon/test/compile_fail-container2.c
 create mode 100644 ccan/tcon/test/compile_fail-container2w.c
 create mode 100644 ccan/tcon/test/compile_fail-container3.c
 create mode 100644 ccan/tcon/test/compile_fail-container3w.c
 create mode 100644 ccan/tcon/test/compile_fail-container4.c
 create mode 100644 ccan/tcon/test/compile_fail-container4w.c
 create mode 100644 ccan/tcon/test/compile_fail-tcon_cast_wrap.c
 create mode 100644 ccan/tcon/test/compile_fail-wrap.c
 create mode 100644 ccan/tcon/test/compile_ok-sizeof.c
 create mode 100644 ccan/tcon/test/compile_ok-value.c
 create mode 100644 ccan/tcon/test/run-container.c
 create mode 100644 ccan/tcon/test/run-wrap.c

-- 
2.4.3

_______________________________________________
ccan mailing list
ccan@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/ccan

             reply	other threads:[~2015-10-22  6:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-22  6:47 David Gibson [this message]
2015-10-22  6:47 ` [PATCHv2 1/6] tcon: Add an alternate way of building type canaries David Gibson
2015-10-22  6:47 ` [PATCHv2 2/6] tcon: Add tcon_sizeof() helper David Gibson
2015-10-22  6:47 ` [PATCHv2 3/6] tcon: Encode integer values into "type" canaries David Gibson
2015-10-27  3:11   ` Rusty Russell
2015-10-27  6:17     ` David Gibson
2015-10-22  6:47 ` [PATCHv2 4/6] tcon: Encode information on container members in " David Gibson
2015-10-22  6:47 ` [PATCHv2 5/6] lstack: Streamline interface with TCON_CONTAINER David Gibson
2015-10-22  6:47 ` [PATCHv2 6/6] lqueue: " David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1445496459-2948-1-git-send-email-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=ccan@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).