From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: [PATCH 2/2] Add module functions to convert from and to big integers. Date: Tue, 23 Apr 2019 17:30:37 +0300 Message-ID: <83imv44wvm.fsf@gnu.org> References: <20190423131742.65814-1-phst@google.com> <20190423131742.65814-2-phst@google.com> Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="62837"; mail-complaints-to="usenet@blaine.gmane.org" Cc: phst@google.com, emacs-devel@gnu.org To: Philipp Stephani Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Apr 23 16:31:55 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hIwSh-000GGM-87 for ged-emacs-devel@m.gmane.org; Tue, 23 Apr 2019 16:31:55 +0200 Original-Received: from localhost ([127.0.0.1]:54670 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIwSg-0002ji-76 for ged-emacs-devel@m.gmane.org; Tue, 23 Apr 2019 10:31:54 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:45933) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIwRZ-0002TJ-Tu for emacs-devel@gnu.org; Tue, 23 Apr 2019 10:30:46 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:34358) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIwRZ-0001oe-FQ; Tue, 23 Apr 2019 10:30:45 -0400 Original-Received: from [176.228.60.248] (port=1199 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1hIwRX-0007fw-P1; Tue, 23 Apr 2019 10:30:44 -0400 In-reply-to: <20190423131742.65814-2-phst@google.com> (message from Philipp Stephani on Tue, 23 Apr 2019 15:17:42 +0200) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:235822 Archived-At: > From: Philipp Stephani > Date: Tue, 23 Apr 2019 15:17:42 +0200 > Cc: Philipp Stephani > > +@deftypefn Function bool extract_big_integer (emacs_env *@var{env}, emacs_value @var{arg}, int *@var{sign}, ptrdiff_t *@var{size}, unsigned char *@var{magnitude}) > +This function, which is available since Emacs 27, extracts the > +integral value of @var{arg}. If @var{sign} is not @code{NULL}, it > +stores the sign of @var{arg} (-1, 0, or +1) into @code{*sign}. The > +magnitude is stored into @var{magnitude} as follows. If @var{size} > +and @var{magnitude} are bot non-@code{NULL}, then @var{magnitude} must > +point to an array of at least @code{*size} bytes. If @var{magnitude} > +is large enough to hold the magnitude of @var{arg}, then this function > +writes the magnitude into the @var{magnitude} array in little-endian > +form, stores the number of bytes written into @code{*size}, and > +returns @code{true}. If @var{magnitude} is not large enough, it > +stores the required size into @code{*size}, signals an error, and > +returns @code{false}. If @var{size} is not @code{NULL} and > +@var{magnitude} is @code{NULL}, then the function stores the required > +size into @code{*size} and returns @code{true}. > +@end deftypefn I think this text should tell more about how magnitude is put into the MAGNITUDE array. I needed to look at the implementation to find the answer to that question. Since the caller will have to make sure the array is "large enough", I think the reader needs to know more about this than this text reveals. > +@deftypefn Function emacs_value make_big_integer (emacs_env *@var{env}, int sign, ptrdiff_t size, unsigned char *magnitude) > +This function, which is available since Emacs 27, takes an > +arbitrary-sized integer argument and returns a corresponding > +@code{emacs_value} object. Same here. In particular, the text mentions "integer argument", but it's unclear to what exactly that alludes, as there's no "argument" in the function's signature as shown. Thanks.