<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Times New Roman \(Body CS\)";
        panose-1:2 2 6 3 5 4 5 2 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:12.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        font-size:12.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:12.0pt;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:161043265;
        mso-list-type:hybrid;
        mso-list-template-ids:-1142934206 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l1
        {mso-list-id:236945300;
        mso-list-type:hybrid;
        mso-list-template-ids:-724956782 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l1:level1
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l1:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l1:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style>
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">I知 trying to compile a common lisp system into a .so which I can then wrap a Python library around to enable easy sharing of the functionality as a Python package (wheel).  I知 having trouble finding examples
 of other C code calling into ECL-compiled shared objects of lisp code.  I hope I can solicit some answer and critical code review here, or pointers to exemplar implementations would also be much appreciated.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">So far I have:<o:p></o:p></span></p>
<ol style="margin-top:0in" start="1" type="1">
<li class="MsoListParagraph" style="margin-left:0in;mso-list:l1 level1 lfo2"><span style="font-size:11.0pt">A Makefile [1] rule to build the .so from the common lisp package.  This part actually seems to be working well (if slow to compile).<o:p></o:p></span></li><li class="MsoListParagraph" style="margin-left:0in;mso-list:l1 level1 lfo2"><span style="font-size:11.0pt">A C source file [2] wrapping the ECL-compiled shared object. I think this is likely where most of my problems are: specifically:<o:p></o:p></span></li><ol style="margin-top:0in" start="1" type="a">
<li class="MsoListParagraph" style="margin-left:0in;mso-list:l1 level2 lfo2"><span style="font-size:11.0pt">How does one get a string back out from Common Lisp to C?  Currently I知 jumping through hoops that seem like they should be unnecessary [3] and only
 work some of the time (other times I知 getting multiple copies of the string text).<o:p></o:p></span></li><li class="MsoListParagraph" style="margin-left:0in;mso-list:l1 level2 lfo2"><span style="font-size:11.0pt">How does one get a UTF8 string from C (wchar_t*) into Common Lisp?  I haven稚 found a way so for now I知 limiting my input to ASCII (char*) [4].<o:p></o:p></span></li><li class="MsoListParagraph" style="margin-left:0in;mso-list:l1 level2 lfo2"><span style="font-size:11.0pt">Is the best way to invoke a function really to call c_string_to_object (e.g., [5] among many others)?  It seems like there should be a more efficient
 way than converting a string into a function name for every function dispatch.<o:p></o:p></span></li><li class="MsoListParagraph" style="margin-left:0in;mso-list:l1 level2 lfo2"><span style="font-size:11.0pt">Finally, calling init [6] has two problems.  First, it takes a very long time every time I load the library.  Is there no way to save the state of the
 lisp image after initialization?  Second, it loads ASDF from a path relative to my local system.  Can I get ASDF compiled into the shared object to remove as many external dependencies as possible?<o:p></o:p></span></li></ol>
</ol>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Any help is much appreciated.  Also, thanks to those who answered issues on the ECL GitLab repository to help me get this far.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Thanks!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Eric<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">[1] <a href="https://github.com/GrammaTech/sel/blob/python-library/Makefile#L110-L128">
https://github.com/GrammaTech/sel/blob/python-library/Makefile#L110-L128</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">[2] <a href="https://github.com/GrammaTech/sel/blob/python-library/software/tree-sitter.c">
https://github.com/GrammaTech/sel/blob/python-library/software/tree-sitter.c</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">[3] <a href="https://github.com/GrammaTech/sel/blob/python-library/software/tree-sitter.c#L14-L20">
https://github.com/GrammaTech/sel/blob/python-library/software/tree-sitter.c#L14-L20</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">[4] <a href="https://github.com/GrammaTech/sel/blob/python-library/software/tree-sitter.c#L104-L123">
https://github.com/GrammaTech/sel/blob/python-library/software/tree-sitter.c#L104-L123</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">[5] <a href="https://github.com/GrammaTech/sel/blob/python-library/software/tree-sitter.c#L27">
https://github.com/GrammaTech/sel/blob/python-library/software/tree-sitter.c#L27</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">[6] <a href="https://github.com/GrammaTech/sel/blob/python-library/software/tree-sitter.c#L6">
https://github.com/GrammaTech/sel/blob/python-library/software/tree-sitter.c#L6</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
</div>
<div style="font-size:8pt; font-family: 'Calibri',sans-serif;">
<hr>
The information contained in this e-mail and any attachments from GrammaTech, Inc may contain confidential and/or proprietary information, and is intended only for the named recipient to whom it was originally addressed. If you are not the intended recipient,
 any disclosure, distribution, or copying of this e-mail or its attachments is strictly prohibited. If you have received this e-mail in error, please notify the sender immediately by return e-mail and permanently delete the e-mail and any attachments.</div>
</body>
</html>