From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: taylanbayirli@gmail.com (Taylan Ulrich =?utf-8?Q?Bay=C4=B1rl=C4=B1?= =?utf-8?Q?=2FKammer?=) Newsgroups: gmane.lisp.guile.user Subject: Re: a foreign struct: a shameless request Date: Fri, 16 Jun 2017 21:02:08 +0200 Message-ID: <87wp8bsqmn.fsf@gmail.com> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1497639124 14092 195.159.176.226 (16 Jun 2017 18:52:04 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 16 Jun 2017 18:52:04 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) Cc: guile-user@gnu.org To: Catonano Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Jun 16 20:51:58 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dLwLd-0003H5-Qx for guile-user@m.gmane.org; Fri, 16 Jun 2017 20:51:57 +0200 Original-Received: from localhost ([::1]:60349 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLwLj-0002nf-2E for guile-user@m.gmane.org; Fri, 16 Jun 2017 14:52:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43348) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLwL9-0002mE-Vp for guile-user@gnu.org; Fri, 16 Jun 2017 14:51:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dLwL8-0003HB-VP for guile-user@gnu.org; Fri, 16 Jun 2017 14:51:28 -0400 Original-Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:33461) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dLwL8-0003Fn-Ob for guile-user@gnu.org; Fri, 16 Jun 2017 14:51:26 -0400 Original-Received: by mail-wm0-x243.google.com with SMTP id f90so6526642wmh.0 for ; Fri, 16 Jun 2017 11:51:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=p3fr3PMrVw2Uu0YKcA7y8ly75jJNUIZTNVNpfnvUISc=; b=gbJmRVeO4LkbJcfEAPTXl8XZF0ekf4bF2W0YQmDnNhWRI9h45kI49GaoqsxcWPVnbM IUCDMPejLdLFYdG0FN++nGY6OzP4y9lyKt1g8RVYfzRBCf04sw5pweR72lF1Znelsro/ TO3GoAwQdT0lSUGZWF5QFpiqRihWW8pg9OGtItE1koSQQWKd1O14/iQLwK5mqhDzCOZh MGFp76BJ41pUV6nLospgCLqDJ0rBV6eZHzsslD0t0XRAW71gM3JcGtfet0gbmyfAcgCM 78AOLEaiJBo22J9irosmm7sXp8KV0qn6c7n0Yy0VZ+mYnnLys3YkM1NsqvmQwlYgTI8U 424Q== 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:references:date:in-reply-to :message-id:user-agent:mime-version; bh=p3fr3PMrVw2Uu0YKcA7y8ly75jJNUIZTNVNpfnvUISc=; b=IY3wmumstzr5l7hjTOhTfDFNJMFNtg8zjuLEG/gM3mk0xp5vIHG7Q9eZ3dprkhLSHx nYIE6yexSEr+lov7FzJwm+ASK9cgngx1VavO4FZlQrj59jSc2zCMBNyJAGNzR9DR+RdB 0puXXOxPuK56Hl7FU9NrLp2GB/w3s/w4O4wcMyNO5EuHp11faGsagEbrScEPXE67zWj5 pDE1rGDZTETQAbIU0KOVZ+YpxTkMFe2c/g3/ApcE0dy+6x5IgKPvfj3JJwQPBUIDvBY7 f4czqKNdmoNX/565DdtC+DBZv4P2lKyjX+soaXe+9AQ+U4lGB72l3OE6MGpEhCPXssnu ESGg== X-Gm-Message-State: AKS2vOyQUKJmkkruBtMDiJf6YWhBwgKGHRGeNg38nywlLykKCuxrixvG eJHLjanYQhR5gpzD X-Received: by 10.28.5.198 with SMTP id 189mr8216373wmf.27.1497639083546; Fri, 16 Jun 2017 11:51:23 -0700 (PDT) Original-Received: from T420 ([2a02:908:c30:6ec0:221:ccff:fe66:68f0]) by smtp.gmail.com with ESMTPSA id p199sm1976514wme.9.2017.06.16.11.51.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 16 Jun 2017 11:51:22 -0700 (PDT) In-Reply-To: (catonano@gmail.com's message of "Fri, 16 Jun 2017 18:04:55 +0200") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::243 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:13842 Archived-At: Catonano writes: > I'd love to see a template of usage of a complex structure from scheme > That is, I'm asking for someone to write that template for me :-/ > > This is the foreign struct I have to deal with > > https://www.gaia-gis.it/gaia-sins/freexl-1.0.1-doxy-doc/html/structFreeXL__CellValue__str.html With bytestructures[0], this would be: (define freexl-cell-value (bs:struct `((type ,uint8) (value ,(bs:union `((int_value ,int) (double_value ,double) (text_value ,cstring-pointer))))))) If you decide to use bytestructures, feel free to e-mail me privately or use the GitHub issues system for questions. I don't actively monitor the Guile ML these days so I may miss your questions and feedback here. [0] https://github.com/TaylanUB/scheme-bytestructures/ HTH, Taylan > Particulary, I don't know how to treat the "union" thing > > A different union field gets populated on the basis of the type of the > content of the spreadsheet cell > > If the cell contains an integer number, then cell.int_value field gets > populated > > If the cell contains a double float number, then the cell.double_value > field gets populated > > And so on > > This is an excerpt from the example usage: > > switch (cell.type > > ) > { > case FREEXL_CELL_INT > > : > printf (", %d", cell.value > > .int_value > > ); > break; > ... > > How do I use "make-c-struct" and "parse-c-struct" with a structure like > this ? > > Thanks in advance