From nobody Mon Feb 9 10:53:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1595856437; cv=none; d=zohomail.com; s=zohoarc; b=gxzYxqYLlKXMORt67sayYwCOa/zaQIXJYlMiRJ4yBmu/nLuiLqUbIoSdAvSmSdAO7xgjJqbXRO7OFiOpSnEyUyBt9LO6StYE+9QmaTkaizjkbikpnPjfXgWbF/rSLuMtm2OyUwONk7bM2kX+4dPc2FcLVkCVbx9pAmc+oGwINMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595856437; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=KaMEYjlDG3HM6TfMMDf5x6QCTVdKePy2b/fpNHgqtT4=; b=fQYtwtQaGUDLFVyGXBolzVdpnWY9LOq5bEy771jxh3esy2DYebdbHnwpatx2YwXaf5wppbM8uLSD6OVs/IkD5wpKFSdGEnUrFt8eo4ers7D8qE/cE7MGM/xrDGmM6F2zKmI0BGmulWdiPsyV79zFUdudJDq9rDDxcqZV4FZeWvg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1595856437243536.452198093143; Mon, 27 Jul 2020 06:27:17 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k039R-0001Vu-OC; Mon, 27 Jul 2020 13:26:45 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k039Q-0001Vb-Dz for xen-devel@lists.xenproject.org; Mon, 27 Jul 2020 13:26:44 +0000 Received: from mail-qk1-x72a.google.com (unknown [2607:f8b0:4864:20::72a]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id cde0e7a1-d00c-11ea-8abe-bc764e2007e4; Mon, 27 Jul 2020 13:26:40 +0000 (UTC) Received: by mail-qk1-x72a.google.com with SMTP id l23so15195448qkk.0 for ; Mon, 27 Jul 2020 06:26:40 -0700 (PDT) Received: from six.lan (cpe-67-241-56-252.twcny.res.rr.com. [67.241.56.252]) by smtp.gmail.com with ESMTPSA id t8sm11828003qtc.50.2020.07.27.06.26.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2020 06:26:38 -0700 (PDT) X-Inumbo-ID: cde0e7a1-d00c-11ea-8abe-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=KaMEYjlDG3HM6TfMMDf5x6QCTVdKePy2b/fpNHgqtT4=; b=AoNJiUMrGU1/zEcVI7rNtQsygstiui6pLZ/O79Gk45wErhqsFyZeXorPFU8EsqyGWv p3dmphPgk/gPAsY70nwA+zdMiOy36q17JfiR9hys2QwDiD1/WczxcuVHy1eg0ZZwTODP uKpv+ItSTW7lX1qDUMQYI0/s6Mkjp4XJTnmLr1EmfFLnTLTbMuJVzFbjx4KaR0iWlNWl 4dIPZWNhU03R7Fdj3emaHVlvP60qgEeNPjsStugzCN6ZkvksBHD7yQJRKL730/oVuzvr 99Rswo1yVL7OYds1gt68gcDN0aQ1dIRL6sQMNHZ4l1KO7/D5NdsF9Iq5ehHsyo7Luqk2 gFYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=KaMEYjlDG3HM6TfMMDf5x6QCTVdKePy2b/fpNHgqtT4=; b=A66FOtJ0mLQkqX1iU1mRXDQfn0ow25f/8tvWykOzalaQx6t5R/05lnTYmQuBQePKIK Fzrdvc1/Rx9sU3aXUXYqxiYieuCXtMdeHYNmD6DUUri/J9o5M+6M6D1oEYUtLWgFrAkg 5nkBRZLyMM9D08xbaXetiyoyI/EeQUURbYyChB7vb3X3fs/0NGqcTDXTfv/43WrcvtpT 4N8EAld5Jwr7R0IEG1cbvq+a0+VVftqIJxQYyp5myazoab8FhdjrXCt8yKzjKaHBsga/ BGqmCuw4X8VyF6eo4l+3ltnmbqQimmF6OxiqBTYRp/1655qe8WHF+aYVV1c1AoLJFcNM 5LPw== X-Gm-Message-State: AOAM530JEJ6Mc+r5rLur5H/d59hBuwi7Xke9ia8sIxxrI7xOUK/WbZBb AzUNJ/ETn7cZomdcGNLQjuZ9Cw2CBgA= X-Google-Smtp-Source: ABdhPJwh5q3SSQneLjUt5N34KQd0L5ewFAMB6FFOFYJbRJ4Fv2ddzOGdKpRH9TNoBLqx2vdusuMLTg== X-Received: by 2002:a05:620a:153c:: with SMTP id n28mr9178029qkk.285.1595856399792; Mon, 27 Jul 2020 06:26:39 -0700 (PDT) From: Nick Rosbrook X-Google-Original-From: Nick Rosbrook To: xen-devel@lists.xenproject.org Subject: [RFC PATCH 1/2] libxl: add Function class to IDL Date: Mon, 27 Jul 2020 09:26:32 -0400 Message-Id: <7e1774dffe69c702f738566abeb04a3a9d29e21b.1595854292.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Nick Rosbrook , Anthony PERARD , Ian Jackson , george.dunlap@citrix.com, Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a Function and CtxFunction classes to idl.py to allow generator scripts to generate wrappers which are repetitive and straight forward when doing so by hand. Examples of such functions are the device_add/remove functions. To start, a Function has attributes for namespace, name, parameters, return type, and an indication if the return value should be interpreted as a status code. The CtxFunction class extends this by indicating that a libxl_ctx is a required parmeter, and can optionally be an async function. Also, add logic to idl.parse to return the list of functions found in an IDL file. For now, have users of idl.py -- i.e. libxl/gentypes.py and golang/xenlight/gengotypes.py -- ignore the list of functions returned. Signed-off-by: Nick Rosbrook --- tools/golang/xenlight/gengotypes.py | 2 +- tools/libxl/gentypes.py | 2 +- tools/libxl/idl.py | 46 ++++++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/ge= ngotypes.py index 557fecd07b..bd3663c9ea 100644 --- a/tools/golang/xenlight/gengotypes.py +++ b/tools/golang/xenlight/gengotypes.py @@ -718,7 +718,7 @@ def xenlight_golang_fmt_name(name, exported =3D True): if __name__ =3D=3D '__main__': idlname =3D sys.argv[1] =20 - (builtins, types) =3D idl.parse(idlname) + (builtins, types, _) =3D idl.parse(idlname) =20 for b in builtins: name =3D b.typename diff --git a/tools/libxl/gentypes.py b/tools/libxl/gentypes.py index 9a45e45acc..ac7306f3f7 100644 --- a/tools/libxl/gentypes.py +++ b/tools/libxl/gentypes.py @@ -592,7 +592,7 @@ if __name__ =3D=3D '__main__': =20 (_, idlname, header, header_private, header_json, impl) =3D sys.argv =20 - (builtins,types) =3D idl.parse(idlname) + (builtins,types,_) =3D idl.parse(idlname) =20 print("outputting libxl type definitions to %s" % header) =20 diff --git a/tools/libxl/idl.py b/tools/libxl/idl.py index d7367503b4..1839871f86 100644 --- a/tools/libxl/idl.py +++ b/tools/libxl/idl.py @@ -347,6 +347,45 @@ class OrderedDict(dict): def ordered_items(self): return [(x,self[x]) for x in self.__ordered] =20 +class Function(object): + """ + A general description of a function signature. + + Attributes: + name (str): name of the function, excluding namespace. + params (list of (str,Type)): list of function parameters. + return_type (Type): the Type (if any), returned by the function. + return_is_status (bool): Indicates that the return value should be + interpreted as an error/status code. + """ + def __init__(self, name=3DNone, params=3DNone, return_type=3DNone, + return_is_status=3DFalse, namespace=3DNone): + + if namespace is None: + self.namespace =3D _get_default_namespace() + else: + self.namespace =3D namespace + + self.name =3D self.namespace + name + self.params =3D params + self.return_type =3D return_type + self.return_is_status =3D return_is_status + +class CtxFunction(Function): + """ + A function that requires a libxl_ctx. + + Attributes: + is_asyncop (bool): indicates that the function accepts a + libxl_asyncop_how parameter. + """ + def __init__(self, name=3DNone, params=3DNone, return_type=3DNone, + return_is_status=3DFalse, is_asyncop=3DFalse): + + self.is_asyncop =3D is_asyncop + + Function.__init__(self, name, params, return_type, return_is_statu= s) + def parse(f): print("Parsing %s" % f, file=3Dsys.stderr) =20 @@ -358,6 +397,10 @@ def parse(f): globs[n] =3D t elif isinstance(t,type(object)) and issubclass(t, Type): globs[n] =3D t + elif isinstance(t, Function): + globs[n] =3D t + elif isinstance(t,type(object)) and issubclass(t, Function): + globs[n] =3D t elif n in ['PASS_BY_REFERENCE', 'PASS_BY_VALUE', 'DIR_NONE', 'DIR_IN', 'DIR_OUT', 'DIR_BOTH', 'namespace', 'hidden']: @@ -370,8 +413,9 @@ def parse(f): % (e.lineno, f, e.text)) =20 types =3D [t for t in locs.ordered_values() if isinstance(t,Type)] + funcs =3D [f for f in locs.ordered_values() if isinstance(f,Function)] =20 builtins =3D [t for t in types if isinstance(t,Builtin)] types =3D [t for t in types if not isinstance(t,Builtin)] =20 - return (builtins,types) + return (builtins,types,funcs) --=20 2.17.1