Debian Codegraph @

texmf-dist/source/latex/lt3rawobjects/lt3rawobjects.dtx

raw
1 % \iffalse meta-comment
2 %
3 % lt3rawobjects Objects and proxies in LaTeX3
4 % Copyright (C) 2022 Paolo De Donato <[email protected]>
5 %
6 % This file is part of lt3rawobjects.
7 %
8 % lt3rawobjects is free software: you can redistribute it and/or modify
9 % it under the terms of the GNU General Public License as published by
10 % the Free Software Foundation, either version 3 of the License, or
11 % (at your option) any later version.
12 %
13 % lt3rawobjects is distributed in the hope that it will be useful,
14 % but WITHOUT ANY WARRANTY; without even the implied warranty of
15 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 % GNU General Public License for more details.
17 %
18 % You should have received a copy of the GNU General Public License
19 % along with lt3rawobjects. If not, see <https://www.gnu.org/licenses/>.
20 %
21 % \fi
22 %
23 % \iffalse
24 %<*driver>
25 \ProvidesFile{lt3rawobjects.dtx}[2023/03/17 2.3 Objects and proxies in LaTeX3]
26 %</driver>
27 %<package>\NeedsTeXFormat{LaTeX2e}
28 %<package>\RequirePackage{expl3}[2022-04-10]
29 %<package>\ProvidesExplPackage{lt3rawobjects}{2023/03/17}{ 2.3 }{Objects and proxies in LaTeX3}
30 %<*driver>
31 \documentclass[full]{l3doc}
32 \usepackage{lt3rawobjects}
33 \usepackage{xparse}
34 \usepackage{xcolor}
35 \usepackage{fancyvrb}
36 \begin{document}
37
38
39 \DocInput{lt3rawobjects.dtx}
40 \end{document}
41 %</driver>
42 % \fi
43 %
44 % \NewDocumentCommand{\thpkg}{}{\pkg{lt3rawobjects}}
45 % \NewDocumentCommand{\thvsn}{}{2.3}
46 % \NewDocumentCommand{\thdta}{}{2023/03/17}
47 % \NewDocumentCommand{\fromV}{ m }{{\ttfamily From: #1}}
48 % \NewDocumentCommand{\fromVD}{ m m }{{\ttfamily From: #1}\par {\ttfamily Deprecated in: #2}}
49 %
50 % \NewDocumentCommand{\simfun}{m m}{\textcolor{blue}{\textbackslash #1}\textcolor{purple}{:#2}}
51 % \NewDocumentCommand{\simvar}{m}{\textcolor{violet}{\textbackslash #1}}
52 % \DefineVerbatimEnvironment{Coding}{Verbatim}{numbers=left, frame=single, commandchars={![]}}
53 %
54 % \title{The \pkg{lt3rawobjects} package}
55 % \author{Paolo De Donato}
56 % \date{Released on \thdta\ Version \thvsn}
57 %
58 % \maketitle
59 %
60 % \tableofcontents
61 %
62 % \begin{documentation}
63 %
64 % \section{Introduction}
65 % Package \thpkg\ introduces a new mechanism to create and manage structured data called ``objects'' like the well known C structures. The functions exported by this package are quite low level, and many important mechanisms like member protection and name resolution aren't already defined and should be introduced by intermediate packages. Higher level libraries built on top of \thpkg\ could also implement an improved and simplified syntax since the main focus of \thpkg\ is versatility and expandability rather than common usage.
66 %
67 % This packages follows the \href{https://semver.org/}{SemVer} specification (\texttt{https://semver.org/}). In particular any major version update (for example from \texttt{1.2} to \texttt{2.0}) may introduce imcompatible changes and so it's not advisable to work with different packages that require different major versions of \thpkg. Instead changes introduced in minor and patch version updates are always backward compatible, and any withdrawn function is declared deprecated instead of being removed.
68 %
69 % \section{Addresses}
70 % In this package a \emph{pure address} is any string without spaces (so a sequence of tokens with category code 12 ``other'') that uniquely identifies a resource or an entity. An example of pure address if the name of a control sequence \tn{\meta{name}} that can obtained by full expanding \cs{cs_to_str:N} \tn{\meta{name}}. Instead an \emph{expanded address} is a token list that contains only tokens with category code 11 (letters) or 12 (other) that can be directly converted to a pure address with a simple call to \cs{tl_to_str:n} or by assigning it to a string variable.
71 %
72 % An \emph{address} is instead a fully expandable token list which full expansion is an expanded address, where full expansion means the expansion process performed inside |c|, |x| and |e| parameters. Moreover, any address should be fully expandable according to the rules of |x| and |e| parameter types with same results, and the name of control sequence resulting from a |c|-type expansion of such address must be equal to its full expansion. For these reasons addresses should not contain parameter tokens like |#| (because they're threat differently by |x| and |e|) or control sequences that prevents expansion like \cs{exp_not:n} (because they leave unexpanded control sequences after an |x| or |e| expansion, and expanded addresses can't have control sequences inside them). In particular, |\tl_to_str:n{ ## }| is \emph{not} a valid address (assuming standard category codes).
73 %
74 % Addresses could be not full expanded inside an |f| argument, thus an address expanded in an |f| argument should be |x|, |e| or |c| expended later to get the actual pure address. If you need to fully expand an address in an |f| argument (because, for example, your macro should be fully expandable and your engine is too old to support |e| expansion efficiently) then you can put your address inside \cs{rwobj_address_f:n} and pass them to your function. For example,
75 % \begin{verbatim}
76 % \your_function:f{ \rwobj_address_f:n { your \address } }
77 % \end{verbatim}
78 % Remember that \cs{rwobj_address_f:n} only works with addresses, can't be used to fully expand any token list.
79 %
80 % Like functions and variables names, pure addresses should follows some basic naming conventions in order to avoid clashes between addresses in different modules. Each pure address starts with the \meta{module} name in which such address is allocated, then an underscore (|_|) and the \meta{identifier} that uniquely identifies the resource inside the module. The \meta{module} should contain only lowercase ASCII letters.
81 %
82 % A \emph{pointer} is just a \LaTeX3 string variable that holds a pure address. We don't enforce to use |str| or any special suffix to denote pointers so you're free to use |str| or a custom \meta{type} as suffix for your pointers in order to distinguish between them according to their type.
83 %
84 % In \thpkg\ all the macros ending with |_adr| or |_address| are fully expandable and can be used to compose valid addresses as explained in their documentation.
85 %
86 % \section{Objects}
87 % An \emph{object} is just a collection of several related entities called \emph{fields}. Objects are themselves entities so they have addresses and could be contained inside other objects. Objects addresses are also used to compose the addresses of each of their inner entity, thus different objects can have fields with the same name without clashing each other. Each object is uniquely identified by its pure address, which is composed by a \meta{module} and an \meta{identifier} as explained before. The use of underscore character in objects identifiers is reserved. You can retrive the address of an object via the \cs{object_address:nn} function.
88 %
89 % Objects are always created from already existing objects. An object that can be used to create other objects is called |proxy|, and the proxy that has created an object is its \emph{generator}. In the |rawobjects| module is already allocated a particular proxy that can be used to create every other proxy. Its identifier is just |proxy| and its pure address is stored in \cs{c_proxy_address_str}. The functions \cs{object_create} can be used to create new objects.
90 %
91 % \section{Fields}
92 % Remember that objects are just a collection of different fields uniquely identidied by a pure address. Here an field could be one of the following entities:
93 % \begin{itemize}
94 % \item a \LaTeX3 variable, in which case the field is called \emph{member};
95 % \item a \LaTeX3 constant, in which case the field is called just \emph{constant};
96 % \item a \LaTeX3 function, in which case the field is called \emph{method};
97 % \item generic control sequences, in which case the field is called simply \emph{macro};
98 % \item an entire object, in which case the field is called \emph{embedded object}.
99 % \end{itemize}
100 %
101 % Objects could be declared \emph{local} or \emph{global}. The only difference between a local and a global object is the scope of their members (that are \LaTeX3 variables). You should always create global object unless you specifically need local members.
102 %
103 % \subsection{Constants}
104 % Constants in an object could be \emph{near} and \emph{remote}. A near constant is just a constant declared in such object and could be referred only by it, instead a remote constant is declared inside its generator and can be referred by any object created from that proxy, thus it's shared between all the generated objects. Functions in this library that work with near constants usually contain |ncmember| in their names, whereas those involving remore constants contain |rcmember| instead.
105 %
106 % Both near and remote constants are created in the same way via the |_newconst| functions, however remote constant should be created in a proxy whereas near contant are created directly in the target object.
107 %
108 % \subsection{Methods}
109 % Methods are \LaTeX3 functions that can't be changed once they're created. Like constant, methods could be near or remote. Moreover, functions in this library dealing with near methods contain |ncmethod| whereas those dealing with remote methods contain |rcmethod| in their names.
110 %
111 % \subsection{Members}
112 % Members are just mutable \LaTeX3 variables. You can manually create new members in already existing objects or you can put the definition of a new member directly in a proxy with the \cs{proxy_push_member} functions. In this way all the objects created with that proxy will have a member according to such definition. If the object is local/global then all its members are automatically local/global.
113 %
114 % A member can be \emph{tracked} or \emph{not tracked}. A tracked member have additional information, like its type, stored in the object or in its generator. In particular, you don't need to specify the type of a tracked member and some functions in \thpkg\ are able to retrieve the required information. All the members declared in the generator are automatically tracked.
115 %
116 % \section{Object members}
117 % Sometimes it's necessary to store an instance of an object inside another object, since objects are structured entities that can't be entirely contained in a single \LaTeX3 variable you can't just put it inside a member or constant. However, there are some very easy workarounds to insert object instances as fields of other objects.
118 %
119 % For example, we're in module |MOD| and we have an object with id |PAR|. We want to provide |PAR| with a field that holds an instance of an object created by proxy |PRX|. We can achieve this in three ways:
120 %
121 % \subsection{Create a pointer member}
122 % We first create a new object from |PRX|
123 % \begin{Coding}
124 % !simfun[object_create][nnn]
125 % { !simfun[object_address][nn] { MOD }{ PRX } }{ MOD }{ INST }
126 % \end{Coding}
127 % then we create an |str| member in |PAR| that will hold the address of the newly created object.
128 % \begin{Coding}
129 % !simfun[object_new_member][nnn]
130 % {
131 % !simfun[object_address][nn] { MOD }{ PAR }
132 % }{ pointer }{ str }
133 %
134 % !simfun[object_member_set][nnnx]
135 % {
136 % !simfun[object_address][nn] { MOD }{ PAR }
137 % }
138 % { pointer }{ str }
139 % {
140 % !simfun[object_address][nn] { MOD }{ INST }
141 % }
142 % \end{Coding}
143 %
144 % You can then get the pointed object by just using the |pointer| member. Notice that you're not force to use the |str| type for the pointer member, but you can also use |tl| or any custom \meta{type}. In the latter case be sure to at least define the following functions: \cs{\meta{type}_new:c}, \cs{\meta{type}_(g)set:cn} and \cs{\meta{type}_use:c}.
145 %
146 % \subsubsection*{Advantages}
147 % \begin{itemize}
148 % \item Simple and no additional function needed to create and manage included objects;
149 % \item you can share the same object between different containers;
150 % \item included objects are objects too, you can use address stored in pointer member just like any object address.
151 % \end{itemize}
152 %
153 % \subsubsection*{Disadvantages}
154 % \begin{itemize}
155 % \item You must manually create both the objects and link them;
156 % \item if you forgot to properly initialize the pointer member it'll contain the ``null address'' (the empty string). Despite other programming languages the null address is not treated specially by \thpkg, which makes finding null pointer errors more difficult.
157 % \end{itemize}
158 %
159 % \subsection{Clone the inner structure}
160 % Anoter solution is to copy the members declared in |PRX| to |PAR|. For example, if in |PRX| are declared a member with name |x| and type |str|, and a member with name |y| and type |int| then
161 % \begin{Coding}
162 % !simfun[object_new_member][nnn]
163 % {
164 % !simfun[object_address][nn] { MOD }{ PAR }
165 % }{ prx-x }{ str }
166 % !simfun[object_new_member][nnn]
167 % {
168 % !simfun[object_address][nn] { MOD }{ PAR }
169 % }{ prx-y }{ int }
170 % \end{Coding}
171 %
172 % \subsubsection*{Advantages}
173 % \begin{itemize}
174 % \item Very simple;
175 % \item no hidden item is created, this procedure has the lowest overhead among all the proposed solutions here.
176 % \end{itemize}
177 %
178 % \subsubsection*{Disadvantages}
179 % \begin{itemize}
180 % \item If you need the original instance of the stored object then you should create a temporary object and manually copy each field to it. Don't use this method if you later need to retrieve the stored object entirely and not only its fields.
181 % \end{itemize}
182 %
183 % \subsection{Embedded objects}
184 % From \thpkg\ \texttt{2.2} you can put \emph{embedded objects} inside objects. Embedded objects are created with \cs{embedded_create} function
185 % \begin{Coding}
186 % !simfun[embedded_create][nnn]
187 % {
188 % !simfun[object_address][nn] { MOD }{ PAR }
189 % }
190 % { PRX }{ emb }
191 % \end{Coding}
192 % and addresses of emmbedded objects can be retrieved with function \cs{object_embedded_adr}. You can also put the definition of embedded objects in a proxy by using \cs{proxy_push_embedded} just like \cs{proxy_push_member}.
193 %
194 % \subsubsection*{Advantages}
195 % \begin{itemize}
196 % \item You can put a declaration inside a proxy so that embedded objects are automatically created during creation of parent object;
197 % \item included objects are objects too, you can use address stored in pointer member just like any object address.
198 % \end{itemize}
199 %
200 % \subsubsection*{Disadvantages}
201 % \begin{itemize}
202 % \item Needs additional functions available for version \texttt{2.2} or later;
203 % \item embedded objects must have the same scope and visibility of parent one;
204 % \item creating objects also creates additional hidden variables, taking so (little) additional space.
205 % \end{itemize}
206 %
207 % \section{Library functions}
208 % \label{sec:lib}
209 %
210 % \subsection{Common functions}
211 %
212 % \begin{function}[EXP]{\rwobj_address_f:n}
213 % \begin{syntax}
214 % \cs{rwobj_address_f:n} \Arg{address}
215 % \end{syntax}
216 % Fully expand an address in an |f|-type argument.
217 %
218 % \fromV{2.3}
219 % \end{function}
220 %
221 % \subsection{Base object functions}
222 %
223 % \begin{function}[rEXP]{\object_address:nn}
224 % \begin{syntax}
225 % \cs{object_address:nn} \Arg{module} \Arg{id}
226 % \end{syntax}
227 % Composes the address of object in module \meta{module} with identifier \meta{id} and places it in the input stream. Notice that both \meta{module} and \meta{id} are converted to strings before composing them in the address, so they shouldn't contain any command inside.
228 %
229 % \fromV{1.0}
230 % \end{function}
231 %
232 % \begin{function}{\object_address_set:Nnn, \object_address_gset:Nnn}
233 % \begin{syntax}
234 % \cs{object_address_set:nn} \meta{str var} \Arg{module} \Arg{id}
235 % \end{syntax}
236 % Stores the adress of selected object inside the string variable \meta{str var}.
237 %
238 % \fromV{1.1}
239 % \end{function}
240 %
241 % \begin{function}[rEXP]{\object_embedded_adr:nn, \object_embedded_adr:Vn}
242 % \begin{syntax}
243 % \cs{object_embedded_adr:nn} \Arg{address} \Arg{id}
244 % \end{syntax}
245 % Compose the address of embedded object with name \meta{id} inside the parent object with address \meta{address}. Since an embedded object is also an object you can use this function for any function that accepts object addresses as an argument.
246 %
247 % \fromV{2.2}
248 % \end{function}
249 %
250 % \begin{function}[pTF]{\object_if_exist:n, \object_if_exist:V}
251 % \begin{syntax}
252 % \cs{object_if_exist_p:n} \marg{address}
253 % \cs{object_if_exist:nTF} \marg{address} \marg{true code} \marg{false code}
254 % \end{syntax}
255 % Tests if an object was instantiated at the specified address.
256 %
257 % \fromV{1.0}
258 % \end{function}
259 %
260 % \begin{function}[EXP]{\object_get_module:n, \object_get_module:V, \object_get_proxy_adr:n, \object_get_proxy_adr:V}
261 % \begin{syntax}
262 % \cs{object_get_module:n} \marg{address}
263 % \cs{object_get_proxy_adr:n} \marg{address}
264 % \end{syntax}
265 % Get the object module and its generator.
266 %
267 % \fromV{1.0}
268 % \end{function}
269 %
270 % \begin{function}[pTF]{\object_if_local:n, \object_if_global:n, \object_if_local:V, \object_if_global:V}
271 % \begin{syntax}
272 % \cs{object_if_local_p:n} \marg{address}
273 % \cs{object_if_local:nTF} \marg{address} \marg{true code} \marg{false code}
274 % \end{syntax}
275 % Tests if the object is local or global.
276 %
277 % \fromV{1.0}
278 % \end{function}
279 %
280 % \begin{function}[pTF]{\object_if_public:n, \object_if_private:n, \object_if_public:V, \object_if_private:V}
281 % \begin{syntax}
282 % \cs{object_if_public_p:n} \marg{address}
283 % \cs{object_if_public:nTF} \marg{address} \marg{true code} \marg{false code}
284 % \end{syntax}
285 % Tests if the object is public or private.
286 %
287 % \fromV{1.0}
288 % \end{function}
289 %
290 % \subsection{Members}
291 %
292 % \begin{function}[rEXP]{\object_member_adr:nnn, \object_member_adr:Vnn, \object_member_adr:nnv, \object_member_adr:nn, \object_member_adr:Vn}
293 % \begin{syntax}
294 % \cs{object_member_adr:nnn} \marg{address} \marg{member name} \marg{member type}
295 % \cs{object_member_adr:nn} \marg{address} \marg{member name}
296 % \end{syntax}
297 % Fully expands to the address of specified member variable. If the member is tracked then you can omit the type field.
298 %
299 % \fromV{1.0}
300 % \end{function}
301 %
302 % \begin{function}[pTF]{\object_member_if_exist:nnn, \object_member_if_exist:Vnn}
303 % \begin{syntax}
304 % \cs{object_member_if_exist_p:nnn} \marg{address} \marg{member name} \marg{member type}
305 % \cs{object_member_if_exist:nnnTF} \marg{address} \marg{member name} \marg{member type} \Arg{true code} \Arg{false code}
306 % \end{syntax}
307 % Tests if the specified member exist.
308 %
309 % \fromV{2.0}
310 % \end{function}
311 %
312 % \begin{function}[pTF]{\object_member_if_tracked:nn, \object_member_if_tracked:Vn}
313 % \begin{syntax}
314 % \cs{object_member_if_tracked_p:nn} \Arg{address} \Arg{member name}
315 % \cs{object_member_if_tracked:nnTF} \Arg{address} \Arg{member name} \Arg{true code} \Arg{false code}
316 % \end{syntax}
317 % Tests if the specified member exist and is tracked.
318 %
319 % \fromV{2.3}
320 % \end{function}
321 %
322 % \begin{function}[EXP]{\object_member_type:nn, \object_member_type:Vn}
323 % \begin{syntax}
324 % \cs{object_member_type:nn} \marg{address} \marg{member name}
325 % \end{syntax}
326 % Fully expands to the type of specified tracked member.
327 %
328 % \fromV{1.0}
329 % \end{function}
330 %
331 % \begin{function}{\object_new_member:nnn, \object_new_member:Vnn, \object_new_member:nnv}
332 % \begin{syntax}
333 % \cs{object_new_member:nnn} \marg{address} \marg{member name} \marg{member type}
334 % \end{syntax}
335 % Creates a new member with specified name and type. The created member is not tracked.
336 %
337 % \fromV{1.0}
338 % \end{function}
339 %
340 % \begin{function}{\object_new_member_tracked:nnn, \object_new_member_tracked:Vnn}
341 % \begin{syntax}
342 % \cs{object_new_member_tracked:nnn} \marg{address} \marg{member name} \marg{member type}
343 % \end{syntax}
344 % Creates a new tracked member.
345 %
346 % \fromV{2.3}
347 % \end{function}
348 %
349 % \begin{function}[EXP]{\object_member_use:nnn, \object_member_use:Vnn, \object_member_use:nnv, \object_member_use:nn, \object_member_use:Vn}
350 % \begin{syntax}
351 % \cs{object_member_use:nnn} \marg{address} \marg{member name} \marg{member type}
352 % \cs{object_member_use:nn} \marg{address} \marg{member name}
353 % \end{syntax}
354 % Uses the specified member variable.
355 %
356 % \fromV{1.0}
357 % \end{function}
358 %
359 % \begin{function}{\object_member_set:nnnn, \object_member_set:nnvn, \object_member_set:Vnnn, \object_member_set:nnn, \object_member_set:Vnn}
360 % \begin{syntax}
361 % \cs{object_member_set:nnnn} \Arg{address} \Arg{member name} \Arg{member type} \Arg{value}
362 % \cs{object_member_set:nnn} \Arg{address} \Arg{member name} \Arg{value}
363 % \end{syntax}
364 % Sets the value of specified member to \marg{value}. It calls implicitly \cs{\meta{member type}_(g)set:cn} then be sure to define it before calling this method.
365 %
366 % \fromV{2.1}
367 % \end{function}
368 %
369 % \begin{function}{\object_member_set_eq:nnnN, \object_member_set_eq:nnvN, \object_member_set_eq:VnnN, \object_member_set_eq:nnnc, \object_member_set_eq:Vnnc, \object_member_set_eq:nnN, \object_member_set_eq:VnN, \object_member_set_eq:nnc, \object_member_set_eq:Vnc}
370 % \begin{syntax}
371 % \cs{object_member_set_eq:nnnN} \marg{address} \marg{member name} \marg{member type} \meta{variable}
372 % \cs{object_member_set_eq:nnN} \marg{address} \marg{member name} \meta{variable}
373 % \end{syntax}
374 % Sets the value of specified member equal to the value of \meta{variable}.
375 %
376 % \fromV{1.0}
377 % \end{function}
378 %
379 % \begin{function}{\object_member_generate:NN, \object_member_generate_protected:NN}
380 % \begin{syntax}
381 % \cs{object_member_generate:NN} \cs{\meta{name\textsubscript{1}}} \cs{\meta{name\textsubscript{2}}:\meta{arg1}\meta{args}}
382 % \end{syntax}
383 % Define the new functions \cs{\meta{name\textsubscript{1}}:nnn\meta{Targs} } and \cs{\meta{name\textsubscript{1}}:nn\meta{Targs} } that pass to \cs{\meta{name\textsubscript{2}}:\meta{arg1}\meta{args} } the specified member address as the first argument. \meta{Targs} is a list of argument specifications obtained by transforming each element of \meta{args} to |n|, |N|, |w|, |T| or |F|.
384 %
385 % The first three parameters of \cs{\meta{name\textsubscript{1}}:nnn\meta{args} } should be in the following order:
386 % \begin{enumerate}
387 % \item an object address;
388 % \item a member name;
389 % \item the type of specified member.
390 % \end{enumerate}
391 %
392 % Function \cs{\meta{name\textsubscript{1}}:nn\meta{args} } only accepts the first two parameters and works only with tracked members. Notice that \meta{arg1} must be only one of the following: |n|, |c|, |v|, |x|, |f|, |e|, |o|.
393 %
394 % \fromV{2.3}
395 % \end{function}
396 %
397 % \begin{function}{\object_member_generate_inline:Nnn, \object_member_generate_protected_inline:Nnn}
398 % \begin{syntax}
399 % \cs{object_member_generate_inline:Nnn} \cs{\meta{name\textsubscript{1}}} \Arg{name\textsubscript{2}} \{\meta{arg1}\meta{args}\}
400 % \end{syntax}
401 % Works as \cs{object_member_generate:NN}, however in \meta{name\textsubscript{2}} you can use parameters |#1| and |#2| to compose the needed function. Parameter |#1| expands to the (fully expanded) member type and |#2| is equal to |g| if the object is global and it's empty if it is local.
402 %
403 % \fromV{2.3}
404 % \end{function}
405 %
406 % \subsection{Constants}
407 % \begin{function}[rEXP]{\object_ncmember_adr:nnn, \object_ncmember_adr:Vnn, \object_ncmember_adr:vnn, \object_rcmember_adr:nnn, \object_rcmember_adr:Vnn}
408 % \begin{syntax}
409 % \cs{object_ncmember_adr:nnn} \Arg{address} \Arg{member name} \Arg{member type}
410 % \end{syntax}
411 % Fully expands to the address of specified near/remote constant member.
412 %
413 % \fromV{2.0}
414 % \end{function}
415 %
416 % \begin{function}[pTF]{\object_ncmember_if_exist:nnn, \object_ncmember_if_exist:Vnn, \object_rcmember_if_exist:nnn, \object_rcmember_if_exist:Vnn}
417 % \begin{syntax}
418 % \cs{object_ncmember_if_exist_p:nnn} \marg{address} \marg{member name} \marg{member type}
419 % \cs{object_ncmember_if_exist:nnnTF} \marg{address} \marg{member name} \marg{member type} \Arg{true code} \Arg{false code}
420 % \end{syntax}
421 % Tests if the specified member constant exist.
422 %
423 % \fromV{2.0}
424 % \end{function}
425 %
426 % \begin{function}[EXP]{\object_ncmember_use:nnn, \object_ncmember_use:Vnn, \object_rcmember_use:nnn, \object_rcmember_use:Vnn}
427 % \begin{syntax}
428 % \cs{object_ncmember_use:nnn} \Arg{address} \Arg{member name} \Arg{member type}
429 % \end{syntax}
430 % Uses the specified near/remote constant member.
431 %
432 % \fromV{2.0}
433 % \end{function}
434 %
435 % \begin{function}{\object_ncmember_generate:NN, \object_ncmember_protected_generate:NN, \object_rcmember_generate:NN, \object_rcmember_protected_generate:NN}
436 % \begin{syntax}
437 % \cs{object_ncmember_generate:NN} \cs{\meta{name\textsubscript{1}}} \cs{name\textsubscript{2}}:\meta{arg1}\meta{args}
438 % \end{syntax}
439 % Works as \cs{object_member_generate:NN} but with constants instead of members.
440 %
441 % \fromV{2.3}
442 % \end{function}
443 %
444 % \begin{function}{\object_ncmember_generate_inline:Nnn, \object_ncmember_protected_generate_inline:Nnn, \object_rcmember_generate_inline:Nnn, \object_rcmember_protected_generate_inline:Nnn}
445 % \begin{syntax}
446 % \cs{object_ncmember_generate_inline:Nnn} \cs{\meta{name\textsubscript{1}}} \Arg{name\textsubscript{2}} \{\meta{arg1}\meta{args}\}
447 % \end{syntax}
448 % Works as \cs{object_member_generate_inline:Nnn} but with constants instead of members.
449 %
450 % \fromV{2.3}
451 % \end{function}
452 %
453 % \subsection{Methods}
454 % \begin{function}[rEXP]{\object_ncmethod_adr:nnn, \object_ncmethod_adr:Vnn, \object_ncmethod_adr:vnn, \object_rcmethod_adr:nnn, \object_rcmethod_adr:Vnn}
455 % \begin{syntax}
456 % \cs{object_ncmethod_adr:nnn} \Arg{address} \Arg{method name} \Arg{method variant}
457 % \end{syntax}
458 % Fully expands to the address of the specified
459 % \begin{itemize}
460 % \item near constant method if \cs{object_ncmethod_adr} is used;
461 % \item remote constant method if \cs{object_rcmethod_adr} is used.
462 % \end{itemize}
463 %
464 % \fromV{2.0}
465 % \end{function}
466 %
467 % \begin{function}[pTF]{\object_ncmethod_if_exist:nnn, \object_ncmethod_if_exist:Vnn, \object_rcmethod_if_exist:nnn, \object_rcmethod_if_exist:Vnn}
468 % \begin{syntax}
469 % \cs{object_ncmethod_if_exist_p:nnn} \marg{address} \marg{method name} \marg{method variant}
470 % \cs{object_ncmethod_if_exist:nnnTF} \marg{address} \marg{method name} \marg{method variant} \Arg{true code} \Arg{false code}
471 % \end{syntax}
472 % Tests if the specified method constant exist.
473 %
474 % \fromV{2.0}
475 % \end{function}
476 %
477 % \begin{function}{\object_new_cmethod:nnnn, \object_new_cmethod:Vnnn}
478 % \begin{syntax}
479 % \cs{object_new_cmethod:nnnn} \Arg{address} \Arg{method name} \Arg{method arguments} \Arg{code}
480 % \end{syntax}
481 % Creates a new method with specified name and argument types. The \marg{method arguments} should be a string composed only by |n| and |N| characters that are passed to \cs{cs_new:Nn}.
482 %
483 % \fromV{2.0}
484 % \end{function}
485 %
486 % \begin{function}[EXP]{\object_ncmethod_call:nnn, \object_ncmethod_call:Vnn, \object_rcmethod_call:nnn, \object_rcmethod_call:Vnn}
487 % \begin{syntax}
488 % \cs{object_ncmethod_call:nnn} \marg{address} \marg{method name} \marg{method variant}
489 % \end{syntax}
490 % Calls the specified method. This function is expandable if and only if the specified method was not declared |protected|.
491 %
492 % \fromV{2.0}
493 % \end{function}
494 %
495 % \subsection{Creation of constants}
496 % \begin{function}{\object_newconst_tl:nnn, \object_newconst_tl:Vnn, \object_newconst_str:nnn, \object_newconst_str:Vnn, \object_newconst_int:nnn, \object_newconst_int:Vnn, \object_newconst_clist:nnn, \object_newconst_clist:Vnn, \object_newconst_dim:nnn, \object_newconst_dim:Vnn, \object_newconst_skip:nnn, \object_newconst_skip:Vnn, \object_newconst_fp:nnn, \object_newconst_fp:Vnn}
497 % \begin{syntax}
498 % \cs{object_newconst_\meta{type}:nnn} \Arg{address} \Arg{constant name} \Arg{value}
499 % \end{syntax}
500 % Creates a constant variable with type \meta{type} and sets its value to \meta{value}.
501 %
502 % \fromV{1.1}
503 % \end{function}
504 %
505 % \begin{function}{\object_newconst_seq_from_clist:nnn, \object_newconst_seq_from_clist:Vnn}
506 % \begin{syntax}
507 % \cs{object_newconst_seq_from_clist:nnn} \Arg{address} \Arg{constant name} \Arg{comma-list}
508 % \end{syntax}
509 % Creates a |seq| constant which is set to contain all the items in \meta{comma-list}.
510 %
511 % \fromV{1.1}
512 % \end{function}
513 %
514 % \begin{function}{\object_newconst_prop_from_keyval:nnn, \object_newconst_prop_from_keyval:Vnn}
515 % \begin{syntax}
516 % \cs{object_newconst_prop_from_keyval:nnn} \Arg{address} \Arg{constant name}
517 % \{
518 % \meta{key} = \meta{value}, ...
519 % \}
520 % \end{syntax}
521 % Creates a |prop| constant which is set to contain all the specified key-value pairs.
522 %
523 % \fromV{1.1}
524 % \end{function}
525 %
526 % \begin{function}{\object_newconst:nnnn}
527 % \begin{syntax}
528 % \cs{object_newconst:nnnn} \Arg{address} \Arg{constant name} \Arg{type} \Arg{value}
529 % \end{syntax}
530 % Invokes \cs{\meta{type}_const:cn} to create the specified constant.
531 %
532 % \fromV{2.1}
533 % \end{function}
534 %
535 % \subsection{Macros}
536 % \begin{function}[rEXP]{\object_macro_adr:nn, \object_macro_adr:Vn}
537 % \begin{syntax}
538 % \cs{object_macro_adr:nn} \Arg{address} \Arg{macro name}
539 % \end{syntax}
540 % Address of specified macro.
541 %
542 % \fromV{2.2}
543 % \end{function}
544 %
545 % \begin{function}[EXP]{\object_macro_use:nn, \object_macro_use:Vn}
546 % \begin{syntax}
547 % \cs{object_macro_use:nn} \Arg{address} \Arg{macro name}
548 % \end{syntax}
549 % Uses the specified macro. This function is expandable if and only if the specified macro is it.
550 %
551 % \fromV{2.2}
552 % \end{function}
553 %
554 % There isn't any standard function to create macros, and macro declarations can't be inserted in a |proxy| object. In fact a macro is just an unspecialized control sequence at the disposal of users that usually already know how to implement them.
555 %
556 % \subsection{Proxies and object creation}
557 %
558 % \begin{function}[pTF]{\object_if_proxy:n, \object_if_proxy:V}
559 % \begin{syntax}
560 % \cs{object_if_proxy_p:n} \marg{address}
561 % \cs{object_if_proxy:nTF} \marg{address} \marg{true code} \marg{false code}
562 % \end{syntax}
563 % Test if the specified object is a proxy object.
564 %
565 % \fromV{1.0}
566 % \end{function}
567 %
568 % \begin{function}[pTF]{\object_test_proxy:nn, \object_test_proxy:Vn}
569 % \begin{syntax}
570 % \cs{object_test_proxy_p:nn} \Arg{object address} \Arg{proxy address}
571 % \cs{object_test_proxy:nnTF} \Arg{object address} \Arg{proxy address} \Arg{true code} \Arg{false code}
572 % \end{syntax}
573 % Test if the specified object is generated by the selected proxy, where \meta{proxy variable} is a string variable holding the proxy address.
574 %
575 % \begin{texnote}
576 % Remember that this command uses internally an |e| expansion so in older engines (any different from Lua\LaTeX\ before 2019) it'll require slow processing. Don't use it in speed critical parts, instead use \cs{object_test_proxy:nN}.
577 % \end{texnote}
578 %
579 % \fromV{2.0}
580 % \end{function}
581 %
582 % \begin{function}[pTF]{\object_test_proxy:nN, \object_test_proxy:VN}
583 % \begin{syntax}
584 % \cs{object_test_proxy_p:nN} \Arg{object address} \meta{proxy variable}
585 % \cs{object_test_proxy:nNTF} \Arg{object address} \meta{proxy variable} \Arg{true code} \Arg{false code}
586 % \end{syntax}
587 % Test if the specified object is generated by the selected proxy, where \meta{proxy variable} is a string variable holding the proxy address. The |:nN| variant don't use |e| expansion, instead of |:nn| command, so it can be safetly used with older compilers.
588 %
589 % \fromV{2.0}
590 % \end{function}
591 %
592 % \begin{variable}{\c_proxy_address_str}
593 % The address of the |proxy| object in the |rawobjects| module.
594 %
595 % \fromV{1.0}
596 % \end{variable}
597 %
598 % \begin{function}{\object_create:nnnNN, \object_create:VnnNN}
599 % \begin{syntax}
600 % \cs{object_create:nnnNN} \marg{proxy address} \marg{module} \marg{id} \meta{scope} \meta{visibility}
601 % \end{syntax}
602 % Creates an object by using the proxy at \meta{proxy address} and the specified parameters. Use this function only if you need to create private objects (at present private objects are functionally equivalent to public objects) or if you need to compile your project with an old version of this library (|< 2.3|).
603 %
604 % \fromV{1.0}
605 % \end{function}
606 %
607 % \begin{function}{\object_create:nnnN, \object_create:VnnN, \object_create:nnn, \object_create:Vnn}
608 % \begin{syntax}
609 % \cs{object_create:nnnN} \Arg{proxy address} \Arg{module} \Arg{id} \meta{scope}\\
610 % \cs{object_create:nnn} \Arg{proxy address} \Arg{module} \Arg{id}
611 % \end{syntax}
612 % Same as \cs{object_create:nnnNN} but both create only public objects, and the |:nnn| version only global ones. Always use these two function instead of \cs{object_create:nnnNN} unless you strictly need private objects.
613 %
614 % \fromV{2.3}
615 % \end{function}
616 %
617 % \begin{function}{\embedded_create:nnn, \embedded_create:Vnn, \embedded_create:nvn}
618 % \begin{syntax}
619 % \cs{embedded_create:nnn} \Arg{parent object} \Arg{proxy address} \Arg{id}
620 % \end{syntax}
621 % Creates an embedded object with name \meta{id} inside \meta{parent object}.
622 %
623 % \fromV{2.2}
624 % \end{function}
625 %
626 % \begin{variable}{\c_object_local_str, \c_object_global_str}
627 % Possible values for \meta{scope} parameter.
628 %
629 % \fromV{1.0}
630 % \end{variable}
631 %
632 % \begin{variable}{\c_object_public_str, \c_object_private_str}
633 % Possible values for \meta{visibility} parameter.
634 %
635 % \fromV{1.0}
636 % \end{variable}
637 %
638 % \begin{function}{\object_create_set:NnnnNN, \object_create_set:NVnnNN, \object_create_set:NnnfNN, \object_create_gset:NnnnNN, \object_create_gset:NVnnNN, \object_create_gset:NnnfNN}
639 % \begin{syntax}
640 % \cs{object_create_set:NnnnNN} \meta{str var} \marg{proxy address} \marg{module} \marg{id} \meta{scope} \meta{visibility}
641 % \end{syntax}
642 % Creates an object and sets its fully expanded address inside \meta{str var}.
643 %
644 % \fromV{1.0}
645 % \end{function}
646 %
647 % \begin{function}{\object_allocate_incr:NNnnNN, \object_allocate_incr:NNVnNN, \object_gallocate_incr:NNnnNN, \object_gallocate_incr:NNVnNN, \object_allocate_gincr:NNnnNN, \object_allocate_gincr:NNVnNN, \object_gallocate_gincr:NNnnNN, \object_gallocate_gincr:NNVnNN}
648 % \begin{syntax}
649 % \cs{object_allocate_incr:NNnnNN} \meta{str var} \meta{int var} \Arg{proxy address} \Arg{module} \meta{scope} \meta{visibility}
650 % \end{syntax}
651 % Build a new object address with module \meta{module} and an identifier generated from \meta{proxy address} and the integer contained inside \meta{int var}, then increments \meta{int var}. This is very useful when you need to create a lot of objects, each of them on a different address. the |_incr| version increases \meta{int var} locally whereas |_gincr| does it globally.
652 %
653 % \fromV{1.1}
654 % \end{function}
655 %
656 % \begin{function}{\proxy_create:nnN, \proxy_create_set:NnnN, \proxy_create_gset:NnnN}
657 % \begin{syntax}
658 % \cs{proxy_create:nnN} \Arg{module} \Arg{id} \meta{visibility}
659 % \cs{proxy_create_set:NnnN} \meta{str var} \Arg{module} \Arg{id} \meta{visibility}
660 % \end{syntax}
661 % These commands are deprecated because proxies should be global and public. Use instead \cs{proxy_create:nn}, \cs{proxy_create_set:Nnn} and \cs{proxy_create_gset:Nnn}.
662 %
663 % \fromVD{1.0}{2.3}
664 % \end{function}
665 %
666 % \begin{function}{\proxy_create:nn, \proxy_create_set:Nnn, \proxy_create_gset:Nnn}
667 % \begin{syntax}
668 % \cs{proxy_create:nn} \Arg{module} \Arg{id}
669 % \cs{proxy_create_set:Nnn} \meta{str var} \Arg{module} \Arg{id}
670 % \end{syntax}
671 % Creates a global public proxy object.
672 %
673 % \fromV{2.3}
674 % \end{function}
675 %
676 % \begin{function}{\proxy_push_member:nnn, \proxy_push_member:Vnn}
677 % \begin{syntax}
678 % \cs{proxy_push_member:nnn} \Arg{proxy address} \Arg{member name} \Arg{member type}
679 % \end{syntax}
680 % Updates a proxy object with a new member specification, so that every subsequential object created with this proxy will have a member variable with the specified name and type that can be retrieved with \cs{object_member_type} functions.
681 %
682 % \fromV{1.0}
683 % \end{function}
684 %
685 % \begin{function}{\proxy_push_embedded:nnn, \proxy_push_embedded:Vnn}
686 % \begin{syntax}
687 % \cs{proxy_push_embedded:nnn} \Arg{proxy address} \Arg{embedded object name} \Arg{embedded object proxy}
688 % \end{syntax}
689 % Updates a proxy object with a new embedded object specification.
690 %
691 % \fromV{2.2}
692 % \end{function}
693 %
694 % \begin{function}{\proxy_add_initializer:nN, \proxy_add_initializer:VN}
695 % \begin{syntax}
696 % \cs{proxy_add_initializer:nN} \Arg{proxy address} \meta{initializer}
697 % \end{syntax}
698 % Pushes a new initializer that will be executed on each created objects. An initializer is a function that should accept five arguments in this order:
699 % \begin{itemize}
700 % \item the full expanded address of used proxy as an |n| argument;
701 % \item the module name as an |n| argument;
702 % \item the full expanded address of created object as an |n| argument.
703 % \end{itemize}
704 %
705 % Initializer will be executed in the same order they're added.
706 %
707 % \fromV{2.3}
708 % \end{function}
709 %
710 % \begin{function}{\object_assign:nn, \object_assign:Vn, \object_assign:nV, \object_assign:VV}
711 % \begin{syntax}
712 % \cs{object_assign:nn} \marg{to address} \marg{from address}
713 % \end{syntax}
714 % Assigns the content of each variable of object at \meta{from address} to each correspective variable in \meta{to address}. Both the objects should be created with the same proxy object and only variables listed in the proxy are assigned.
715 %
716 % \fromV{1.0}
717 % \end{function}
718 %
719 % \section{Examples}
720 % \subsection*{Example 1}
721 % Create a public proxy with id \verb|myproxy| with the specification of a single member variable with name \verb|myvar| and type \verb|tl|, then set its address inside \cs{g_myproxy_str}.
722 %
723 % \begin{Coding}
724 % !simfun[str_new][N] !simvar[g_myproxy_str]
725 % !simfun[proxy_create_gset][Nnn] !simvar[g_myproxy_str] { example }{ myproxy }
726 % !simfun[proxy_push_member][Vnn] !simvar[g_myproxy_str] { myvar }{ tl }
727 % \end{Coding}
728 %
729 % Then create a new object with name \verb|myobj| with that proxy, assign then token list \verb|\c_dollar_str{} ~ dollar ~ \c_dollar_str{}| to \verb|myvar| and then print it.
730 %
731 % \begin{Coding}
732 % !simfun[str_new][N] !simvar[g_myobj_str]
733 % !simfun[object_create_gset][NVnn] !simvar[g_myobj_str] !simvar[g_myproxy_str]
734 % { example }{ myobj }
735 % !simfun[tl_gset][cn]
736 % {
737 % !simfun[object_member_adr][Vn] !simvar[g_myobj_str] { myvar }
738 % }
739 % { !simvar[c_dollar_str]{} ~ dollar ~ !simvar[c_dollar_str]{} }
740 % !simfun[object_member_use][Vn] !simvar[g_myobj_str] { myvar }
741 % \end{Coding}
742 %
743 % Output: \ExplSyntaxOn
744 % \str_new:N \g_myproxy_str
745 % \proxy_create_gset:Nnn \g_myproxy_str { example }{ myproxy }
746 % \proxy_push_member:Vnn \g_myproxy_str { myvar }{ tl }
747 % \str_new:N \g_myobj_str
748 % \object_create_gset:NVnn \g_myobj_str \g_myproxy_str
749 % { example }{ myobj }
750 % \tl_gset:cn
751 % {
752 % \object_member_adr:Vn \g_myobj_str { myvar }
753 % }
754 % { \c_dollar_str{} ~ dollar ~ \c_dollar_str{} }
755 % \object_member_use:Vn \g_myobj_str { myvar }
756 % \ExplSyntaxOff
757 %
758 % You can also avoid to specify an object identify and use \cs{object_gallocate_gincr} instead:
759 %
760 % \begin{Coding}
761 % !simfun[int_new][N] !simvar[g_intc_int]
762 % !simfun[object_gallocate_gincr][NNVnNN] !simvar[g_myobj_str] !simvar[g_intc_int] !simvar[g_myproxy_str]
763 % { example } !simvar[c_object_local_str] !simvar[c_object_public_str]
764 % !simfun[tl_gset][cn]
765 % {
766 % !simfun[object_member_adr][Vn] !simvar[g_myobj_str] { myvar }
767 % }
768 % { !simvar[c_dollar_str]{} ~ dollar ~ !simvar[c_dollar_str]{} }
769 % !simfun[object_member_use][Vn] !simvar[g_myobj_str] { myvar }
770 % \end{Coding}
771 %
772 % Output: \ExplSyntaxOn
773 % \int_new:N \g_intc_int
774 % \object_gallocate_gincr:NNVnNN \g_myobj_str \g_intc_int \g_myproxy_str
775 % { example } \c_object_local_str \c_object_public_str
776 % \tl_gset:cn
777 % {
778 % \object_member_adr:Vn \g_myobj_str { myvar }
779 % }
780 % { \c_dollar_str{} ~ dollar ~ \c_dollar_str{} }
781 % \object_member_use:Vn \g_myobj_str { myvar }
782 % \ExplSyntaxOff
783 %
784 % \subsection*{Example 2}
785 % In this example we create a proxy object with an embedded object inside.
786 %
787 % Internal proxy
788 % \begin{Coding}
789 % !simfun[proxy_create][nn] { mymod }{ INT }
790 % !simfun[proxy_push_member][nnn]
791 % {
792 % !simfun[object_address][nn] { mymod }{ INT }
793 % }{ var }{ tl }
794 % \end{Coding}
795 %
796 % Container proxy
797 % \begin{Coding}
798 % !simfun[proxy_create][nn] { mymod }{ EXT }
799 % !simfun[proxy_push_embedded][nnn]
800 % {
801 % !simfun[object_address][nn] { mymod }{ EXT }
802 % }
803 % { emb }
804 % {
805 % !simfun[object_address][nn] { mymod }{ INT }
806 % }
807 % \end{Coding}
808 %
809 % Now we create a new object from proxy |EXT|. It'll contain an embedded object created with |INT| proxy:
810 % \begin{Coding}
811 % !simfun[str_new][N] !simvar[g_EXTobj_str]
812 % !simfun[int_new][N] !simvar[g_intcount_int]
813 % !simfun[object_gallocate_gincr][NNnnNN]
814 % !simvar[g_EXTobj_str] !simvar[g_intcount_int]
815 % {
816 % !simfun[object_address][nn] { mymod }{ EXT }
817 % }
818 % { mymod }
819 % !simvar[c_object_local_str] !simvar[c_object_public_str]
820 % \end{Coding}
821 % and use the embedded object in the following way:
822 % \begin{Coding}
823 % !simfun[object_member_set][nnn]
824 % {
825 % !simfun[object_embedded_adr][Vn] !simvar[g_EXTobj_str] { emb }
826 % }{ var }{ Hi }
827 % !simfun[object_member_use][nn]
828 % {
829 % !simfun[object_embedded_adr][Vn] !simvar[g_EXTobj_str] { emb }
830 % }{ var }
831 % \end{Coding}
832 % Output: \ExplSyntaxOn
833 % \proxy_create:nn{ mymod }{ INT }
834 % \proxy_push_member:nnn
835 % {
836 % \object_address:nn{ mymod }{ INT }
837 % }{ var }{ tl }
838 %
839 % \proxy_create:nn{ mymod }{ EXT }
840 % \proxy_push_embedded:nnn
841 % {
842 % \object_address:nn{ mymod }{ EXT }
843 % }
844 % { emb }
845 % {
846 % \object_address:nn{ mymod }{ INT }
847 % }
848 %
849 % \str_new:N \g_EXTobj_str
850 % \int_new:N \g_intcount_int
851 % \object_gallocate_gincr:NNnnNN
852 % \g_EXTobj_str \g_intcount_int
853 % {
854 % \object_address:nn{ mymod }{ EXT }
855 % }
856 % { mymod }
857 % \c_object_local_str \c_object_public_str
858 %
859 % \object_member_set:nnn
860 % {
861 % \object_embedded_adr:Vn \g_EXTobj_str { emb }
862 % }{ var }{ Hi }
863 % \object_member_use:nn
864 % {
865 % \object_embedded_adr:Vn \g_EXTobj_str { emb }
866 % }{ var }
867 % \ExplSyntaxOff
868 %
869 % \subsection*{Example 3}
870 % Here we show how to properly use \cs{object_member_generate:NN}. Suppose we don't know \cs{object_member_use} and we want to use \cs{tl_use:N} to get the value stored in member |MEM| of object |U| in module |MD3|.
871 %
872 % \ExplSyntaxOn
873 % \proxy_create:nn {MD3}{ex3p}
874 % \proxy_push_member:nnn { \object_address:nn {MD3}{ex3p} }{MEM}{tl}
875 % \object_create:nnn { \object_address:nn {MD3}{ex3p} }{MD3}{U}
876 % \ExplSyntaxOff
877 %
878 % We can do it in this way:
879 % \begin{Coding}
880 % !simfun[tl_use][c]
881 % {
882 % !simfun[object_member_adr][nnn]
883 % { !simfun[object_address][nn] { MD3 }{ U } }
884 % { MEM }{ tl }
885 % }
886 % \end{Coding}
887 % but this solution is not so pratical since we should write a lot of code each time. We can then use \cs{object_member_generate:NN} to define an auxilary macro \cs{myaux_print_tl:nnn} in this way:
888 % \begin{Coding}
889 % !simfun[object_member_generate][NN] \myaux_print_tl !simfun[tl_use][c]
890 % \end{Coding}
891 % then we can get the content of our member in this way:
892 % \begin{Coding}
893 % !simfun[myaux_print_tl][nnn]
894 % { !simfun[object_address][nn] { MD3 }{ U } }
895 % { MEM }{ tl }
896 % \end{Coding}
897 %
898 % For example if |U| contains |Hi| then the preceding code will output \ExplSyntaxOn
899 % \object_member_set:nnnn
900 % { \object_address:nn {MD3}{U}}{MEM}{tl}{Hi}
901 % \object_member_generate_inline:Nnn \myaux_print_tl { #1_use }{ c }
902 % \myaux_print_tl:nn
903 % { \object_address:nn {MD3}{U}}{MEM}
904 % \ExplSyntaxOff . If member |MEM| is tracked then you can use also the following command, which is generated together with \cs{myaux_print_tl:nnn}
905 % \begin{Coding}
906 % !simfun[myaux_print_tl][nn]
907 % { !simfun[object_address][nn] { MD3 }{ U } }
908 % { MEM }
909 % \end{Coding}
910 %
911 % However, this function only works with |tl| members since we use \cs{tl_use:N}, so you should define a new function for every possible type, and even if you do it newer types introduced in other packages will not be supported. In such cases you can use \cs{object_member_generate_inline:Nnn} which allows you to build the called function by specifying its name and its parameters. The preceding code then becomes
912 % \begin{Coding}
913 % !simfun[object_member_generate_inline][Nnn] \myaux_print_tl { tl_use }{ c }
914 % \end{Coding}
915 %
916 % This function does much more: in the second argument you can put also the parameters |#1| and |#2| that will expand respectively to the type of specified member and its scope. Let \cs{myaux_print:nnn} be our version of \cs{object_member_use:nnn} that retrieves the valued of the specified member, we are now able to define it in this way:
917 % \begin{Coding}
918 % !simfun[object_member_generate_inline][Nnn] \myaux_print { #1_use }{ c }
919 % \end{Coding}
920 %
921 % When you use \cs{myaux_print:nnn} on a member of type |int| it replaces all the recurrences of |#1| with |int|, thus it will call \cs{int_use:c}.
922 %\end{documentation}
923 %
924 %\begin{implementation}
925 %
926 %\section{Implementation}
927 % \begin{macrocode}
928 %<*package>
929 % \end{macrocode}
930 %
931 % \begin{macrocode}
932 %<@@=rawobjects>
933 % \end{macrocode}
934 %
935 % Deprecation message
936 % \begin{macrocode}
937
938 \msg_new:nnn { rawobjects }{ deprecate }
939 {
940 Command ~ #1 ~ is ~ deprecated. ~ Use ~ instead ~ #2
941 }
942
943 \cs_new_protected:Nn \@@_launch_deprecate:NN
944 {
945 \msg_warning:nnnn{ rawobjects }{ deprecate }{ #1 }{ #2 }
946 }
947
948 % \end{macrocode}
949 %
950 % \begin{macro}{\rwobj_address_f:n}
951 % It just performs a |c| expansion before passing it to \cs{cs_to_str:N}.
952 % \begin{macrocode}
953
954 \cs_new:Nn \rwobj_address_f:n
955 {
956 \exp_args:Nc \cs_to_str:N { #1 }
957 }
958
959 % \end{macrocode}
960 % \end{macro}
961 %
962 %\begin{variable}{\c_object_local_str, \c_object_global_str, \c_object_public_str, \c_object_private_str}
963 % \begin{macrocode}
964 \str_const:Nn \c_object_local_str {l}
965 \str_const:Nn \c_object_global_str {g}
966 \str_const:Nn \c_object_public_str {_}
967 \str_const:Nn \c_object_private_str {__}
968
969
970 \cs_new:Nn \@@_scope:N
971 {
972 \str_use:N #1
973 }
974
975 \cs_new:Nn \@@_scope_pfx:N
976 {
977 \str_if_eq:NNF #1 \c_object_local_str
978 { g }
979 }
980
981 \cs_generate_variant:Nn \@@_scope_pfx:N { c }
982
983 \cs_new:Nn \@@_scope_pfx_cl:n
984 {
985 \@@_scope_pfx:c{
986 \object_ncmember_adr:nnn
987 {
988 \object_embedded_adr:nn { #1 }{ /_I_/ }
989 }
990 { S }{ str }
991 }
992 }
993
994 \cs_new:Nn \@@_vis_var:N
995 {
996 \str_use:N #1
997 }
998
999 \cs_new:Nn \@@_vis_fun:N
1000 {
1001 \str_if_eq:NNT #1 \c_object_private_str
1002 {
1003 __
1004 }
1005 }
1006
1007 % \end{macrocode}
1008 %\end{variable}
1009 %
1010 %\begin{macro}{\object_address:nn}
1011 %Get address of an object
1012 % \begin{macrocode}
1013 \cs_new:Nn \object_address:nn {
1014 \tl_to_str:n { #1 _ #2 }
1015 }
1016 % \end{macrocode}
1017 %\end{macro}
1018 %
1019 % \begin{macro}{\object_embedded_adr:nn}
1020 % Address of embedded object
1021 % \begin{macrocode}
1022
1023 \cs_new:Nn \object_embedded_adr:nn
1024 {
1025 #1 \tl_to_str:n{ _SUB_ #2 }
1026 }
1027
1028 \cs_generate_variant:Nn \object_embedded_adr:nn{ Vn }
1029
1030 % \end{macrocode}
1031 % \end{macro}
1032 %
1033 %\begin{macro}{\object_address_set:Nnn, \object_address_gset:Nnn}
1034 % Saves the address of an object into a string variable
1035 % \begin{macrocode}
1036
1037 \cs_new_protected:Nn \object_address_set:Nnn {
1038 \str_set:Nn #1 { #2 _ #3 }
1039 }
1040
1041 \cs_new_protected:Nn \object_address_gset:Nnn {
1042 \str_gset:Nn #1 { #2 _ #3 }
1043 }
1044
1045 % \end{macrocode}
1046 %\end{macro}
1047 %
1048 %\begin{macro}[pTF]{\object_if_exist:n}
1049 %Tests if object exists.
1050 % \begin{macrocode}
1051
1052 \prg_new_conditional:Nnn \object_if_exist:n { p, T, F, TF }
1053 {
1054 \cs_if_exist:cTF
1055 {
1056 \object_ncmember_adr:nnn
1057 {
1058 \object_embedded_adr:nn{ #1 }{ /_I_/ }
1059 }
1060 { S }{ str }
1061 }
1062 {
1063 \prg_return_true:
1064 }
1065 {
1066 \prg_return_false:
1067 }
1068 }
1069
1070 \prg_generate_conditional_variant:Nnn \object_if_exist:n { V }
1071 { p, T, F, TF }
1072
1073 % \end{macrocode}
1074 %\end{macro}
1075 %
1076 %\begin{macro}{\object_get_module:n, \object_get_proxy_adr:n}
1077 %Retrieve the name, module and generating proxy of an object
1078 % \begin{macrocode}
1079 \cs_new:Nn \object_get_module:n {
1080 \object_ncmember_use:nnn
1081 {
1082 \object_embedded_adr:nn{ #1 }{ /_I_/ }
1083 }
1084 { M }{ str }
1085 }
1086 \cs_new:Nn \object_get_proxy_adr:n {
1087 \object_ncmember_use:nnn
1088 {
1089 \object_embedded_adr:nn{ #1 }{ /_I_/ }
1090 }
1091 { P }{ str }
1092 }
1093
1094 \cs_generate_variant:Nn \object_get_module:n { V }
1095 \cs_generate_variant:Nn \object_get_proxy_adr:n { V }
1096 % \end{macrocode}
1097 %\end{macro}
1098 %
1099 %\begin{macro}[pTF]{\object_if_local:n, \object_if_global:n, \object_if_public:n, \object_if_private:n}
1100 %Test the specified parameters.
1101 % \begin{macrocode}
1102 \prg_new_conditional:Nnn \object_if_local:n {p, T, F, TF}
1103 {
1104 \str_if_eq:cNTF
1105 {
1106 \object_ncmember_adr:nnn
1107 {
1108 \object_embedded_adr:nn{ #1 }{ /_I_/ }
1109 }
1110 { S }{ str }
1111 }
1112 \c_object_local_str
1113 {
1114 \prg_return_true:
1115 }
1116 {
1117 \prg_return_false:
1118 }
1119 }
1120
1121 \prg_new_conditional:Nnn \object_if_global:n {p, T, F, TF}
1122 {
1123 \str_if_eq:cNTF
1124 {
1125 \object_ncmember_adr:nnn
1126 {
1127 \object_embedded_adr:nn{ #1 }{ /_I_/ }
1128 }
1129 { S }{ str }
1130 }
1131 \c_object_global_str
1132 {
1133 \prg_return_true:
1134 }
1135 {
1136 \prg_return_false:
1137 }
1138 }
1139
1140 \prg_new_conditional:Nnn \object_if_public:n {p, T, F, TF}
1141 {
1142 \str_if_eq:cNTF
1143 {
1144 \object_ncmember_adr:nnn
1145 {
1146 \object_embedded_adr:nn{ #1 }{ /_I_/ }
1147 }
1148 { V }{ str }
1149 }
1150 \c_object_public_str
1151 {
1152 \prg_return_true:
1153 }
1154 {
1155 \prg_return_false:
1156 }
1157 }
1158
1159 \prg_new_conditional:Nnn \object_if_private:n {p, T, F, TF}
1160 {
1161 \str_if_eq:cNTF
1162 {
1163 \object_ncmember_adr:nnn
1164 {
1165 \object_embedded_adr:nn{ #1 }{ /_I_/ }
1166 }
1167 { V }{ str }
1168 }
1169 \c_object_private_str
1170 {
1171 \prg_return_true:
1172 }
1173 {
1174 \prg_return_false:
1175 }
1176 }
1177
1178 \prg_generate_conditional_variant:Nnn \object_if_local:n { V }
1179 { p, T, F, TF }
1180 \prg_generate_conditional_variant:Nnn \object_if_global:n { V }
1181 { p, T, F, TF }
1182 \prg_generate_conditional_variant:Nnn \object_if_public:n { V }
1183 { p, T, F, TF }
1184 \prg_generate_conditional_variant:Nnn \object_if_private:n { V }
1185 { p, T, F, TF }
1186 % \end{macrocode}
1187 %\end{macro}
1188 %
1189 %\begin{macro}{\object_macro_adr:nn, \object_macro_use:nn}
1190 % Generic macro address
1191 % \begin{macrocode}
1192
1193 \cs_new:Nn \object_macro_adr:nn
1194 {
1195 #1 \tl_to_str:n{ _MACRO_ #2 }
1196 }
1197
1198 \cs_generate_variant:Nn \object_macro_adr:nn{ Vn }
1199
1200 \cs_new:Nn \object_macro_use:nn
1201 {
1202 \use:c
1203 {
1204 \object_macro_adr:nn{ #1 }{ #2 }
1205 }
1206 }
1207
1208 \cs_generate_variant:Nn \object_macro_use:nn{ Vn }
1209
1210 % \end{macrocode}
1211 % \end{macro}
1212 %
1213 %\begin{macro}{\@@_member_adr:nnnNN}
1214 % Macro address without object inference
1215 % \begin{macrocode}
1216
1217 \cs_new:Nn \@@_member_adr:nnnNN
1218 {
1219 \@@_scope:N #4
1220 \@@_vis_var:N #5
1221 #1 \tl_to_str:n { _ MEMBER _ #2 _ #3 }
1222 }
1223
1224 \cs_generate_variant:Nn \@@_member_adr:nnnNN { VnnNN, nnncc }
1225
1226 % \end{macrocode}
1227 % \end{macro}
1228 %
1229 %\begin{macro}{\object_member_adr:nnn}
1230 %Get the address of a member variable
1231 % \begin{macrocode}
1232
1233 \cs_new:Nn \object_member_adr:nnn
1234 {
1235 \@@_member_adr:nnncc { #1 }{ #2 }{ #3 }
1236 {
1237 \object_ncmember_adr:nnn
1238 {
1239 \object_embedded_adr:nn{ #1 }{ /_I_/ }
1240 }
1241 { S }{ str }
1242 }
1243 {
1244 \object_ncmember_adr:nnn
1245 {
1246 \object_embedded_adr:nn{ #1 }{ /_I_/ }
1247 }
1248 { V }{ str }
1249 }
1250 }
1251
1252 \cs_generate_variant:Nn \object_member_adr:nnn { Vnn, vnn, nnv, nnf }
1253
1254 % \end{macrocode}
1255 %\end{macro}
1256 %
1257 % \begin{macro}[pTF]{\object_member_if_exist:nnn}
1258 % Tests if the specified member exists
1259 % \begin{macrocode}
1260
1261 \prg_new_conditional:Nnn \object_member_if_exist:nnn {p, T, F, TF }
1262 {
1263 \cs_if_exist:cTF
1264 {
1265 \object_member_adr:nnn { #1 }{ #2 }{ #3 }
1266 }
1267 {
1268 \prg_return_true:
1269 }
1270 {
1271 \prg_return_false:
1272 }
1273 }
1274
1275 \prg_generate_conditional_variant:Nnn \object_member_if_exist:nnn
1276 { Vnn }{ p, T, F, TF }
1277
1278 % \end{macrocode}
1279 % \end{macro}
1280 %
1281 % \begin{macro}[pTF]{\object_member_if_tracked:nn}
1282 % Tests if the member is tracked.
1283 % \begin{macrocode}
1284
1285 \prg_new_conditional:Nnn \object_member_if_tracked:nn {p, T, F, TF }
1286 {
1287 \cs_if_exist:cTF
1288 {
1289 \object_rcmember_adr:nnn
1290 { #1 }{ #2 _ type }{ str }
1291 }
1292 {
1293 \prg_return_true:
1294 }
1295 {
1296 \cs_if_exist:cTF
1297 {
1298 \object_ncmember_adr:nnn
1299 {
1300 \object_embedded_adr:nn { #1 }{ /_T_/ }
1301 }
1302 { #2 _ type }{ str }
1303 }
1304 {
1305 \prg_return_true:
1306 }
1307 {
1308 \prg_return_false:
1309 }
1310 }
1311 }
1312
1313 \prg_generate_conditional_variant:Nnn \object_member_if_tracked:nn
1314 { Vn }{ p, T, F, TF }
1315
1316 \prg_new_eq_conditional:NNn \object_member_if_exist:nn
1317 \object_member_if_tracked:nn { p, T, F, TF }
1318 \prg_new_eq_conditional:NNn \object_member_if_exist:Vn
1319 \object_member_if_tracked:Vn { p, T, F, TF }
1320
1321 % \end{macrocode}
1322 % \end{macro}
1323 %
1324 % \begin{macro}{\object_member_type:nn}
1325 % Deduce the type of tracked members.
1326 % \begin{macrocode}
1327
1328 \cs_new:Nn \object_member_type:nn
1329 {
1330 \cs_if_exist:cTF
1331 {
1332 \object_rcmember_adr:nnn
1333 { #1 }{ #2 _ type }{ str }
1334 }
1335 {
1336 \object_rcmember_use:nnn
1337 { #1 }{ #2 _ type }{ str }
1338 }
1339 {
1340 \cs_if_exist:cT
1341 {
1342 \object_ncmember_adr:nnn
1343 {
1344 \object_embedded_adr:nn { #1 }{ /_T_/ }
1345 }
1346 { #2 _ type }{ str }
1347 }
1348 {
1349 \object_ncmember_use:nnn
1350 {
1351 \object_embedded_adr:nn { #1 }{ /_T_/ }
1352 }
1353 { #2 _ type }{ str }
1354 }
1355 }
1356 }
1357
1358 % \end{macrocode}
1359 % \end{macro}
1360 %
1361 %\begin{macro}{\object_member_adr:nn}
1362 %Get the address of a member variable
1363 % \begin{macrocode}
1364
1365 \cs_new:Nn \object_member_adr:nn
1366 {
1367 \object_member_adr:nnf { #1 }{ #2 }
1368 {
1369 \object_member_type:nn { #1 }{ #2 }
1370 }
1371 }
1372
1373 \cs_generate_variant:Nn \object_member_adr:nn { Vn }
1374
1375 % \end{macrocode}
1376 %\end{macro}
1377 %
1378 % Helper functions for \cs{object_*_generate} functions.
1379 % \begin{macrocode}
1380
1381 \cs_new:Nn \@@_par_trans:N
1382 {
1383 \str_case:nnF { #1 }
1384 {
1385 { N }{ N }
1386 { V }{ N }
1387 { n }{ n }
1388 { v }{ n }
1389 { f }{ n }
1390 { x }{ n }
1391 { e }{ n }
1392 { o }{ n }
1393 { ~ }{}
1394 }
1395 { #1 }
1396 }
1397
1398 \cs_new:Nn \@@_par_trans:n
1399 {
1400 \str_map_function:nN { #1 } \@@_par_trans:N
1401 }
1402
1403 \str_new:N \l_@@_tmp_fa_str
1404
1405 \cs_new_protected:Nn \@@_save_dat:n
1406 {
1407 \str_set:Nx \l_@@_tmp_fa_str
1408 { \str_tail:n{ #1 } }
1409 }
1410 \cs_new_protected:Nn \@@_save_dat:nnN
1411 {
1412 \str_set:Nx \l_@@_tmp_fa_str
1413 { \str_tail:n{ #2 } }
1414 }
1415 \cs_new_protected:Nn \@@_save_dat_aux:n
1416 {
1417 \@@_save_dat:nnN #1
1418 }
1419 \cs_generate_variant:Nn \@@_save_dat_aux:n { f }
1420
1421 \cs_new_protected:Nn \@@_save_fun:N
1422 {
1423 \@@_save_dat_aux:f { \cs_split_function:N #1 }
1424 }
1425
1426 \cs_new:Nn \@@_use_dat:nn
1427 {
1428 #1 : #2 \str_use:N \l_@@_tmp_fa_str
1429 }
1430
1431 % \end{macrocode}
1432 %
1433 % \begin{macro}{\object_member_generate:NN, \object_member_generate_inline:Nnn, \object_member_generate_protected:NN, \object_member_generate_protected_inline:Nnn}
1434 % Generate member versions of specified functions.
1435 % \begin{macrocode}
1436
1437 \cs_new_protected:Nn \@@_mgen:nN
1438 {
1439 \@@_save_fun:N #2
1440 \cs_new:cpn { #1 : nnn \str_use:N \l_@@_tmp_fa_str } ##1##2##3
1441 {
1442 #2
1443 {
1444 \object_member_adr:nnn{ ##1 }{ ##2 }{ ##3 }
1445 }
1446 }
1447 \cs_new:cpn { #1 : nn \str_use:N \l_@@_tmp_fa_str } ##1##2
1448 {
1449 #2
1450 {
1451 \object_member_adr:nn{ ##1 }{ ##2 }
1452 }
1453 }
1454 }
1455 \cs_new_protected:Nn \@@_mgen_pr:nN
1456 {
1457 \@@_save_fun:N #2
1458 \cs_new_protected:cpn
1459 { #1 : nnn \str_use:N \l_@@_tmp_fa_str } ##1##2##3
1460 {
1461 #2
1462 {
1463 \object_member_adr:nnn{ ##1 }{ ##2 }{ ##3 }
1464 }
1465 }
1466 \cs_new_protected:cpn
1467 { #1 : nn \str_use:N \l_@@_tmp_fa_str } ##1##2
1468 {
1469 #2
1470 {
1471 \object_member_adr:nn{ ##1 }{ ##2 }
1472 }
1473 }
1474 }
1475
1476 \cs_new_protected:Nn \@@_mgen:nnn
1477 {
1478 \@@_save_dat:n { #3 }
1479
1480 \cs_new:cpn { @@_auxfun_#1 :nn } ##1##2
1481 {
1482 \use:c{ #2 : #3 }
1483 }
1484 \cs_generate_variant:cn { @@_auxfun_#1 :nn }{ nf, ff }
1485
1486 \cs_new:cpn { #1 : nnn \str_use:N \l_@@_tmp_fa_str } ##1##2##3
1487 {
1488 \use:c { @@_auxfun_#1 :nf }
1489 { ##3 }
1490 {
1491 \@@_scope_pfx_cl:n{ ##1 }
1492 }
1493 {
1494 \object_member_adr:nnn{ ##1 }{ ##2 }{ ##3 }
1495 }
1496 }
1497 \cs_new:cpn { #1 : nn \str_use:N \l_@@_tmp_fa_str } ##1##2
1498 {
1499 \use:c { @@_auxfun_#1 :ff }
1500 {
1501 \object_member_type:nn { ##1 }{ ##2 }
1502 }
1503 {
1504 \@@_scope_pfx_cl:n{ ##1 }
1505 }
1506 {
1507 \object_member_adr:nn{ ##1 }{ ##2 }
1508 }
1509 }
1510 }
1511 \cs_new_protected:Nn \@@_mgen_pr:nnn
1512 {
1513 \@@_save_dat:n { #3 }
1514
1515 \cs_new:cpn { @@_auxfun_#1 :nn } ##1##2
1516 {
1517 \use:c{ #2 : #3 }
1518 }
1519 \cs_generate_variant:cn { @@_auxfun_#1 :nn }{ nf, ff }
1520
1521 \cs_new_protected:cpn
1522 { #1 : nnn \str_use:N \l_@@_tmp_fa_str } ##1##2##3
1523 {
1524 \use:c { @@_auxfun_#1 :nf }
1525 { ##3 }
1526 {
1527 \@@_scope_pfx_cl:n{ ##1 }
1528 }
1529 {
1530 \object_member_adr:nnn{ ##1 }{ ##2 }{ ##3 }
1531 }
1532 }
1533 \cs_new_protected:cpn
1534 { #1 : nn \str_use:N \l_@@_tmp_fa_str } ##1##2
1535 {
1536 \use:c { @@_auxfun_#1 :ff }
1537 {
1538 \object_member_type:nn { ##1 }{ ##2 }
1539 }
1540 {
1541 \@@_scope_pfx_cl:n{ ##1 }
1542 }
1543 {
1544 \object_member_adr:nn{ ##1 }{ ##2 }
1545 }
1546 }
1547 }
1548
1549 \cs_generate_variant:Nn \@@_mgen:nN { fN }
1550 \cs_generate_variant:Nn \@@_mgen:nnn { fnn }
1551 \cs_generate_variant:Nn \@@_mgen_pr:nN { fN }
1552 \cs_generate_variant:Nn \@@_mgen_pr:nnn { fnn }
1553
1554 \cs_new_protected:Nn \object_member_generate:NN
1555 {
1556 \@@_mgen:fN { \cs_to_str:N #1 } #2
1557 }
1558
1559 \cs_new_protected:Nn \object_member_generate_inline:Nnn
1560 {
1561 \@@_mgen:fnn { \cs_to_str:N #1 }{ #2 }{ #3 }
1562 }
1563 \cs_new_protected:Nn \object_member_generate_protected:NN
1564 {
1565 \@@_mgen_pr:fN { \cs_to_str:N #1 } #2
1566 }
1567
1568 \cs_new_protected:Nn \object_member_generate_protected_inline:Nnn
1569 {
1570 \@@_mgen_pr:fnn { \cs_to_str:N #1 }{ #2 }{ #3 }
1571 }
1572
1573 % \end{macrocode}
1574 % \end{macro}
1575 %
1576 % \begin{macro}{\object_ncmember_generate:NN, \object_ncmember_generate_inline:Nnn, \object_ncmember_generate_protected:NN, \object_ncmember_generate_protected_inline:Nnn}
1577 % Generate ncmember versions of specified functions.
1578 % \begin{macrocode}
1579
1580 \cs_new_protected:Nn \@@_ncgen:nN
1581 {
1582 \@@_save_fun:N #2
1583 \cs_new:cpn { #1 : nnn \str_use:N \l_@@_tmp_fa_str } ##1##2##3
1584 {
1585 #2
1586 {
1587 \object_ncmember_adr:nnn{ ##1 }{ ##2 }{ ##3 }
1588 }
1589 }
1590 }
1591 \cs_new_protected:Nn \@@_ncgen_pr:nN
1592 {
1593 \@@_save_fun:N #2
1594 \cs_new_protected:cpn
1595 { #1 : nnn \str_use:N \l_@@_tmp_fa_str } ##1##2##3
1596 {
1597 #2
1598 {
1599 \object_ncmember_adr:nnn{ ##1 }{ ##2 }{ ##3 }
1600 }
1601 }
1602 }
1603
1604 \cs_new_protected:Nn \@@_ncgen:nnn
1605 {
1606 \@@_save_dat:n { #3 }
1607
1608 \cs_new:cpn { @@_auxfun_#1 :nn } ##1##2
1609 {
1610 \use:c{ #2 : #3 }
1611 }
1612 \cs_generate_variant:cn { @@_auxfun_#1 :nn }{ nf }
1613
1614 \cs_new:cpn { #1 : nnn \str_use:N \l_@@_tmp_fa_str } ##1##2##3
1615 {
1616 \use:c { @@_auxfun_#1 :nf }
1617 { ##3 }
1618 {
1619 \@@_scope_pfx_cl:n{ ##1 }
1620 }
1621 {
1622 \object_ncmember_adr:nnn{ ##1 }{ ##2 }{ ##3 }
1623 }
1624 }
1625 }
1626 \cs_new_protected:Nn \@@_ncgen_pr:nnn
1627 {
1628 \@@_save_dat:n { #3 }
1629
1630 \cs_new:cpn { @@_auxfun_#1 :nn } ##1##2
1631 {
1632 \use:c{ #2 : #3 }
1633 }
1634 \cs_generate_variant:cn { @@_auxfun_#1 :nn }{ nf }
1635
1636 \cs_new_protected:cpn
1637 { #1 : nnn \str_use:N \l_@@_tmp_fa_str } ##1##2##3
1638 {
1639 \use:c { @@_auxfun_#1 :nf }
1640 { ##3 }
1641 {
1642 \@@_scope_pfx_cl:n{ ##1 }
1643 }
1644 {
1645 \object_ncmember_adr:nnn{ ##1 }{ ##2 }{ ##3 }
1646 }
1647 }
1648 }
1649
1650 \cs_generate_variant:Nn \@@_ncgen:nN { fN }
1651 \cs_generate_variant:Nn \@@_ncgen:nnn { fnn }
1652 \cs_generate_variant:Nn \@@_ncgen_pr:nN { fN }
1653 \cs_generate_variant:Nn \@@_ncgen_pr:nnn { fnn }
1654
1655 \cs_new_protected:Nn \object_ncmember_generate:NN
1656 {
1657 \@@_ncgen:fN { \cs_to_str:N #1 } #2
1658 }
1659
1660 \cs_new_protected:Nn \object_ncmember_generate_inline:Nnn
1661 {
1662 \@@_ncgen:fnn { \cs_to_str:N #1 }{ #2 }{ #3 }
1663 }
1664 \cs_new_protected:Nn \object_ncmember_generate_protected:NN
1665 {
1666 \@@_ncgen_pr:fN { \cs_to_str:N #1 } #2
1667 }
1668
1669 \cs_new_protected:Nn \object_ncmember_generate_protected_inline:Nnn
1670 {
1671 \@@_ncgen_pr:fnn { \cs_to_str:N #1 }{ #2 }{ #3 }
1672 }
1673
1674 % \end{macrocode}
1675 % \end{macro}
1676 %
1677 % \begin{macro}{\object_rcmember_generate:NN, \object_rcmember_generate_inline:Nnn, \object_rcmember_generate_protected:NN, \object_rcmember_generate_protected_inline:Nnn}
1678 % Generate ncmember versions of specified functions.
1679 % \begin{macrocode}
1680
1681 \cs_new_protected:Nn \@@_rcgen:nN
1682 {
1683 \@@_save_fun:N #2
1684 \cs_new:cpn { #1 : nnn \str_use:N \l_@@_tmp_fa_str } ##1##2##3
1685 {
1686 #2
1687 {
1688 \object_rcmember_adr:nnn{ ##1 }{ ##2 }{ ##3 }
1689 }
1690 }
1691 }
1692 \cs_new_protected:Nn \@@_rcgen_pr:nN
1693 {
1694 \@@_save_fun:N #2
1695 \cs_new_protected:cpn
1696 { #1 : nnn \str_use:N \l_@@_tmp_fa_str } ##1##2##3
1697 {
1698 #2
1699 {
1700 \object_rcmember_adr:nnn{ ##1 }{ ##2 }{ ##3 }
1701 }
1702 }
1703 }
1704
1705 \cs_new_protected:Nn \@@_rcgen:nnn
1706 {
1707 \@@_save_dat:n { #3 }
1708
1709 \cs_new:cpn { @@_auxfun_#1 :nn } ##1##2
1710 {
1711 \use:c{ #2 : #3 }
1712 }
1713 \cs_generate_variant:cn { @@_auxfun_#1 :nn }{ nf }
1714
1715 \cs_new:cpn { #1 : nnn \str_use:N \l_@@_tmp_fa_str } ##1##2##3
1716 {
1717 \use:c { @@_auxfun_#1 :nf }
1718 { ##3 }
1719 {
1720 \@@_scope_pfx_cl:n{ ##1 }
1721 }
1722 {
1723 \object_rcmember_adr:nnn{ ##1 }{ ##2 }{ ##3 }
1724 }
1725 }
1726 }
1727 \cs_new_protected:Nn \@@_rcgen_pr:nnn
1728 {
1729 \@@_save_dat:n { #3 }
1730
1731 \cs_new:cpn { @@_auxfun_#1 :nn } ##1##2
1732 {
1733 \use:c{ #2 : #3 }
1734 }
1735 \cs_generate_variant:cn { @@_auxfun_#1 :nn }{ nf }
1736
1737 \cs_new_protected:cpn
1738 { #1 : nnn \str_use:N \l_@@_tmp_fa_str } ##1##2##3
1739 {
1740 \use:c { @@_auxfun_#1 :nf }
1741 { ##3 }
1742 {
1743 \@@_scope_pfx_cl:n{ ##1 }
1744 }
1745 {
1746 \object_rcmember_adr:nnn{ ##1 }{ ##2 }{ ##3 }
1747 }
1748 }
1749 }
1750
1751 \cs_generate_variant:Nn \@@_rcgen:nN { fN }
1752 \cs_generate_variant:Nn \@@_rcgen:nnn { fnn }
1753 \cs_generate_variant:Nn \@@_rcgen_pr:nN { fN }
1754 \cs_generate_variant:Nn \@@_rcgen_pr:nnn { fnn }
1755
1756 \cs_new_protected:Nn \object_rcmember_generate:NN
1757 {
1758 \@@_rcgen:fN { \cs_to_str:N #1 } #2
1759 }
1760
1761 \cs_new_protected:Nn \object_rcmember_generate_inline:Nnn
1762 {
1763 \@@_rcgen:fnn { \cs_to_str:N #1 }{ #2 }{ #3 }
1764 }
1765 \cs_new_protected:Nn \object_rcmember_generate_protected:NN
1766 {
1767 \@@_rcgen_pr:fN { \cs_to_str:N #1 } #2
1768 }
1769
1770 \cs_new_protected:Nn \object_rcmember_generate_protected_inline:Nnn
1771 {
1772 \@@_rcgen_pr:fnn { \cs_to_str:N #1 }{ #2 }{ #3 }
1773 }
1774
1775 % \end{macrocode}
1776 % \end{macro}
1777 %
1778 % Auxilary functions
1779 % \begin{macrocode}
1780
1781 \cs_generate_variant:Nn \cs_generate_variant:Nn { cx }
1782
1783 \cs_new_protected:Nn \@@_genmem_int:nnn
1784 {
1785 \@@_mgen:nnn { #1 }{ #2 }{ #3 }
1786 \cs_generate_variant:cx
1787 { #1 : nnn \str_use:N \l_@@_tmp_fa_str }
1788 { Vnn \str_use:N \l_@@_tmp_fa_str, nnv \str_use:N \l_@@_tmp_fa_str }
1789 \cs_generate_variant:cx
1790 { #1 : nn \str_use:N \l_@@_tmp_fa_str }
1791 { Vn \str_use:N \l_@@_tmp_fa_str }
1792 }
1793 \cs_new_protected:Nn \@@_genmem_pr_int:nnn
1794 {
1795 \@@_mgen_pr:nnn { #1 }{ #2 }{ #3 }
1796 \cs_generate_variant:cx
1797 { #1 : nnn \str_use:N \l_@@_tmp_fa_str }
1798 { Vnn \str_use:N \l_@@_tmp_fa_str, nnv \str_use:N \l_@@_tmp_fa_str }
1799 \cs_generate_variant:cx
1800 { #1 : nn \str_use:N \l_@@_tmp_fa_str }
1801 { Vn \str_use:N \l_@@_tmp_fa_str }
1802 }
1803
1804 \cs_new_protected:Nn \@@_genncm_int:nnn
1805 {
1806 \@@_ncgen:nnn { #1 }{ #2 }{ #3 }
1807 \cs_generate_variant:cx
1808 { #1 : nnn \str_use:N \l_@@_tmp_fa_str }
1809 { Vnn \str_use:N \l_@@_tmp_fa_str }
1810 }
1811 \cs_new_protected:Nn \@@_genncm_pr_int:nnn
1812 {
1813 \@@_ncgen_pr:nnn { #1 }{ #2 }{ #3 }
1814 \cs_generate_variant:cx
1815 { #1 : nnn \str_use:N \l_@@_tmp_fa_str }
1816 { Vnn \str_use:N \l_@@_tmp_fa_str }
1817 }
1818
1819 \cs_new_protected:Nn \@@_genrcm_int:nnn
1820 {
1821 \@@_rcgen:nnn { #1 }{ #2 }{ #3 }
1822 \cs_generate_variant:cx
1823 { #1 : nnn \str_use:N \l_@@_tmp_fa_str }
1824 { Vnn \str_use:N \l_@@_tmp_fa_str }
1825 }
1826 \cs_new_protected:Nn \@@_genrcm_pr_int:nnn
1827 {
1828 \@@_rcgen_pr:nnn { #1 }{ #2 }{ #3 }
1829 \cs_generate_variant:cx
1830 { #1 : nnn \str_use:N \l_@@_tmp_fa_str }
1831 { Vnn \str_use:N \l_@@_tmp_fa_str }
1832 }
1833
1834 % \end{macrocode}
1835 %
1836 % \begin{macrocode}
1837
1838 \msg_new:nnnn { rawobjects }{ noerr }{ Unspecified ~ scope }
1839 {
1840 Object ~ #1 ~ hasn't ~ a ~ scope ~ variable
1841 }
1842
1843 % \end{macrocode}
1844 %
1845 %\begin{macro}{\object_new_member:nnn, \object_new_member_tracked:nnn}
1846 %Creates a new member variable
1847 % \begin{macrocode}
1848
1849 \@@_genmem_pr_int:nnn { object_new_member }{ #1 _ new }{ c }
1850
1851 \cs_new_protected:Nn \object_new_member_tracked:nnn
1852 {
1853 \object_new_member:nnn { #1 }{ #2 }{ #3 }
1854
1855 \str_const:cn
1856 {
1857 \object_ncmember_adr:nnn
1858 {
1859 \object_embedded_adr:nn { #1 }{ /_T_/ }
1860 }
1861 { #2 _ type }{ str }
1862 }
1863 { #3 }
1864 }
1865
1866 \cs_generate_variant:Nn \object_new_member_tracked:nnn { Vnn, nnv }
1867
1868 % \end{macrocode}
1869 %\end{macro}
1870 %
1871 %\begin{macro}{\object_member_use:nnn, \object_member_use:nn}
1872 %Uses a member variable
1873 % \begin{macrocode}
1874
1875 \@@_genmem_int:nnn {object_member_use}{ #1_use }{c}
1876
1877 \cs_generate_variant:Nn \object_member_use:nnn {vnn}
1878
1879 % \end{macrocode}
1880 %\end{macro}
1881 %
1882 %\begin{macro}{\object_member_set:nnnn, \object_member_set:nnn}
1883 % Set the value a member.
1884 % \begin{macrocode}
1885
1886 \@@_genmem_pr_int:nnn {object_member_set}{ #1_#2 set }{ cn }
1887
1888 % \end{macrocode}
1889 %\end{macro}
1890 %
1891 %\begin{macro}{\object_member_set_eq:nnnN, \object_member_set_eq:nnN}
1892 % Make a member equal to another variable.
1893 % \begin{macrocode}
1894
1895 \@@_genmem_pr_int:nnn { object_member_set_eq }{ #1 _ #2 set_eq }{ cN }
1896
1897 \cs_generate_variant:Nn \object_member_set_eq:nnnN { nnnc, Vnnc }
1898
1899 \cs_generate_variant:Nn \object_member_set_eq:nnN { nnc, Vnc }
1900
1901 % \end{macrocode}
1902 %\end{macro}
1903 %
1904 % \begin{macro}{\object_ncmember_adr:nnn}
1905 % Get address of near constant
1906 % \begin{macrocode}
1907
1908 \cs_new:Nn \object_ncmember_adr:nnn
1909 {
1910 \tl_to_str:n{ c _ } #1 \tl_to_str:n { _ CONST _ #2 _ #3 }
1911 }
1912
1913 \cs_generate_variant:Nn \object_ncmember_adr:nnn { Vnn, vnn }
1914
1915 % \end{macrocode}
1916 % \end{macro}
1917 %
1918 %\begin{macro}{\object_rcmember_adr:nnn}
1919 % Get the address of a remote constant.
1920 % \begin{macrocode}
1921
1922 \cs_new:Nn \object_rcmember_adr:nnn
1923 {
1924 \object_ncmember_adr:vnn
1925 {
1926 \object_ncmember_adr:nnn
1927 {
1928 \object_embedded_adr:nn{ #1 }{ /_I_/ }
1929 }
1930 { P }{ str }
1931 }
1932 { #2 }{ #3 }
1933 }
1934
1935 \cs_generate_variant:Nn \object_rcmember_adr:nnn { Vnn }
1936 % \end{macrocode}
1937 %\end{macro}
1938 %
1939 % \begin{macro}[pTF]{\object_ncmember_if_exist:nnn, \object_rcmember_if_exist:nnn}
1940 % Tests if the specified member constant exists.
1941 % \begin{macrocode}
1942
1943 \prg_new_conditional:Nnn \object_ncmember_if_exist:nnn {p, T, F, TF }
1944 {
1945 \cs_if_exist:cTF
1946 {
1947 \object_ncmember_adr:nnn { #1 }{ #2 }{ #3 }
1948 }
1949 {
1950 \prg_return_true:
1951 }
1952 {
1953 \prg_return_false:
1954 }
1955 }
1956
1957 \prg_new_conditional:Nnn \object_rcmember_if_exist:nnn {p, T, F, TF }
1958 {
1959 \cs_if_exist:cTF
1960 {
1961 \object_rcmember_adr:nnn { #1 }{ #2 }{ #3 }
1962 }
1963 {
1964 \prg_return_true:
1965 }
1966 {
1967 \prg_return_false:
1968 }
1969 }
1970
1971 \prg_generate_conditional_variant:Nnn \object_ncmember_if_exist:nnn
1972 { Vnn }{ p, T, F, TF }
1973 \prg_generate_conditional_variant:Nnn \object_rcmember_if_exist:nnn
1974 { Vnn }{ p, T, F, TF }
1975
1976 % \end{macrocode}
1977 % \end{macro}
1978 %
1979 %\begin{macro}{\object_ncmember_use:nnn, \object_rcmember_use:nnn}
1980 % Uses a near/remote constant.
1981 % \begin{macrocode}
1982
1983 \@@_genncm_int:nnn { object_ncmember_use }{ #1_use}{ c }
1984
1985 \@@_genrcm_int:nnn { object_rcmember_use }{ #1_use}{ c }
1986
1987 % \end{macrocode}
1988 %\end{macro}
1989 %
1990 % \begin{macro}{\object_newconst:nnnn}
1991 % Creates a constant variable, use with caution
1992 % \begin{macrocode}
1993
1994 \@@_genncm_pr_int:nnn { object_newconst }{ #1 _ const }{ cn }
1995
1996 % \end{macrocode}
1997 % \end{macro}
1998 %
1999 % \begin{macro}{\object_newconst_tl:nnn, \object_newconst_str:nnn, \object_newconst_int:nnn, \object_newconst_clist:nnn, \object_newconst_dim:nnn, \object_newconst_skip:nnn, \object_newconst_fp:nnn}
2000 % Create constants
2001 % \begin{macrocode}
2002
2003 \cs_new_protected:Nn \object_newconst_tl:nnn
2004 {
2005 \object_newconst:nnnn { #1 }{ #2 }{ tl }{ #3 }
2006 }
2007 \cs_new_protected:Nn \object_newconst_str:nnn
2008 {
2009 \object_newconst:nnnn { #1 }{ #2 }{ str }{ #3 }
2010 }
2011 \cs_new_protected:Nn \object_newconst_int:nnn
2012 {
2013 \object_newconst:nnnn { #1 }{ #2 }{ int }{ #3 }
2014 }
2015 \cs_new_protected:Nn \object_newconst_clist:nnn
2016 {
2017 \object_newconst:nnnn { #1 }{ #2 }{ clist }{ #3 }
2018 }
2019 \cs_new_protected:Nn \object_newconst_dim:nnn
2020 {
2021 \object_newconst:nnnn { #1 }{ #2 }{ dim }{ #3 }
2022 }
2023 \cs_new_protected:Nn \object_newconst_skip:nnn
2024 {
2025 \object_newconst:nnnn { #1 }{ #2 }{ skip }{ #3 }
2026 }
2027 \cs_new_protected:Nn \object_newconst_fp:nnn
2028 {
2029 \object_newconst:nnnn { #1 }{ #2 }{ fp }{ #3 }
2030 }
2031
2032 \cs_generate_variant:Nn \object_newconst_tl:nnn { Vnn }
2033 \cs_generate_variant:Nn \object_newconst_str:nnn { Vnn }
2034 \cs_generate_variant:Nn \object_newconst_int:nnn { Vnn }
2035 \cs_generate_variant:Nn \object_newconst_clist:nnn { Vnn }
2036 \cs_generate_variant:Nn \object_newconst_dim:nnn { Vnn }
2037 \cs_generate_variant:Nn \object_newconst_skip:nnn { Vnn }
2038 \cs_generate_variant:Nn \object_newconst_fp:nnn { Vnn }
2039
2040
2041 \cs_generate_variant:Nn \object_newconst_str:nnn { nnx }
2042 \cs_generate_variant:Nn \object_newconst_str:nnn { nnV }
2043
2044 % \end{macrocode}
2045 %\end{macro}
2046 %
2047 % \begin{macro}{\object_newconst_seq_from_clist:nnn}
2048 % Creates a |seq| constant.
2049 % \begin{macrocode}
2050
2051 \cs_new_protected:Nn \object_newconst_seq_from_clist:nnn
2052 {
2053 \seq_const_from_clist:cn
2054 {
2055 \object_ncmember_adr:nnn { #1 }{ #2 }{ seq }
2056 }
2057 { #3 }
2058 }
2059
2060 \cs_generate_variant:Nn \object_newconst_seq_from_clist:nnn { Vnn }
2061
2062 % \end{macrocode}
2063 %\end{macro}
2064 %
2065 % \begin{macro}{\object_newconst_prop_from_keyval:nnn}
2066 % Creates a |prop| constant.
2067 % \begin{macrocode}
2068
2069 \cs_new_protected:Nn \object_newconst_prop_from_keyval:nnn
2070 {
2071 \prop_const_from_keyval:cn
2072 {
2073 \object_ncmember_adr:nnn { #1 }{ #2 }{ prop }
2074 }
2075 { #3 }
2076 }
2077
2078 \cs_generate_variant:Nn \object_newconst_prop_from_keyval:nnn { Vnn }
2079
2080 % \end{macrocode}
2081 %\end{macro}
2082 %
2083 %
2084 % \begin{macro}{\object_ncmethod_adr:nnn, \object_rcmethod_adr:nnn}
2085 % Fully expands to the method address.
2086 % \begin{macrocode}
2087
2088 \cs_new:Nn \object_ncmethod_adr:nnn
2089 {
2090 #1 \tl_to_str:n { _ CMETHOD _ #2 : #3 }
2091 }
2092
2093 \cs_generate_variant:Nn \object_ncmethod_adr:nnn { Vnn , vnn }
2094
2095 \cs_new:Nn \object_rcmethod_adr:nnn
2096 {
2097 \object_ncmethod_adr:vnn
2098 {
2099 \object_ncmember_adr:nnn
2100 {
2101 \object_embedded_adr:nn{ #1 }{ /_I_/ }
2102 }
2103 { P }{ str }
2104 }
2105 { #2 }{ #3 }
2106 }
2107
2108 \cs_generate_variant:Nn \object_ncmethod_adr:nnn { Vnn , vnn }
2109 \cs_generate_variant:Nn \object_rcmethod_adr:nnn { Vnn }
2110
2111 % \end{macrocode}
2112 % \end{macro}
2113 %
2114 % \begin{macro}[pTF]{\object_ncmethod_if_exist:nnn, \object_rcmethod_if_exist:nnn}
2115 % Tests if the specified member constant exists.
2116 % \begin{macrocode}
2117
2118 \prg_new_conditional:Nnn \object_ncmethod_if_exist:nnn {p, T, F, TF }
2119 {
2120 \cs_if_exist:cTF
2121 {
2122 \object_ncmethod_adr:nnn { #1 }{ #2 }{ #3 }
2123 }
2124 {
2125 \prg_return_true:
2126 }
2127 {
2128 \prg_return_false:
2129 }
2130 }
2131
2132 \prg_new_conditional:Nnn \object_rcmethod_if_exist:nnn {p, T, F, TF }
2133 {
2134 \cs_if_exist:cTF
2135 {
2136 \object_rcmethodr_adr:nnn { #1 }{ #2 }{ #3 }
2137 }
2138 {
2139 \prg_return_true:
2140 }
2141 {
2142 \prg_return_false:
2143 }
2144 }
2145
2146 \prg_generate_conditional_variant:Nnn \object_ncmethod_if_exist:nnn
2147 { Vnn }{ p, T, F, TF }
2148 \prg_generate_conditional_variant:Nnn \object_rcmethod_if_exist:nnn
2149 { Vnn }{ p, T, F, TF }
2150
2151 % \end{macrocode}
2152 % \end{macro}
2153 %
2154 % \begin{macro}{\object_new_cmethod:nnnn}
2155 % Creates a new method
2156 % \begin{macrocode}
2157
2158 \cs_new_protected:Nn \object_new_cmethod:nnnn
2159 {
2160 \cs_new:cn
2161 {
2162 \object_ncmethod_adr:nnn { #1 }{ #2 }{ #3 }
2163 }
2164 { #4 }
2165 }
2166
2167 \cs_generate_variant:Nn \object_new_cmethod:nnnn { Vnnn }
2168
2169 % \end{macrocode}
2170 % \end{macro}
2171 %
2172 % \begin{macro}{\object_ncmethod_call:nnn, \object_rcmethod_call:nnn}
2173 % Calls the specified method.
2174 % \begin{macrocode}
2175
2176 \cs_new:Nn \object_ncmethod_call:nnn
2177 {
2178 \use:c
2179 {
2180 \object_ncmethod_adr:nnn { #1 }{ #2 }{ #3 }
2181 }
2182 }
2183
2184 \cs_new:Nn \object_rcmethod_call:nnn
2185 {
2186 \use:c
2187 {
2188 \object_rcmethod_adr:nnn { #1 }{ #2 }{ #3 }
2189 }
2190 }
2191
2192 \cs_generate_variant:Nn \object_ncmethod_call:nnn { Vnn }
2193 \cs_generate_variant:Nn \object_rcmethod_call:nnn { Vnn }
2194
2195 % \end{macrocode}
2196 % \end{macro}
2197 %
2198 % \begin{macrocode}
2199
2200 \cs_new_protected:Nn \@@_initproxy:nnn
2201 {
2202 \object_newconst:nnnn
2203 {
2204 \object_embedded_adr:nn{ #3 }{ /_I_/ }
2205 }
2206 { ifprox }{ bool }{ \c_true_bool }
2207 }
2208 \cs_generate_variant:Nn \@@_initproxy:nnn { VnV }
2209
2210 % \end{macrocode}
2211 %
2212 %
2213 %\begin{macro}[pTF]{\object_if_proxy:n}
2214 %Test if an object is a proxy.
2215 % \begin{macrocode}
2216
2217 \cs_new:Nn \@@_bol_com:N
2218 {
2219 \cs_if_exist_p:N #1 && \bool_if_p:N #1
2220 }
2221
2222 \cs_generate_variant:Nn \@@_bol_com:N { c }
2223
2224 \prg_new_conditional:Nnn \object_if_proxy:n {p, T, F, TF}
2225 {
2226 \cs_if_exist:cTF
2227 {
2228 \object_ncmember_adr:nnn
2229 {
2230 \object_embedded_adr:nn{ #1 }{ /_I_/ }
2231 }
2232 { ifprox }{ bool }
2233 }
2234 {
2235 \bool_if:cTF
2236 {
2237 \object_ncmember_adr:nnn
2238 {
2239 \object_embedded_adr:nn{ #1 }{ /_I_/ }
2240 }
2241 { ifprox }{ bool }
2242 }
2243 {
2244 \prg_return_true:
2245 }
2246 {
2247 \prg_return_false:
2248 }
2249 }
2250 {
2251 \prg_return_false:
2252 }
2253 }
2254
2255 % \end{macrocode}
2256 %\end{macro}
2257 %
2258 %\begin{macro}[pTF]{\object_test_proxy:nn, \object_test_proxy:nN}
2259 %Test if an object is generated from selected proxy.
2260 % \begin{macrocode}
2261
2262 \prg_generate_conditional_variant:Nnn \str_if_eq:nn { ve }{ TF }
2263
2264 \prg_new_conditional:Nnn \object_test_proxy:nn {p, T, F, TF}
2265 {
2266 \str_if_eq:veTF
2267 {
2268 \object_ncmember_adr:nnn
2269 {
2270 \object_embedded_adr:nn{ #1 }{ /_I_/ }
2271 }
2272 { P }{ str }
2273 }
2274 { #2 }
2275 {
2276 \prg_return_true:
2277 }
2278 {
2279 \prg_return_false:
2280 }
2281 }
2282
2283 \prg_new_conditional:Nnn \object_test_proxy:nN {p, T, F, TF}
2284 {
2285 \str_if_eq:cNTF
2286 {
2287 \object_ncmember_adr:nnn
2288 {
2289 \object_embedded_adr:nn{ #1 }{ /_I_/ }
2290 }
2291 { P }{ str }
2292 }
2293 #2
2294 {
2295 \prg_return_true:
2296 }
2297 {
2298 \prg_return_false:
2299 }
2300 }
2301
2302 \prg_generate_conditional_variant:Nnn \object_test_proxy:nn
2303 { Vn }{p, T, F, TF}
2304 \prg_generate_conditional_variant:Nnn \object_test_proxy:nN
2305 { VN }{p, T, F, TF}
2306
2307 % \end{macrocode}
2308 %\end{macro}
2309 %
2310 % \begin{macro}{\object_create:nnnNN, \object_create_set:NnnnNN, \object_create_gset:NnnnNN, \object_create:nnnN, \object_create_set:NnnnN, \object_create_gset:NnnnN, \object_create:nnn, \object_create_set:Nnnn, \object_create_gset:Nnnn, \embedded_create:nnn}
2311 % Creates an object from a proxy.
2312 % \begin{macrocode}
2313
2314 \msg_new:nnnn { rawobjects }{ notproxy }{ Fake ~ proxy }
2315 {
2316 Object ~ #1 ~ is ~ not ~ a ~ proxy.
2317 }
2318
2319 \cs_new_protected:Nn \@@_force_proxy:n
2320 {
2321 \object_if_proxy:nF { #1 }
2322 {
2323 \msg_error:nnn { rawobjects }{ notproxy }{ #1 }
2324 }
2325 }
2326
2327 \cs_new_protected:Nn \@@_create_anon:nnnNN
2328 {
2329 \tl_if_empty:nF{ #1 }
2330 {
2331
2332 \@@_force_proxy:n { #1 }
2333
2334
2335 \object_newconst_str:nnn
2336 {
2337 \object_embedded_adr:nn{ #3 }{ /_I_/ }
2338 }
2339 { M }{ #2 }
2340 \object_newconst_str:nnn
2341 {
2342 \object_embedded_adr:nn{ #3 }{ /_I_/ }
2343 }
2344 { P }{ #1 }
2345 \object_newconst_str:nnV
2346 {
2347 \object_embedded_adr:nn{ #3 }{ /_I_/ }
2348 }
2349 { S } #4
2350 \object_newconst_str:nnV
2351 {
2352 \object_embedded_adr:nn{ #3 }{ /_I_/ }
2353 }
2354 { V } #5
2355
2356 \seq_map_inline:cn
2357 {
2358 \object_member_adr:nnn { #1 }{ varlist }{ seq }
2359 }
2360 {
2361 \object_new_member:nnv { #3 }{ ##1 }
2362 {
2363 \object_ncmember_adr:nnn { #1 }{ ##1 _ type }{ str }
2364 }
2365 }
2366
2367 \seq_map_inline:cn
2368 {
2369 \object_member_adr:nnn { #1 }{ objlist }{ seq }
2370 }
2371 {
2372 \embedded_create:nvn
2373 { #3 }
2374 {
2375 \object_ncmember_adr:nnn { #1 }{ ##1 _ proxy }{ str }
2376 }
2377 { ##1 }
2378 }
2379
2380 \tl_map_inline:cn
2381 {
2382 \object_member_adr:nnn { #1 }{ init }{ tl }
2383 }
2384 {
2385 ##1 { #1 }{ #2 }{ #3 }
2386 }
2387
2388 }
2389 }
2390
2391 \cs_generate_variant:Nn \@@_create_anon:nnnNN { xnxNN, xvxcc }
2392
2393 \cs_new_protected:Nn \object_create:nnnNN
2394 {
2395 \@@_create_anon:xnxNN { #1 }{ #2 }
2396 { \object_address:nn { #2 }{ #3 } }
2397 #4 #5
2398 }
2399
2400 \cs_generate_variant:Nn \object_create:nnnNN { VnnNN }
2401
2402 \cs_new_protected:Nn \object_create_set:NnnnNN
2403 {
2404 \object_create:nnnNN { #2 }{ #3 }{ #4 } #5 #6
2405 \str_set:Nx #1 { \object_address:nn { #3 }{ #4 } }
2406 }
2407
2408 \cs_new_protected:Nn \object_create_gset:NnnnNN
2409 {
2410 \object_create:nnnNN { #2 }{ #3 }{ #4 } #5 #6
2411 \str_gset:Nx #1 { \object_address:nn { #3 }{ #4 } }
2412 }
2413
2414 \cs_generate_variant:Nn \object_create_set:NnnnNN { NVnnNN, NnnfNN }
2415 \cs_generate_variant:Nn \object_create_gset:NnnnNN { NVnnNN, NnnfNN }
2416
2417
2418
2419 \cs_new_protected:Nn \object_create:nnnN
2420 {
2421 \object_create:nnnNN { #1 }{ #2 }{ #3 } #4 \c_object_public_str
2422 }
2423
2424 \cs_generate_variant:Nn \object_create:nnnN { VnnN }
2425
2426 \cs_new_protected:Nn \object_create_set:NnnnN
2427 {
2428 \object_create_set:NnnnNN #1 { #2 }{ #3 }{ #4 } #5 \c_object_public_str
2429 }
2430
2431 \cs_new_protected:Nn \object_create_gset:NnnnN
2432 {
2433 \object_create_gset:NnnnNN #1 { #2 }{ #3 }{ #4 } #5 \c_object_public_str
2434 }
2435
2436 \cs_generate_variant:Nn \object_create_set:NnnnN { NVnnN }
2437 \cs_generate_variant:Nn \object_create_gset:NnnnN { NVnnN }
2438
2439 \cs_new_protected:Nn \object_create:nnn
2440 {
2441 \object_create:nnnNN { #1 }{ #2 }{ #3 }
2442 \c_object_global_str \c_object_public_str
2443 }
2444
2445 \cs_generate_variant:Nn \object_create:nnn { Vnn }
2446
2447 \cs_new_protected:Nn \object_create_set:Nnnn
2448 {
2449 \object_create_set:NnnnNN #1 { #2 }{ #3 }{ #4 }
2450 \c_object_global_str \c_object_public_str
2451 }
2452
2453 \cs_new_protected:Nn \object_create_gset:Nnnn
2454 {
2455 \object_create_gset:NnnnNN #1 { #2 }{ #3 }{ #4 }
2456 \c_object_global_str \c_object_public_str
2457 }
2458
2459 \cs_generate_variant:Nn \object_create_set:Nnnn { NVnn }
2460 \cs_generate_variant:Nn \object_create_gset:Nnnn { NVnn }
2461
2462
2463
2464
2465 \cs_new_protected:Nn \embedded_create:nnn
2466 {
2467 \@@_create_anon:xvxcc { #2 }
2468 {
2469 \object_ncmember_adr:nnn
2470 {
2471 \object_embedded_adr:nn{ #1 }{ /_I_/ }
2472 }
2473 { M }{ str }
2474 }
2475 {
2476 \object_embedded_adr:nn
2477 { #1 }{ #3 }
2478 }
2479 {
2480 \object_ncmember_adr:nnn
2481 {
2482 \object_embedded_adr:nn{ #1 }{ /_I_/ }
2483 }
2484 { S }{ str }
2485 }
2486 {
2487 \object_ncmember_adr:nnn
2488 {
2489 \object_embedded_adr:nn{ #1 }{ /_I_/ }
2490 }
2491 { V }{ str }
2492 }
2493 }
2494
2495 \cs_generate_variant:Nn \embedded_create:nnn { nvn, Vnn }
2496
2497 % \end{macrocode}
2498 %\end{macro}
2499 %
2500 %\begin{macro}{\proxy_create:nn, \proxy_create_set:Nnn, \proxy_create_gset:Nnn}
2501 %Creates a new proxy object
2502 % \begin{macrocode}
2503
2504 \cs_new_protected:Nn \proxy_create:nn
2505 {
2506 \object_create:VnnNN \c_proxy_address_str { #1 }{ #2 }
2507 \c_object_global_str \c_object_public_str
2508 }
2509
2510 \cs_new_protected:Nn \proxy_create_set:Nnn
2511 {
2512 \object_create_set:NVnnNN #1 \c_proxy_address_str { #2 }{ #3 }
2513 \c_object_global_str \c_object_public_str
2514 }
2515
2516 \cs_new_protected:Nn \proxy_create_gset:Nnn
2517 {
2518 \object_create_gset:NVnnNN #1 \c_proxy_address_str { #2 }{ #3 }
2519 \c_object_global_str \c_object_public_str
2520 }
2521
2522
2523
2524 \cs_new_protected:Nn \proxy_create:nnN
2525 {
2526 \@@_launch_deprecate:NN \proxy_create:nnN \proxy_create:nn
2527 \object_create:VnnNN \c_proxy_address_str { #1 }{ #2 }
2528 \c_object_global_str #3
2529 }
2530
2531 \cs_new_protected:Nn \proxy_create_set:NnnN
2532 {
2533 \@@_launch_deprecate:NN \proxy_create_set:NnnN \proxy_create_set:Nnn
2534 \object_create_set:NVnnNN #1 \c_proxy_address_str { #2 }{ #3 }
2535 \c_object_global_str #4
2536 }
2537
2538 \cs_new_protected:Nn \proxy_create_gset:NnnN
2539 {
2540 \@@_launch_deprecate:NN \proxy_create_gset:NnnN \proxy_create_gset:Nnn
2541 \object_create_gset:NVnnNN #1 \c_proxy_address_str { #2 }{ #3 }
2542 \c_object_global_str #4
2543 }
2544
2545 % \end{macrocode}
2546 %\end{macro}
2547 %
2548 %\begin{macro}{\proxy_push_member:nnn}
2549 % Push a new member inside a proxy.
2550 % \begin{macrocode}
2551
2552 \cs_new_protected:Nn \proxy_push_member:nnn
2553 {
2554 \object_newconst_str:nnn { #1 }{ #2 _ type }{ #3 }
2555 \seq_gput_left:cn
2556 {
2557 \object_member_adr:nnn { #1 }{ varlist }{ seq }
2558 }
2559 { #2 }
2560 }
2561
2562 \cs_generate_variant:Nn \proxy_push_member:nnn { Vnn }
2563
2564 % \end{macrocode}
2565 %\end{macro}
2566 %
2567 %\begin{macro}{\proxy_push_embedded:nnn}
2568 % Push a new embedded object inside a proxy.
2569 % \begin{macrocode}
2570
2571 \cs_new_protected:Nn \proxy_push_embedded:nnn
2572 {
2573 \object_newconst_str:nnx { #1 }{ #2 _ proxy }{ #3 }
2574 \seq_gput_left:cn
2575 {
2576 \object_member_adr:nnn { #1 }{ objlist }{ seq }
2577 }
2578 { #2 }
2579 }
2580
2581 \cs_generate_variant:Nn \proxy_push_embedded:nnn { Vnn }
2582
2583 % \end{macrocode}
2584 %\end{macro}
2585 %
2586 %\begin{macro}{\proxy_add_initializer:nN}
2587 % Push a new embedded object inside a proxy.
2588 % \begin{macrocode}
2589
2590 \cs_new_protected:Nn \proxy_add_initializer:nN
2591 {
2592 \tl_gput_right:cn
2593 {
2594 \object_member_adr:nnn { #1 }{ init }{ tl }
2595 }
2596 { #2 }
2597 }
2598
2599 \cs_generate_variant:Nn \proxy_add_initializer:nN { VN }
2600
2601 % \end{macrocode}
2602 %\end{macro}
2603 %
2604 %\begin{variable}{\c_proxy_address_str}
2605 % Variable containing the address of the \verb|proxy| object.
2606 % \begin{macrocode}
2607
2608 \str_const:Nx \c_proxy_address_str
2609 { \object_address:nn { rawobjects }{ proxy } }
2610
2611 \object_newconst_str:nnn
2612 {
2613 \object_embedded_adr:Vn \c_proxy_address_str { /_I_/ }
2614 }
2615 { M }{ rawobjects }
2616
2617 \object_newconst_str:nnV
2618 {
2619 \object_embedded_adr:Vn \c_proxy_address_str { /_I_/ }
2620 }
2621 { P } \c_proxy_address_str
2622
2623 \object_newconst_str:nnV
2624 {
2625 \object_embedded_adr:Vn \c_proxy_address_str { /_I_/ }
2626 }
2627 { S } \c_object_global_str
2628
2629 \object_newconst_str:nnV
2630 {
2631 \object_embedded_adr:Vn \c_proxy_address_str { /_I_/ }
2632 }
2633 { V } \c_object_public_str
2634
2635
2636 \@@_initproxy:VnV \c_proxy_address_str { rawobjects } \c_proxy_address_str
2637
2638 \object_new_member:Vnn \c_proxy_address_str { init }{ tl }
2639
2640 \object_new_member:Vnn \c_proxy_address_str { varlist }{ seq }
2641
2642 \object_new_member:Vnn \c_proxy_address_str { objlist }{ seq }
2643
2644 \proxy_push_member:Vnn \c_proxy_address_str
2645 { init }{ tl }
2646 \proxy_push_member:Vnn \c_proxy_address_str
2647 { varlist }{ seq }
2648 \proxy_push_member:Vnn \c_proxy_address_str
2649 { objlist }{ seq }
2650
2651 \proxy_add_initializer:VN \c_proxy_address_str
2652 \@@_initproxy:nnn
2653
2654 % \end{macrocode}
2655 %\end{variable}
2656 %
2657 % \begin{macro}{\object_allocate_incr:NNnnNN, \object_gallocate_incr:NNnnNN, \object_allocate_gincr:NNnnNN, \object_gallocate_gincr:NNnnNN}
2658 % Create an address and use it to instantiate an object
2659 % \begin{macrocode}
2660
2661 \cs_new:Nn \@@_combine_aux:nnn
2662 {
2663 anon . #3 . #2 . #1
2664 }
2665
2666 \cs_generate_variant:Nn \@@_combine_aux:nnn { Vnf }
2667
2668 \cs_new:Nn \@@_combine:Nn
2669 {
2670 \@@_combine_aux:Vnf #1 { #2 }
2671 {
2672 \cs_to_str:N #1
2673 }
2674 }
2675
2676 \cs_new_protected:Nn \object_allocate_incr:NNnnNN
2677 {
2678 \object_create_set:NnnfNN #1 { #3 }{ #4 }
2679 {
2680 \@@_combine:Nn #2 { #3 }
2681 }
2682 #5 #6
2683
2684 \int_incr:N #2
2685 }
2686
2687 \cs_new_protected:Nn \object_gallocate_incr:NNnnNN
2688 {
2689 \object_create_gset:NnnfNN #1 { #3 }{ #4 }
2690 {
2691 \@@_combine:Nn #2 { #3 }
2692 }
2693 #5 #6
2694
2695 \int_incr:N #2
2696 }
2697
2698 \cs_generate_variant:Nn \object_allocate_incr:NNnnNN { NNVnNN }
2699
2700 \cs_generate_variant:Nn \object_gallocate_incr:NNnnNN { NNVnNN }
2701
2702 \cs_new_protected:Nn \object_allocate_gincr:NNnnNN
2703 {
2704 \object_create_set:NnnfNN #1 { #3 }{ #4 }
2705 {
2706 \@@_combine:Nn #2 { #3 }
2707 }
2708 #5 #6
2709
2710 \int_gincr:N #2
2711 }
2712
2713 \cs_new_protected:Nn \object_gallocate_gincr:NNnnNN
2714 {
2715 \object_create_gset:NnnfNN #1 { #3 }{ #4 }
2716 {
2717 \@@_combine:Nn #2 { #3 }
2718 }
2719 #5 #6
2720
2721 \int_gincr:N #2
2722 }
2723
2724 \cs_generate_variant:Nn \object_allocate_gincr:NNnnNN { NNVnNN }
2725
2726 \cs_generate_variant:Nn \object_gallocate_gincr:NNnnNN { NNVnNN }
2727
2728 % \end{macrocode}
2729 % \end{macro}
2730 %
2731 %
2732 %\begin{macro}{\object_assign:nn}
2733 %Copy an object to another one.
2734 % \begin{macrocode}
2735 \cs_new_protected:Nn \object_assign:nn
2736 {
2737 \seq_map_inline:cn
2738 {
2739 \object_member_adr:vnn
2740 {
2741 \object_ncmember_adr:nnn
2742 {
2743 \object_embedded_adr:nn{ #1 }{ /_I_/ }
2744 }
2745 { P }{ str }
2746 }
2747 { varlist }{ seq }
2748 }
2749 {
2750 \object_member_set_eq:nnc { #1 }{ ##1 }
2751 {
2752 \object_member_adr:nn{ #2 }{ ##1 }
2753 }
2754 }
2755 }
2756
2757 \cs_generate_variant:Nn \object_assign:nn { nV, Vn, VV }
2758 % \end{macrocode}
2759 %\end{macro}
2760 %
2761 % \begin{macrocode}
2762 %</package>
2763 % \end{macrocode}
2764 %
2765 %\end{implementation}
2766 %
2767 %\PrintIndex
2768
2769
2770