From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stephen Leake Newsgroups: gmane.emacs.devel Subject: Re: implementing curl module with opaque emacs types Date: Tue, 17 Feb 2015 13:33:33 -0600 Message-ID: <85fva48h9u.fsf@stephe-leake.org> References: <838ugdf251.fsf@gnu.org> <54D80098.3020209@cs.ucla.edu> <54D85304.1030600@cs.ucla.edu> <54D9AC29.2020603@cs.ucla.edu> <54DA8539.1020905@cs.ucla.edu> <87zj8ktq8f.fsf@lifelogs.com> <54DD6413.1000403@cs.ucla.edu> <83wq3m436s.fsf@gnu.org> <834mqowbnh.fsf@gnu.org> <85egpsgf5z.fsf@stephe-leake.org> <83oaovull2.fsf@gnu.org> <85y4nzat5m.fsf@stephe-leake.org> <85egprasb7.fsf_-_@stephe-leake.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1424201776 4700 80.91.229.3 (17 Feb 2015 19:36:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 17 Feb 2015 19:36:16 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Feb 17 20:36:06 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YNnwE-0006Hd-0O for ged-emacs-devel@m.gmane.org; Tue, 17 Feb 2015 20:36:06 +0100 Original-Received: from localhost ([::1]:47065 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNnwD-0003kH-G7 for ged-emacs-devel@m.gmane.org; Tue, 17 Feb 2015 14:36:05 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNnvH-00037u-8b for emacs-devel@gnu.org; Tue, 17 Feb 2015 14:35:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YNnvE-00033e-2w for emacs-devel@gnu.org; Tue, 17 Feb 2015 14:35:07 -0500 Original-Received: from gproxy7-pub.mail.unifiedlayer.com ([70.40.196.235]:49012) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1YNnvD-0002y6-N3 for emacs-devel@gnu.org; Tue, 17 Feb 2015 14:35:03 -0500 Original-Received: (qmail 3403 invoked by uid 0); 17 Feb 2015 19:34:57 -0000 Original-Received: from unknown (HELO cmgw2) (10.0.90.83) by gproxy7.mail.unifiedlayer.com with SMTP; 17 Feb 2015 19:34:57 -0000 Original-Received: from host114.hostmonster.com ([74.220.207.114]) by cmgw2 with id tXZg1p0152UdiVW01XZjkj; Tue, 17 Feb 2015 12:33:44 -0700 X-Authority-Analysis: v=2.1 cv=NPZGpSKg c=1 sm=1 tr=0 a=CQdxDb2CKd3SRg4I0/XZPQ==:117 a=CQdxDb2CKd3SRg4I0/XZPQ==:17 a=DsvgjBjRAAAA:8 a=f5113yIGAAAA:8 a=TeMFXEv2S7AA:10 a=9i_RQKNPAAAA:8 a=hEr_IkYJT6EA:10 a=jrwKn-8xaegA:10 a=0HtSIViG9nkA:10 a=yxiwwc8xzzuXz15hk-QA:9 a=G2VCdyPZR-KgIj9sLokA:9 Original-Received: from [70.94.38.149] (port=53504 helo=takver) by host114.hostmonster.com with esmtpsa (TLSv1.2:AES128-GCM-SHA256:128) (Exim 4.82) (envelope-from ) id 1YNnts-0001pi-FQ for emacs-devel@gnu.org; Tue, 17 Feb 2015 12:33:40 -0700 In-Reply-To: <85egprasb7.fsf_-_@stephe-leake.org> (Stephen Leake's message of "Sun, 15 Feb 2015 13:27:40 -0600") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (windows-nt) X-Identified-User: {2442:host114.hostmonster.com:stephele:stephe-leake.org} {sentby:smtp auth 70.94.38.149 authed with stephen_leake@stephe-leake.org} X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 70.40.196.235 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:183210 Archived-At: --=-=-= Content-Type: text/plain Stephen Leake writes: > Stephen Leake writes: > >> So let's take a stab at something closer to your approach. >> >> I'm not familiar with the idioms for making an opaque type in C; would >> that just be a pointer to void? something like: >> >> typedef void* Lisp_Object_Ptr; > > Here is the list of Emacs functions that curl.c currently uses > > Fprovide > SSDATA > XSAVE_POINTER > builtin_lisp_symbol (for Qnil) > defsubr > intern > make_string > > We can either implement these in a new version of emacs_module_api.h/.c, > or rewrite curl.c to not use them. Attached is a first attempt at emacs_module_api.h for this. The only change in curl.c is: -#include -#include +/* #include */ +/* #include */ +#include "emacs_modules_api.h" This gives compilation errors: curl.c: In function 'init': curl.c:113:13: error: 'Scurl_make' undeclared (first use in this function) defsubr (&Scurl_make); ^ curl.c:113:13: note: each undeclared identifier is reported only once for each function it appears in curl.c:114:13: error: 'Scurl_fetch_url' undeclared (first use in this function) defsubr (&Scurl_fetch_url); ^ curl.c:115:13: error: 'Scurl_content' undeclared (first use in this function) defsubr (&Scurl_content); ^ curl.c:116:13: error: 'Scurl_free' undeclared (first use in this function) defsubr (&Scurl_free); ^ Makefile:14: recipe for target 'curl.o' failed This is because I deleted the declaration of 'sname' from the DEFUN macro, because I couldn't figure out how to implement it simply. It seems EXFUN is redundant with the first part of DEFUN, so I'm not sure why the EXFUN statments are in curl.c. So we either need a lisp wrapper to declare the module functions, with some way to lookup the EXFUN symbols to set the function values, or we need to implement a C function (not macro) that creates the struct for defsubr. -- -- Stephe --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=emacs_modules_api.h Content-Transfer-Encoding: base64 LyogRW1hY3MgbW9kdWxlcyBBUEkgKi8KCiNpZmRlZiBXSU5ET1dTTlQKIyBpZmRlZiBlbWFjcwog ICAvKiBjb21waWxpbmcgZW1hY3MgKi8KIyAgZGVmaW5lIEVNQUNTX0VYUE9SVCAgX19kZWNsc3Bl YyhkbGxleHBvcnQpCiMgZWxzZQogICAvKiBjb21waWxpbmcgYSBtb2R1bGUgKi8KIyAgZGVmaW5l IEVNQUNTX0VYUE9SVCAgX19kZWNsc3BlYyhkbGxpbXBvcnQpCiMgZW5kaWYKI2Vsc2UKICAvKiBu b24tV2luZG93cyBPUyAqLwojIGRlZmluZSBFTUFDU19FWFBPUlQgX19hdHRyaWJ1dGVfXygodmlz aWJpbGl0eSAoImRlZmF1bHQiKSkpCiNlbmRpZgoKI2luY2x1ZGUgPHN0ZGludC5oPgojaW5jbHVk ZSA8c3RkYm9vbC5oPgoKLyogbGlzcC5oOjg3ICovCiNpZm5kZWYgRU1BQ1NfSU5UX01BWAojIGlm IElOVFBUUl9NQVggPD0gMAojICBlcnJvciAiSU5UUFRSX01BWCBtaXNjb25maWd1cmVkIgojIGVs aWYgSU5UUFRSX01BWCA8PSBJTlRfTUFYID4+IE5PTlBPSU5URVJfQklUUyAmJiAhZGVmaW5lZCBX SURFX0VNQUNTX0lOVAp0eXBlZGVmIGludCBFTUFDU19JTlQ7CnR5cGVkZWYgdW5zaWduZWQgaW50 IEVNQUNTX1VJTlQ7CiMgIGRlZmluZSBFTUFDU19JTlRfTUFYIElOVF9NQVgKIyAgZGVmaW5lIHBJ ICIiCiMgZWxpZiBJTlRQVFJfTUFYIDw9IExPTkdfTUFYID4+IE5PTlBPSU5URVJfQklUUyAmJiAh ZGVmaW5lZCBXSURFX0VNQUNTX0lOVAp0eXBlZGVmIGxvbmcgaW50IEVNQUNTX0lOVDsKdHlwZWRl ZiB1bnNpZ25lZCBsb25nIEVNQUNTX1VJTlQ7Ci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