From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bruce Korb Newsgroups: gmane.lisp.guile.devel Subject: Re: Getting source location information Date: Wed, 30 Nov 2005 12:53:50 -0800 Organization: At Home Message-ID: <200511301253.50840.bruce.korb@gmail.com> References: <200511272025.32395.bruce.korb@gmail.com> <87psoixgtv.fsf@laas.fr> <87hd9uezaa.fsf@trouble.defaultvalue.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1133384115 20242 80.91.229.2 (30 Nov 2005 20:55:15 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 30 Nov 2005 20:55:15 +0000 (UTC) Cc: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Nov 30 21:55:13 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EhYxm-0004VD-Q4 for guile-devel@m.gmane.org; Wed, 30 Nov 2005 21:54:03 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EhYxm-0002jr-1C for guile-devel@m.gmane.org; Wed, 30 Nov 2005 15:54:02 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EhYxf-0002jE-CE for guile-devel@gnu.org; Wed, 30 Nov 2005 15:53:55 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EhYxd-0002ir-UT for guile-devel@gnu.org; Wed, 30 Nov 2005 15:53:55 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EhYxd-0002io-P7 for guile-devel@gnu.org; Wed, 30 Nov 2005 15:53:53 -0500 Original-Received: from [207.115.57.74] (helo=ylpvm43.prodigy.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EhYxd-0000sX-TM for guile-devel@gnu.org; Wed, 30 Nov 2005 15:53:54 -0500 Original-Received: from pimout1-ext.prodigy.net (pimout1-int.prodigy.net [207.115.5.65]) by ylpvm43.prodigy.net (8.12.10 outbound/8.12.10) with ESMTP id jAUKrs2E019189 for ; Wed, 30 Nov 2005 15:53:55 -0500 X-ORBL: [69.226.209.231] Original-Received: from [192.168.1.4] (adsl-69-226-209-231.dsl.pltn13.pacbell.net [69.226.209.231]) by pimout1-ext.prodigy.net (8.13.4 outbound domainkey aix/8.13.4) with ESMTP id jAUKrnJt019026; Wed, 30 Nov 2005 15:53:50 -0500 Original-To: Rob Browning User-Agent: KMail/1.7.1 In-Reply-To: <87hd9uezaa.fsf@trouble.defaultvalue.org> Content-Disposition: inline X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:5437 Archived-At: On Wednesday 30 November 2005 11:00 am, Rob Browning wrote: > If so, then I wondered if it might be possible to just implement the > function mentioned originally > i.e. ag_scm_c_eval_string_from_file_line, and here's what I came up > with. Note that I have no idea if this will actually work; I haven't > tested it, and I don't know the semantics of the port related > filename, line, and column bits offhand. > > (define (eval-port port) > ;; See strports.c inner_eval_string for similar code. > (let loop ((next-form (read port)) > (any-read? #f) > (result #f)) > (if (eof-object? next-form) > (if any-read? result) > (loop (read port) > #t > (primitive-eval next-form))))) > > (define (eval-string-from-file str filename line column) > (call-with-input-string str > (lambda (port) > (set-port-filename! port filename) > (set-port-line! port line) > (set-port-column! port column) > (eval-port port)))) With the final piece being the C code: SCM proc = scm_c_eval_string ("eval-string-from-file"); SCM str = scm_from_locale_string (scheme_text); SCM file = scm_from_locale_string (file_name); SCM line = scm_from_int (line_no); SCM res = scm_call_3 (proc, str, file, line); // Let's forget columns -- we don't have scm_call_4. Actually, I might as well create the port in C and invoke "eval-port" directly. I could easily set the column number, too. (If I were tracking it.) I'll give this a spin and let you know if it works shortly (a day or two). Thank you. (I still think adding it to libguile would not hurt.) Regards, Bruce _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel