210 lines
11 KiB
HTML
210 lines
11 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<!-- This manual documents Guile version 3.0.10.
|
||
|
|
||
|
Copyright (C) 1996-1997, 2000-2005, 2009-2023 Free Software Foundation,
|
||
|
Inc.
|
||
|
|
||
|
Copyright (C) 2021 Maxime Devos
|
||
|
|
||
|
Copyright (C) 2024 Tomas Volf
|
||
|
|
||
|
|
||
|
Permission is granted to copy, distribute and/or modify this document
|
||
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||
|
any later version published by the Free Software Foundation; with no
|
||
|
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
|
||
|
copy of the license is included in the section entitled "GNU Free
|
||
|
Documentation License." -->
|
||
|
<title>Snarfing Macros (Guile Reference Manual)</title>
|
||
|
|
||
|
<meta name="description" content="Snarfing Macros (Guile Reference Manual)">
|
||
|
<meta name="keywords" content="Snarfing Macros (Guile Reference Manual)">
|
||
|
<meta name="resource-type" content="document">
|
||
|
<meta name="distribution" content="global">
|
||
|
<meta name="Generator" content=".texi2any-real">
|
||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||
|
|
||
|
<link href="index.html" rel="start" title="Top">
|
||
|
<link href="Concept-Index.html" rel="index" title="Concept Index">
|
||
|
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
||
|
<link href="API-Reference.html" rel="up" title="API Reference">
|
||
|
<link href="Data-Types.html" rel="next" title="Data Types">
|
||
|
<link href="Initialization.html" rel="prev" title="Initialization">
|
||
|
<style type="text/css">
|
||
|
<!--
|
||
|
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
|
||
|
div.example {margin-left: 3.2em}
|
||
|
span:hover a.copiable-link {visibility: visible}
|
||
|
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
|
||
|
-->
|
||
|
</style>
|
||
|
<link rel="stylesheet" type="text/css" href="https://www.gnu.org/software/gnulib/manual.css">
|
||
|
|
||
|
|
||
|
</head>
|
||
|
|
||
|
<body lang="en">
|
||
|
<div class="section-level-extent" id="Snarfing-Macros">
|
||
|
<div class="nav-panel">
|
||
|
<p>
|
||
|
Next: <a href="Data-Types.html" accesskey="n" rel="next">Data Types</a>, Previous: <a href="Initialization.html" accesskey="p" rel="prev">Initializing Guile</a>, Up: <a href="API-Reference.html" accesskey="u" rel="up">API Reference</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
|
||
|
</div>
|
||
|
<hr>
|
||
|
<h3 class="section" id="Snarfing-Macros-1"><span>6.5 Snarfing Macros<a class="copiable-link" href="#Snarfing-Macros-1"> ¶</a></span></h3>
|
||
|
<a class="index-entry-id" id="index-guile_002dsnarf-recognized-macros"></a>
|
||
|
<a class="index-entry-id" id="index-guile_002dsnarf-deprecated-macros"></a>
|
||
|
|
||
|
<p>The following macros do two different things: when compiled normally,
|
||
|
they expand in one way; when processed during snarfing, they cause the
|
||
|
<code class="code">guile-snarf</code> program to pick up some initialization code,
|
||
|
See <a class="xref" href="Function-Snarfing.html">Function Snarfing</a>.
|
||
|
</p>
|
||
|
<p>The descriptions below use the term ‘normally’ to refer to the case
|
||
|
when the code is compiled normally, and ‘while snarfing’ when the code
|
||
|
is processed by <code class="code">guile-snarf</code>.
|
||
|
</p>
|
||
|
<dl class="first-deffn">
|
||
|
<dt class="deffn" id="index-SCM_005fSNARF_005fINIT"><span class="category-def">C Macro: </span><span><strong class="def-name">SCM_SNARF_INIT</strong> <var class="def-var-arguments">(code)</var><a class="copiable-link" href="#index-SCM_005fSNARF_005fINIT"> ¶</a></span></dt>
|
||
|
<dd>
|
||
|
<p>Normally, <code class="code">SCM_SNARF_INIT</code> expands to nothing; while snarfing, it
|
||
|
causes <var class="var">code</var> to be included in the initialization action file,
|
||
|
followed by a semicolon.
|
||
|
</p>
|
||
|
<p>This is the fundamental macro for snarfing initialization actions.
|
||
|
The more specialized macros below use it internally.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
|
||
|
<dl class="first-deffn">
|
||
|
<dt class="deffn" id="index-SCM_005fDEFINE"><span class="category-def">C Macro: </span><span><strong class="def-name">SCM_DEFINE</strong> <var class="def-var-arguments">(c_name, scheme_name, req, opt, var, arglist, docstring)</var><a class="copiable-link" href="#index-SCM_005fDEFINE"> ¶</a></span></dt>
|
||
|
<dd>
|
||
|
<p>Normally, this macro expands into
|
||
|
</p>
|
||
|
<div class="example smallexample">
|
||
|
<pre class="example-preformatted">static const char s_<var class="var">c_name</var>[] = <var class="var">scheme_name</var>;
|
||
|
SCM
|
||
|
<var class="var">c_name</var> <var class="var">arglist</var>
|
||
|
</pre></div>
|
||
|
|
||
|
<p>While snarfing, it causes
|
||
|
</p>
|
||
|
<div class="example smallexample">
|
||
|
<pre class="example-preformatted">scm_c_define_gsubr (s_<var class="var">c_name</var>, <var class="var">req</var>, <var class="var">opt</var>, <var class="var">var</var>,
|
||
|
<var class="var">c_name</var>);
|
||
|
</pre></div>
|
||
|
|
||
|
<p>to be added to the initialization actions. Thus, you can use it to
|
||
|
declare a C function named <var class="var">c_name</var> that will be made available to
|
||
|
Scheme with the name <var class="var">scheme_name</var>.
|
||
|
</p>
|
||
|
<p>Note that the <var class="var">arglist</var> argument must have parentheses around it.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-deffn">
|
||
|
<dt class="deffn" id="index-SCM_005fSYMBOL"><span class="category-def">C Macro: </span><span><strong class="def-name">SCM_SYMBOL</strong> <var class="def-var-arguments">(c_name, scheme_name)</var><a class="copiable-link" href="#index-SCM_005fSYMBOL"> ¶</a></span></dt>
|
||
|
<dt class="deffnx def-cmd-deffn" id="index-SCM_005fGLOBAL_005fSYMBOL"><span class="category-def">C Macro: </span><span><strong class="def-name">SCM_GLOBAL_SYMBOL</strong> <var class="def-var-arguments">(c_name, scheme_name)</var><a class="copiable-link" href="#index-SCM_005fGLOBAL_005fSYMBOL"> ¶</a></span></dt>
|
||
|
<dd><p>Normally, these macros expand into
|
||
|
</p>
|
||
|
<div class="example smallexample">
|
||
|
<pre class="example-preformatted">static SCM <var class="var">c_name</var>
|
||
|
</pre></div>
|
||
|
|
||
|
<p>or
|
||
|
</p>
|
||
|
<div class="example smallexample">
|
||
|
<pre class="example-preformatted">SCM <var class="var">c_name</var>
|
||
|
</pre></div>
|
||
|
|
||
|
<p>respectively. While snarfing, they both expand into the
|
||
|
initialization code
|
||
|
</p>
|
||
|
<div class="example smallexample">
|
||
|
<pre class="example-preformatted"><var class="var">c_name</var> = scm_permanent_object (scm_from_locale_symbol (<var class="var">scheme_name</var>));
|
||
|
</pre></div>
|
||
|
|
||
|
<p>Thus, you can use them declare a static or global variable of type
|
||
|
<code class="code">SCM</code> that will be initialized to the symbol named
|
||
|
<var class="var">scheme_name</var>.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-deffn">
|
||
|
<dt class="deffn" id="index-SCM_005fKEYWORD"><span class="category-def">C Macro: </span><span><strong class="def-name">SCM_KEYWORD</strong> <var class="def-var-arguments">(c_name, scheme_name)</var><a class="copiable-link" href="#index-SCM_005fKEYWORD"> ¶</a></span></dt>
|
||
|
<dt class="deffnx def-cmd-deffn" id="index-SCM_005fGLOBAL_005fKEYWORD"><span class="category-def">C Macro: </span><span><strong class="def-name">SCM_GLOBAL_KEYWORD</strong> <var class="def-var-arguments">(c_name, scheme_name)</var><a class="copiable-link" href="#index-SCM_005fGLOBAL_005fKEYWORD"> ¶</a></span></dt>
|
||
|
<dd><p>Normally, these macros expand into
|
||
|
</p>
|
||
|
<div class="example smallexample">
|
||
|
<pre class="example-preformatted">static SCM <var class="var">c_name</var>
|
||
|
</pre></div>
|
||
|
|
||
|
<p>or
|
||
|
</p>
|
||
|
<div class="example smallexample">
|
||
|
<pre class="example-preformatted">SCM <var class="var">c_name</var>
|
||
|
</pre></div>
|
||
|
|
||
|
<p>respectively. While snarfing, they both expand into the
|
||
|
initialization code
|
||
|
</p>
|
||
|
<div class="example smallexample">
|
||
|
<pre class="example-preformatted"><var class="var">c_name</var> = scm_permanent_object (scm_c_make_keyword (<var class="var">scheme_name</var>));
|
||
|
</pre></div>
|
||
|
|
||
|
<p>Thus, you can use them declare a static or global variable of type
|
||
|
<code class="code">SCM</code> that will be initialized to the keyword named
|
||
|
<var class="var">scheme_name</var>.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-deffn">
|
||
|
<dt class="deffn" id="index-SCM_005fVARIABLE"><span class="category-def">C Macro: </span><span><strong class="def-name">SCM_VARIABLE</strong> <var class="def-var-arguments">(c_name, scheme_name)</var><a class="copiable-link" href="#index-SCM_005fVARIABLE"> ¶</a></span></dt>
|
||
|
<dt class="deffnx def-cmd-deffn" id="index-SCM_005fGLOBAL_005fVARIABLE"><span class="category-def">C Macro: </span><span><strong class="def-name">SCM_GLOBAL_VARIABLE</strong> <var class="def-var-arguments">(c_name, scheme_name)</var><a class="copiable-link" href="#index-SCM_005fGLOBAL_005fVARIABLE"> ¶</a></span></dt>
|
||
|
<dd><p>These macros are equivalent to <code class="code">SCM_VARIABLE_INIT</code> and
|
||
|
<code class="code">SCM_GLOBAL_VARIABLE_INIT</code>, respectively, with a <var class="var">value</var> of
|
||
|
<code class="code">SCM_BOOL_F</code>.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-deffn">
|
||
|
<dt class="deffn" id="index-SCM_005fVARIABLE_005fINIT"><span class="category-def">C Macro: </span><span><strong class="def-name">SCM_VARIABLE_INIT</strong> <var class="def-var-arguments">(c_name, scheme_name, value)</var><a class="copiable-link" href="#index-SCM_005fVARIABLE_005fINIT"> ¶</a></span></dt>
|
||
|
<dt class="deffnx def-cmd-deffn" id="index-SCM_005fGLOBAL_005fVARIABLE_005fINIT"><span class="category-def">C Macro: </span><span><strong class="def-name">SCM_GLOBAL_VARIABLE_INIT</strong> <var class="def-var-arguments">(c_name, scheme_name, value)</var><a class="copiable-link" href="#index-SCM_005fGLOBAL_005fVARIABLE_005fINIT"> ¶</a></span></dt>
|
||
|
<dd>
|
||
|
<p>Normally, these macros expand into
|
||
|
</p>
|
||
|
<div class="example smallexample">
|
||
|
<pre class="example-preformatted">static SCM <var class="var">c_name</var>
|
||
|
</pre></div>
|
||
|
|
||
|
<p>or
|
||
|
</p>
|
||
|
<div class="example smallexample">
|
||
|
<pre class="example-preformatted">SCM <var class="var">c_name</var>
|
||
|
</pre></div>
|
||
|
|
||
|
<p>respectively. While snarfing, they both expand into the
|
||
|
initialization code
|
||
|
</p>
|
||
|
<div class="example smallexample">
|
||
|
<pre class="example-preformatted"><var class="var">c_name</var> = scm_permanent_object (scm_c_define (<var class="var">scheme_name</var>, <var class="var">value</var>));
|
||
|
</pre></div>
|
||
|
|
||
|
<p>Thus, you can use them declare a static or global C variable of type
|
||
|
<code class="code">SCM</code> that will be initialized to the object representing the
|
||
|
Scheme variable named <var class="var">scheme_name</var> in the current module. The
|
||
|
variable will be defined when it doesn’t already exist. It is always
|
||
|
set to <var class="var">value</var>.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
</div>
|
||
|
<hr>
|
||
|
<div class="nav-panel">
|
||
|
<p>
|
||
|
Next: <a href="Data-Types.html">Data Types</a>, Previous: <a href="Initialization.html">Initializing Guile</a>, Up: <a href="API-Reference.html">API Reference</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
</body>
|
||
|
</html>
|