1 /* identifier.h                                    -*- mode:c; coding:utf-8; -*-
2  *
3  *   Copyright (c) 2010-2021  Takashi Kato <ktakashi@ymail.com>
4  *
5  *   Redistribution and use in source and binary forms, with or without
6  *   modification, are permitted provided that the following conditions
7  *   are met:
8  *
9  *   1. Redistributions of source code must retain the above copyright
10  *      notice, this list of conditions and the following disclaimer.
11  *
12  *   2. Redistributions in binary form must reproduce the above copyright
13  *      notice, this list of conditions and the following disclaimer in the
14  *      documentation and/or other materials provided with the distribution.
15  *
16  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
22  *   TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  *   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24  *   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25  *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  *   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  *  $Id: $
29  */
30 #ifndef SAGITTARIUS_PRIVATE_IDENTIFIER_H_
31 #define SAGITTARIUS_PRIVATE_IDENTIFIER_H_
32 
33 #include "sagittariusdefs.h"
34 #include "clos.h"
35 
36 SG_CLASS_DECL(Sg_IdentifierClass);
37 #define SG_CLASS_IDENTIFIER (&Sg_IdentifierClass)
38 
39 struct SgIdentifierRec
40 {
41   SG_HEADER;
42   SgSymbol  *name;
43   SgObject   envs;
44   SgLibrary *library;
45   int        pending;
46   SgObject   identity;
47 };
48 
49 #define SG_IDENTIFIER(obj)   ((SgIdentifier*)(obj))
50 #define SG_IDENTIFIERP(obj)  SG_XTYPEP(obj,SG_CLASS_IDENTIFIER)
51 #define SG_IDENTIFIER_NAME(obj)     (SG_IDENTIFIER(obj)->name)
52 #define SG_IDENTIFIER_ENVS(obj)     (SG_IDENTIFIER(obj)->envs)
53 #define SG_IDENTIFIER_LIBRARY(obj)  (SG_IDENTIFIER(obj)->library)
54 #define SG_IDENTIFIER_PENDING(obj)  (SG_IDENTIFIER(obj)->pending)
55 #define SG_IDENTIFIER_IDENTITY(obj) (SG_IDENTIFIER(obj)->identity)
56 
57 /* for my sake, remove this after 0.7.8. */
58 #define Sg_MakeIdentifier(name, env, lib)	\
59   Sg_MakeGlobalIdentifier(name, SG_LIBRARY(lib))
60 
61 /* for C translator */
62 #define SG_INIT_IDENTIFIER(id, n, e, i, l, p)	\
63   do {						\
64     SG_IDENTIFIER(id)->pending = (p);		\
65     SG_IDENTIFIER(id)->name = (n);		\
66     SG_IDENTIFIER(id)->envs = (e);		\
67     SG_IDENTIFIER(id)->identity = (i);		\
68     SG_IDENTIFIER(id)->library = (l);		\
69   } while (0)
70 
71 SG_CDECL_BEGIN
72 
73 SG_EXTERN SgObject Sg_MakeGlobalIdentifier(SgObject name, SgLibrary *library);
74 SG_EXTERN SgObject Sg_MakeRawIdentifier(SgObject name, SgObject envs,
75 					SgObject identity,
76 					SgLibrary *library, int pendingP);
77 
78 SG_CDECL_END
79 
80 #endif /* SAGITTARIUS_IDENTIFIER_H_ */
81 
82 /*
83   end of file
84   Local Variables:
85   coding: utf-8-unix
86   End:
87 */
88