1 /* # skkinput (Simple Kana-Kanji Input)
2 *
3 * This file is part of skkinput.
4 * Copyright (C) 2002
5 * Takashi SAKAMOTO (PXG01715@nifty.ne.jp)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with skkinput; see the file COPYING. If not, write to
19 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21 #if !defined (lentity_inl_h)
22 #define lentity_inl_h
23 #if defined (DEBUG)
24 #include <stdio.h>
25 #endif
26 #include "cstring.h"
27
28 struct tagLMCMDINFO ;
29
30 #define lispEntity_GetSymbolPtr(ptr) ((TLispSymbol *)((TLispEntity *)(ptr) + 1))
31 #define lispEntity_GetConsPtr(ptr) ((TLispConscell *)((TLispEntity *)(ptr) + 1))
32 #define lispEntity_GetVectorPtr(ptr) ((TLispVector *)((TLispEntity *)(ptr) + 1))
33 #define lispEntity_GetLongPtr(ptr) ((long *)((TLispEntity *)(ptr) + 1))
34 #define lispEntity_GetFloatPtr(ptr) ((float *)((TLispEntity *)(ptr) + 1))
35 #define lispEntity_GetStringPtr(ptr) ((TLispString *)((TLispEntity *)(ptr) + 1))
36 #define lispEntity_GetSubrPtr(ptr) ((struct tagLMCMDINFO const **)((TLispEntity *)(ptr) + 1))
37 #define lispEntity_GetBufferPtr(ptr) ((TLispBuffer *)((TLispEntity *)(ptr) + 1))
38 #define lispEntity_GetWindowPtr(ptr) ((TLispWindow *)((TLispEntity *)(ptr) + 1))
39 #define lispEntity_GetFramePtr(ptr) ((TLispFrame *)((TLispEntity *)(ptr) + 1))
40 #define lispEntity_GetMutexPtr(ptr) ((TLispMutex *)((TLispEntity *)(ptr) + 1))
41 #define lispEntity_GetXEventPtr(ptr) ((TLispXEventInt *)((TLispEntity *)(ptr) + 1))
42
43 extern inline Boolean
lispEntity_GetType(register TLispManager * pLispMgr,register TLispEntity * pEntity,register int * piType)44 lispEntity_GetType (
45 register TLispManager* pLispMgr,
46 register TLispEntity* pEntity,
47 register int* piType)
48 {
49 assert (pLispMgr != NULL) ;
50 assert (pEntity != NULL) ;
51 assert (piType != NULL) ;
52
53 *piType = pEntity->m_iType ;
54 return True ;
55 }
56
57 extern inline Boolean
lispEntity_AddRef(register TLispManager * pLispMgr,register TLispEntity * pEntity)58 lispEntity_AddRef (
59 register TLispManager* pLispMgr,
60 register TLispEntity* pEntity)
61 {
62 assert (pLispMgr != NULL) ;
63 assert (pEntity != NULL) ;
64 assert (0 <= pEntity->m_iType && pEntity->m_iType < MAX_LISPENTITY_TYPE) ;
65 assert (pEntity->m_lReferCount >= 0) ;
66
67 pEntity->m_lReferCount ++ ;
68 assert (pEntity->m_lReferCount >= 0) ;
69 return True ;
70 }
71
72 extern inline Boolean
lispEntity_Release(register TLispManager * pLispMgr,register TLispEntity * pEntity)73 lispEntity_Release (
74 register TLispManager* pLispMgr,
75 register TLispEntity* pEntity)
76 {
77 assert (pLispMgr != NULL) ;
78 assert (pEntity != NULL) ;
79 assert (0 <= pEntity->m_iType && pEntity->m_iType < MAX_LISPENTITY_TYPE) ;
80 assert (pEntity->m_lReferCount > 0) ;
81
82 pEntity->m_lReferCount -- ;
83 return True ;
84 }
85
86 extern inline TLispEntity*
lispMgr_GetReservedEntity(register TLispManager * pLispMgr,register int nIndex)87 lispMgr_GetReservedEntity (
88 register TLispManager* pLispMgr,
89 register int nIndex)
90 {
91 assert (pLispMgr != NULL) ;
92 assert (0 <= nIndex && nIndex < LISPMGR_SIZE_RESERVED) ;
93 assert (pLispMgr->m_apEntReserved [nIndex] != NULL) ;
94 return pLispMgr->m_apEntReserved [nIndex] ;
95 }
96
97 extern inline Boolean
lispMgr_CreateNil(register TLispManager * pLispMgr,register TLispEntity ** const ppEntReturn)98 lispMgr_CreateNil (
99 register TLispManager* pLispMgr,
100 register TLispEntity** const ppEntReturn)
101 {
102 assert (pLispMgr != NULL) ;
103 assert (ppEntReturn != NULL) ;
104 *ppEntReturn = pLispMgr->m_apEntReserved [LISPMGR_INDEX_NIL] ;
105 return True ;
106 }
107
108 extern inline Boolean
lispMgr_CreateT(register TLispManager * pLispMgr,register TLispEntity ** const ppEntReturn)109 lispMgr_CreateT (
110 register TLispManager* pLispMgr,
111 register TLispEntity** const ppEntReturn)
112 {
113 assert (pLispMgr != NULL) ;
114 assert (ppEntReturn != NULL) ;
115 *ppEntReturn = pLispMgr->m_apEntReserved [LISPMGR_INDEX_T] ;
116 return True ;
117 }
118
119 extern inline Boolean
lispMgr_CreateVoid(register TLispManager * pLispMgr,register TLispEntity ** const ppEntReturn)120 lispMgr_CreateVoid (
121 register TLispManager* pLispMgr,
122 register TLispEntity** const ppEntReturn)
123 {
124 assert (pLispMgr != NULL) ;
125 assert (pLispMgr->m_pEntVoid != NULL) ;
126 assert (ppEntReturn != NULL) ;
127
128 *ppEntReturn = pLispMgr->m_pEntVoid ;
129 return True ;
130 }
131
132 extern inline Boolean
lispMgr_CreateEmpty(register TLispManager * pLispMgr,register TLispEntity ** const ppEntReturn)133 lispMgr_CreateEmpty (
134 register TLispManager* pLispMgr,
135 register TLispEntity** const ppEntReturn)
136 {
137 assert (pLispMgr != NULL) ;
138 assert (pLispMgr->m_pEntEmpty != NULL) ;
139 assert (ppEntReturn != NULL) ;
140
141 *ppEntReturn = pLispMgr->m_pEntEmpty ;
142 return True ;
143 }
144
145 extern inline Boolean
lispEntity_Nullp(register TLispManager * pLispMgr,register TLispEntity * pEntity)146 lispEntity_Nullp (
147 register TLispManager* pLispMgr,
148 register TLispEntity* pEntity)
149 {
150 TLispEntity* pNil ;
151
152 (void) lispMgr_CreateNil (pLispMgr, &pNil) ;
153 return (pNil == pEntity)? True : False ;
154 }
155
156 extern inline Boolean
lispEntity_Symbolp(register TLispManager * pLispMgr,register TLispEntity * pEntity)157 lispEntity_Symbolp (
158 register TLispManager* pLispMgr,
159 register TLispEntity* pEntity)
160 {
161 int iType ;
162 #if defined (DEBUG)
163 Boolean fResult ;
164 #endif
165 #if defined (DEBUG)
166 fResult = lispEntity_GetType (pLispMgr, pEntity, &iType) ;
167 assert (fResult == True) ;
168 #else
169 (void) lispEntity_GetType (pLispMgr, pEntity, &iType) ;
170 #endif
171 return (iType == LISPENTITY_SYMBOL)? True : False ;
172 }
173
174 extern inline Boolean
lispEntity_XEventIntegerp(register TLispManager * pLispMgr,register TLispEntity * pEntity)175 lispEntity_XEventIntegerp (
176 register TLispManager* pLispMgr,
177 register TLispEntity* pEntity)
178 {
179 register TLispXEventInt* pEvent = lispEntity_GetXEventPtr (pEntity) ;
180
181 assert (pLispMgr != NULL) ;
182 assert (pEntity != NULL) ;
183
184 return (pEntity->m_iType == LISPENTITY_XEVENT &&
185 pEvent->m_pEntValue->m_iType == LISPENTITY_INTEGER) ;
186 }
187
188 extern inline Boolean
lispEntity_Integerp(register TLispManager * pLispMgr,register TLispEntity * pEntity)189 lispEntity_Integerp (
190 register TLispManager* pLispMgr,
191 register TLispEntity* pEntity)
192 {
193 return (pEntity->m_iType == LISPENTITY_INTEGER ||
194 lispEntity_XEventIntegerp (pLispMgr, pEntity)) ;
195 }
196
197 extern inline Boolean
lispEntity_Floatp(register TLispManager * pLispMgr,register TLispEntity * pEntity)198 lispEntity_Floatp (
199 register TLispManager* pLispMgr,
200 register TLispEntity* pEntity)
201 {
202 int iType ;
203 #if defined (DEBUG)
204 Boolean fResult ;
205 #endif
206 #if defined (DEBUG)
207 fResult = lispEntity_GetType (pLispMgr, pEntity, &iType) ;
208 assert (fResult == True) ;
209 #else
210 (void) lispEntity_GetType (pLispMgr, pEntity, &iType) ;
211 #endif
212 return (iType == LISPENTITY_FLOAT)? True : False ;
213 }
214
215 extern inline Boolean
lispEntity_Markerp(register TLispManager * pLispMgr,register TLispEntity * pEntity)216 lispEntity_Markerp (
217 register TLispManager* pLispMgr,
218 register TLispEntity* pEntity)
219 {
220 int iType ;
221 #if defined (DEBUG)
222 Boolean fResult ;
223 #endif
224 #if defined (DEBUG)
225 fResult = lispEntity_GetType (pLispMgr, pEntity, &iType) ;
226 assert (fResult == True) ;
227 #else
228 (void) lispEntity_GetType (pLispMgr, pEntity, &iType) ;
229 #endif
230 return (iType == LISPENTITY_MARKER)? True : False ;
231 }
232
233 extern inline Boolean
lispEntity_Numberp(register TLispManager * pLispMgr,register TLispEntity * pEntity)234 lispEntity_Numberp (
235 register TLispManager* pLispMgr,
236 register TLispEntity* pEntity)
237 {
238 return (lispEntity_Floatp (pLispMgr, pEntity) ||
239 lispEntity_Integerp (pLispMgr, pEntity)) ;
240 }
241
242 extern inline Boolean
lispEntity_IntegerOrMarkerp(register TLispManager * pLispMgr,register TLispEntity * pEntity)243 lispEntity_IntegerOrMarkerp (
244 register TLispManager* pLispMgr,
245 register TLispEntity* pEntity)
246 {
247 return (lispEntity_Integerp (pLispMgr, pEntity) ||
248 lispEntity_Markerp (pLispMgr, pEntity)) ;
249 }
250
251 extern inline Boolean
lispEntity_Consp(register TLispManager * pLispMgr,register TLispEntity * pEntity)252 lispEntity_Consp (
253 register TLispManager* pLispMgr,
254 register TLispEntity* pEntity)
255 {
256 int iType ;
257 #if defined (DEBUG)
258 Boolean fResult ;
259 #endif
260 #if defined (DEBUG)
261 fResult = lispEntity_GetType (pLispMgr, pEntity, &iType) ;
262 assert (fResult == True) ;
263 #else
264 (void) lispEntity_GetType (pLispMgr, pEntity, &iType) ;
265 #endif
266 return (iType == LISPENTITY_CONSCELL)? True : False ;
267 }
268
269 extern inline Boolean
lispEntity_Listp(register TLispManager * pLispMgr,register TLispEntity * pEntity)270 lispEntity_Listp (
271 register TLispManager* pLispMgr,
272 register TLispEntity* pEntity)
273 {
274 int iType ;
275
276 if (lispEntity_Nullp (pLispMgr, pEntity))
277 return True ;
278
279 (void) lispEntity_GetType (pLispMgr, pEntity, &iType) ;
280 return (iType == LISPENTITY_CONSCELL)? True : False ;
281 }
282
283 extern inline Boolean
lispEntity_Stringp(register TLispManager * pLispMgr,register TLispEntity * pEntity)284 lispEntity_Stringp (
285 register TLispManager* pLispMgr,
286 register TLispEntity* pEntity)
287 {
288 int iType ;
289 #if defined (DEBUG)
290 Boolean fResult ;
291 #endif
292 #if defined (DEBUG)
293 fResult = lispEntity_GetType (pLispMgr, pEntity, &iType) ;
294 assert (fResult == True) ;
295 #else
296 (void) lispEntity_GetType (pLispMgr, pEntity, &iType) ;
297 #endif
298 return (iType == LISPENTITY_STRING)? True : False ;
299 }
300
301 extern inline Boolean
lispEntity_Vectorp(register TLispManager * pLispMgr,register TLispEntity * pEntity)302 lispEntity_Vectorp (
303 register TLispManager* pLispMgr,
304 register TLispEntity* pEntity)
305 {
306 int iType ;
307 #if defined (DEBUG)
308 Boolean fResult ;
309 #endif
310 #if defined (DEBUG)
311 fResult = lispEntity_GetType (pLispMgr, pEntity, &iType) ;
312 assert (fResult == True) ;
313 #else
314 (void) lispEntity_GetType (pLispMgr, pEntity, &iType) ;
315 #endif
316 return (iType == LISPENTITY_VECTOR)? True : False ;
317 }
318
319 extern inline Boolean
lispEntity_Arrayp(register TLispManager * pLispMgr,register TLispEntity * pEntity)320 lispEntity_Arrayp (
321 register TLispManager* pLispMgr,
322 register TLispEntity* pEntity)
323 {
324 assert (pLispMgr != NULL) ;
325 assert (pEntity != NULL) ;
326
327 return (lispEntity_Vectorp (pLispMgr, pEntity) ||
328 lispEntity_Stringp (pLispMgr, pEntity)) ;
329 }
330
331 /*
332 * Entity �� buffer �Ǥ��뤫�ɤ�����Ƚ�ꤹ�롣
333 */
334 extern inline Boolean
lispEntity_Bufferp(register TLispManager * pLispMgr,register TLispEntity * pEntity)335 lispEntity_Bufferp (
336 register TLispManager* pLispMgr,
337 register TLispEntity* pEntity)
338 {
339 int iType ;
340 #if defined (DEBUG)
341 Boolean fResult ;
342 #endif
343 #if defined (DEBUG)
344 fResult = lispEntity_GetType (pLispMgr, pEntity, &iType) ;
345 assert (fResult == True) ;
346 #else
347 (void) lispEntity_GetType (pLispMgr, pEntity, &iType) ;
348 #endif
349 return (iType == LISPENTITY_BUFFER)? True : False ;
350 }
351
352 extern inline Boolean
lispEntity_Sequencep(register TLispManager * pLispMgr,register TLispEntity * pEntity)353 lispEntity_Sequencep (
354 register TLispManager* pLispMgr,
355 register TLispEntity* pEntity)
356 {
357 assert (pLispMgr != NULL) ;
358 assert (pEntity != NULL) ;
359
360 return (lispEntity_Listp (pLispMgr, pEntity) ||
361 lispEntity_Arrayp (pLispMgr, pEntity)) ;
362 }
363
364 extern inline TLispEntity*
lispEntity_XEvent2Integer(register TLispEntity * pEntity)365 lispEntity_XEvent2Integer (
366 register TLispEntity* pEntity)
367 {
368 assert (pEntity != NULL) ;
369 assert (pEntity->m_iType == LISPENTITY_XEVENT) ;
370 return (lispEntity_GetXEventPtr (pEntity))->m_pEntValue ;
371 }
372
373 extern inline Boolean
lispEntity_Eq(register TLispManager * pLispMgr,register TLispEntity * pEntLeft,register TLispEntity * pEntRight)374 lispEntity_Eq (
375 register TLispManager* pLispMgr,
376 register TLispEntity* pEntLeft,
377 register TLispEntity* pEntRight)
378 {
379 #if 0
380 assert (pLispMgr != NULL) ;
381 assert (pEntLeft != NULL) ;
382 assert (pEntRight != NULL) ;
383 return (pEntLeft == pEntRight)? True : False ;
384 #else
385 register TLispEntity* pEntLeftCmp ;
386 register TLispEntity* pEntRightCmp ;
387
388 assert (pLispMgr != NULL) ;
389 assert (pEntLeft != NULL) ;
390 assert (pEntRight != NULL) ;
391
392 /* ���ʤ�����κ�������XEVENT ENTITY �� Integer �Ȥ��ơ�eq ����褦�ˤ��롣
393 * �ޤ���ɬ�פˤʤ�Τ� im-send �ۤˤ���λ����������顣
394 */
395 pEntLeftCmp = (pEntLeft->m_iType != LISPENTITY_XEVENT)? pEntLeft : lispEntity_XEvent2Integer (pEntLeft) ;
396 pEntRightCmp = (pEntRight->m_iType != LISPENTITY_XEVENT)? pEntRight : lispEntity_XEvent2Integer (pEntRight) ;
397 return pEntLeftCmp == pEntRightCmp ;
398 #endif
399 UNREFERENCED_PARAMETER (pLispMgr) ;
400 }
401
402 extern inline Boolean
lispEntity_GetCar(register TLispManager * pLispMgr,register TLispEntity * pEntity,register TLispEntity ** const ppRetvalue)403 lispEntity_GetCar (
404 register TLispManager* pLispMgr,
405 register TLispEntity* pEntity,
406 register TLispEntity** const ppRetvalue)
407 {
408 TLispConscell* pConscell ;
409
410 assert (pLispMgr != NULL) ;
411 assert (pEntity != NULL) ;
412 assert (ppRetvalue != NULL) ;
413
414 if (lispEntity_Nullp (pLispMgr, pEntity))
415 return lispMgr_CreateNil (pLispMgr, ppRetvalue) ;
416
417 if (pEntity->m_iType != LISPENTITY_CONSCELL)
418 return False ;
419
420 pConscell = lispEntity_GetConsPtr (pEntity) ;
421 *ppRetvalue = pConscell->m_pCar ;
422 return True ;
423 }
424
425 extern inline Boolean
lispEntity_GetCdr(register TLispManager * pLispMgr,register TLispEntity * pEntity,register TLispEntity ** const ppRetvalue)426 lispEntity_GetCdr (
427 register TLispManager* pLispMgr,
428 register TLispEntity* pEntity,
429 register TLispEntity** const ppRetvalue)
430 {
431 register TLispConscell* pConscell ;
432
433 assert (pLispMgr != NULL) ;
434 assert (pEntity != NULL) ;
435 assert (ppRetvalue != NULL) ;
436
437 if (lispEntity_Nullp (pLispMgr, pEntity))
438 return lispMgr_CreateNil (pLispMgr, ppRetvalue) ;
439
440 if (pEntity->m_iType != LISPENTITY_CONSCELL)
441 return False ;
442
443 pConscell = lispEntity_GetConsPtr (pEntity) ;
444 *ppRetvalue = pConscell->m_pCdr ;
445 return True ;
446 }
447
448 extern inline Boolean
lispEntity_GetCadr(register TLispManager * pLispMgr,register TLispEntity * pEntity,register TLispEntity ** const ppRetvalue)449 lispEntity_GetCadr (
450 register TLispManager* pLispMgr,
451 register TLispEntity* pEntity,
452 register TLispEntity** const ppRetvalue)
453 {
454 TLispEntity* pCDR ;
455 TLispEntity* pCADR ;
456
457 if (TFAILED (lispEntity_GetCdr (pLispMgr, pEntity, &pCDR)) ||
458 TFAILED (lispEntity_GetCar (pLispMgr, pCDR, &pCADR)))
459 return False ;
460 *ppRetvalue = pCADR ;
461 return True ;
462 }
463
464 extern inline Boolean
lispEntity_GetCaar(register TLispManager * pLispMgr,register TLispEntity * pEntity,register TLispEntity ** const ppRetvalue)465 lispEntity_GetCaar (
466 register TLispManager* pLispMgr,
467 register TLispEntity* pEntity,
468 register TLispEntity** const ppRetvalue)
469 {
470 TLispEntity* pCAR ;
471 TLispEntity* pCAAR ;
472
473 if (TFAILED (lispEntity_GetCar (pLispMgr, pEntity, &pCAR)) ||
474 TFAILED (lispEntity_GetCar (pLispMgr, pCAR, &pCAAR)))
475 return False ;
476 *ppRetvalue = pCAAR ;
477 return True ;
478 }
479
480 extern inline Boolean
lispEntity_GetCaddr(register TLispManager * pLispMgr,register TLispEntity * pEntity,register TLispEntity ** const ppRetvalue)481 lispEntity_GetCaddr (
482 register TLispManager* pLispMgr,
483 register TLispEntity* pEntity,
484 register TLispEntity** const ppRetvalue)
485 {
486 TLispEntity* pCDR ;
487 TLispEntity* pCDDR ;
488 TLispEntity* pCADDR ;
489
490 if (TFAILED (lispEntity_GetCdr (pLispMgr, pEntity, &pCDR)) ||
491 TFAILED (lispEntity_GetCdr (pLispMgr, pCDR, &pCDDR)) ||
492 TFAILED (lispEntity_GetCar (pLispMgr, pCDDR, &pCADDR)))
493 return False ;
494 *ppRetvalue = pCADDR ;
495 return True ;
496 }
497
498 extern inline Boolean
lispEntity_GetCddr(register TLispManager * pLispMgr,register TLispEntity * pEntity,register TLispEntity ** const ppRetvalue)499 lispEntity_GetCddr (
500 register TLispManager* pLispMgr,
501 register TLispEntity* pEntity,
502 register TLispEntity** const ppRetvalue)
503 {
504 TLispEntity* pCDR ;
505 TLispEntity* pCDDR ;
506
507 if (TFAILED (lispEntity_GetCdr (pLispMgr, pEntity, &pCDR)) ||
508 TFAILED (lispEntity_GetCdr (pLispMgr, pCDR, &pCDDR)))
509 return False ;
510 *ppRetvalue = pCDDR ;
511 return True ;
512 }
513
514 extern inline Boolean
lispEntity_SetCar(register TLispManager * pLispMgr,register TLispEntity * pEntity,register TLispEntity * pCar)515 lispEntity_SetCar (
516 register TLispManager* pLispMgr,
517 register TLispEntity* pEntity,
518 register TLispEntity* pCar)
519 {
520 register TLispConscell* pConscell ;
521
522 assert (pLispMgr != NULL) ;
523 assert (pEntity != NULL) ;
524 assert (pCar != NULL) ;
525
526 if (pEntity->m_iType != LISPENTITY_CONSCELL)
527 return False ;
528
529 pConscell = lispEntity_GetConsPtr (pEntity) ;
530 pConscell->m_pCar = pCar ;
531 return True ;
532 }
533
534 extern inline Boolean
lispEntity_SetCdr(register TLispManager * pLispMgr,register TLispEntity * pEntity,register TLispEntity * pCdr)535 lispEntity_SetCdr (
536 register TLispManager* pLispMgr,
537 register TLispEntity* pEntity,
538 register TLispEntity* pCdr)
539 {
540 register TLispConscell* pConscell ;
541
542 assert (pLispMgr != NULL) ;
543 assert (pEntity != NULL) ;
544 assert (pCdr != NULL) ;
545
546 if (pEntity->m_iType != LISPENTITY_CONSCELL)
547 return False ;
548
549 pConscell = lispEntity_GetConsPtr (pEntity) ;
550 pConscell->m_pCdr = pCdr ;
551 return True ;
552 }
553
554 extern inline Boolean
lispEntity_CountArgument(register TLispManager * pLispMgr,TLispEntity * pEntity,int * pnCount)555 lispEntity_CountArgument (
556 register TLispManager* pLispMgr,
557 TLispEntity* pEntity,
558 int* pnCount)
559 {
560 register int nArgument ;
561
562 assert (pLispMgr != NULL) ;
563 assert (pEntity != NULL) ;
564 assert (pnCount != NULL) ;
565
566 nArgument = 0 ;
567 while (!lispEntity_Nullp (pLispMgr, pEntity)) {
568 if (TFAILED (lispEntity_GetCdr (pLispMgr, pEntity, &pEntity)) ||
569 pEntity == NULL)
570 return False ;
571 nArgument ++ ;
572 }
573 *pnCount = nArgument ;
574 return True ;
575 }
576
577 extern inline Boolean
lispEntity_GetSymbolName(register TLispManager * pLispMgr,register TLispEntity * pEntity,register const Char ** const ppSymName,register int * piSymName)578 lispEntity_GetSymbolName (
579 register TLispManager* pLispMgr,
580 register TLispEntity* pEntity,
581 register const Char** const ppSymName,
582 register int* piSymName)
583 {
584 register TLispSymbol* pSymbol ;
585
586 assert (pLispMgr != NULL) ;
587 assert (pEntity != NULL) ;
588 assert (ppSymName != NULL) ;
589 assert (piSymName != NULL) ;
590
591 if (pEntity->m_iType != LISPENTITY_SYMBOL)
592 return False ;
593
594 pSymbol = lispEntity_GetSymbolPtr (pEntity) ;
595 *ppSymName = pSymbol->m_achName ;
596 *piSymName = pSymbol->m_nLength ;
597 return True ;
598 }
599
600 extern inline Boolean
lispEntity_Tp(register TLispManager * pLispMgr,register TLispEntity * pEntity)601 lispEntity_Tp (
602 register TLispManager* pLispMgr,
603 register TLispEntity* pEntity)
604 {
605 TLispEntity* pT ;
606
607 lispMgr_CreateT (pLispMgr, &pT) ;
608 return (pT == pEntity)? True : False ;
609 }
610
611 extern inline Boolean
lispEntity_Voidp(register TLispManager * pLispMgr,register TLispEntity * pEntity)612 lispEntity_Voidp (
613 register TLispManager* pLispMgr,
614 register TLispEntity* pEntity)
615 {
616 assert (pLispMgr != NULL) ;
617 assert (pLispMgr->m_pEntVoid != NULL) ;
618 return (pEntity == pLispMgr->m_pEntVoid) ;
619 }
620
621 extern inline Boolean
lispEntity_Emptyp(register TLispManager * pLispMgr,register TLispEntity * pEntity)622 lispEntity_Emptyp (
623 register TLispManager* pLispMgr,
624 register TLispEntity* pEntity)
625 {
626 assert (pLispMgr != NULL) ;
627 assert (pLispMgr->m_pEntEmpty != NULL) ;
628 return (pEntity == pLispMgr->m_pEntEmpty) ;
629 }
630
631 extern inline Boolean
lispEntity_GetLastElement(register TLispManager * pLispMgr,register TLispEntity * pEntList,register TLispEntity ** ppEntRetval)632 lispEntity_GetLastElement (
633 register TLispManager* pLispMgr,
634 register TLispEntity* pEntList,
635 register TLispEntity** ppEntRetval)
636 {
637 TLispEntity* pEntNextList ;
638
639 assert (pLispMgr != NULL) ;
640 assert (pEntList != NULL) ;
641 assert (ppEntRetval != NULL) ;
642
643 while (TSUCCEEDED (lispEntity_GetCdr (pLispMgr, pEntList, &pEntNextList)) &&
644 TFAILED (lispEntity_Nullp (pLispMgr, pEntNextList)))
645 pEntList = pEntNextList ;
646 *ppEntRetval = pEntList ;
647 return True ;
648 }
649
650 /* lnumber.c */
651 extern inline Boolean
lispEntity_GetIntegerValue(register TLispManager * pLispMgr,register TLispEntity * pEntity,register long * plValue)652 lispEntity_GetIntegerValue (
653 register TLispManager* pLispMgr,
654 register TLispEntity* pEntity,
655 register long* plValue)
656 {
657 register long* plInteger ;
658 register TLispXEventInt* pEvent ;
659
660 assert (pLispMgr != NULL) ;
661 assert (pEntity != NULL) ;
662 assert (plValue != NULL) ;
663
664 switch (pEntity->m_iType) {
665 case LISPENTITY_XEVENT:
666 pEvent = lispEntity_GetXEventPtr (pEntity) ;
667 assert (pEvent->m_pEntValue != NULL) ;
668 pEntity = pEvent->m_pEntValue ;
669 assert (pEntity != NULL) ;
670 if (pEntity->m_iType != LISPENTITY_INTEGER)
671 return False ;
672 /* fall-down */
673 case LISPENTITY_INTEGER:
674 plInteger = lispEntity_GetLongPtr (pEntity) ;
675 *plValue = *plInteger ;
676 break ;
677 default:
678 return False ;
679 }
680 return True ;
681 }
682
683 extern inline Boolean
lispEntity_GetFloatValue(register TLispManager * pLispMgr,register TLispEntity * pEntity,register float * pfValue)684 lispEntity_GetFloatValue (
685 register TLispManager* pLispMgr,
686 register TLispEntity* pEntity,
687 register float* pfValue)
688 {
689 float* plFloat ;
690
691 assert (pLispMgr != NULL) ;
692 assert (pEntity != NULL) ;
693 assert (pfValue != NULL) ;
694
695 if (pEntity->m_iType != LISPENTITY_FLOAT)
696 return False ;
697 plFloat = lispEntity_GetFloatPtr (pEntity) ;
698 *pfValue = *plFloat ;
699 return True ;
700 }
701
702 extern inline Boolean
lispEntity_GetNumberValue(register TLispManager * pLispMgr,register TLispEntity * pEntity,register TLispNumber * pReturn)703 lispEntity_GetNumberValue (
704 register TLispManager* pLispMgr,
705 register TLispEntity* pEntity,
706 register TLispNumber* pReturn)
707 {
708 long lValue ;
709 float fValue ;
710
711 assert (pLispMgr != NULL) ;
712 assert (pEntity != NULL) ;
713 assert (pReturn != NULL) ;
714
715 switch (pEntity->m_iType) {
716 case LISPENTITY_INTEGER:
717 (void) lispEntity_GetIntegerValue (pLispMgr, pEntity, &lValue) ;
718 pReturn->m_fFloatp = False ;
719 pReturn->m_Value.m_lLong = lValue ;
720 break ;
721 case LISPENTITY_FLOAT:
722 (void) lispEntity_GetFloatValue (pLispMgr, pEntity, &fValue) ;
723 pReturn->m_fFloatp = True ;
724 pReturn->m_Value.m_fFloat = fValue ;
725 break ;
726 default:
727 return False ;
728 }
729 return True ;
730 }
731
732 extern inline Boolean
lispEntity_GetNumberOrMarkerValue(register TLispManager * pLispMgr,register TLispEntity * pEntity,register TLispNumber * pReturn)733 lispEntity_GetNumberOrMarkerValue (
734 register TLispManager* pLispMgr,
735 register TLispEntity* pEntity,
736 register TLispNumber* pReturn)
737 {
738 assert (pLispMgr != NULL) ;
739 assert (pEntity != NULL) ;
740 assert (pReturn != NULL) ;
741
742 switch (pEntity->m_iType) {
743 case LISPENTITY_INTEGER:
744 {
745 long lValue ;
746
747 (void) lispEntity_GetIntegerValue (pLispMgr, pEntity, &lValue) ;
748 pReturn->m_fFloatp = False ;
749 pReturn->m_Value.m_lLong = lValue ;
750 break ;
751 }
752 case LISPENTITY_FLOAT:
753 {
754 float fValue ;
755
756 (void) lispEntity_GetFloatValue (pLispMgr, pEntity, &fValue) ;
757 pReturn->m_fFloatp = True ;
758 pReturn->m_Value.m_fFloat = fValue ;
759 break ;
760 }
761 case LISPENTITY_MARKER:
762 {
763 TLispEntity* pEntBuffer ;
764 int nPosition ;
765 (void) lispMarker_GetBufferPosition (pLispMgr, pEntity, &pEntBuffer, &nPosition) ;
766 if (pEntBuffer == NULL)
767 return False ;
768 pReturn->m_fFloatp = False ;
769 pReturn->m_Value.m_lLong = nPosition ;
770 break ;
771 }
772 default:
773 return False ;
774 }
775 return True ;
776 }
777
778 /* lsymbol.kc */
779 extern inline Boolean
lispEntity_MatchSymbolNamep(register TLispManager * pLispMgr,register TLispEntity * pEntity,register const Char * pName,register int nName)780 lispEntity_MatchSymbolNamep (
781 register TLispManager* pLispMgr,
782 register TLispEntity* pEntity,
783 register const Char* pName,
784 register int nName)
785 {
786 register TLispSymbol* pSymbol ;
787
788 if (pEntity->m_iType != LISPENTITY_SYMBOL)
789 return False ;
790
791 pSymbol = lispEntity_GetSymbolPtr (pEntity) ;
792 if (nName != pSymbol->m_nLength ||
793 Cstrncmp (pName, pSymbol->m_achName, nName))
794 return False ;
795 return True ;
796 }
797
798 extern inline Boolean
lispEntity_Lambdap(register TLispManager * pLispMgr,register TLispEntity * pEntity)799 lispEntity_Lambdap (
800 register TLispManager* pLispMgr,
801 register TLispEntity* pEntity)
802 {
803 return lispEntity_Eq (pLispMgr, pEntity, lispMgr_GetReservedEntity (pLispMgr, LISPMGR_INDEX_LAMBDA)) ;
804 }
805
806 extern inline Boolean
lispEntity_Macrop(register TLispManager * pLispMgr,register TLispEntity * pEntity)807 lispEntity_Macrop (
808 register TLispManager* pLispMgr,
809 register TLispEntity* pEntity)
810 {
811 return lispEntity_Eq (pLispMgr, pEntity, lispMgr_GetReservedEntity (pLispMgr, LISPMGR_INDEX_MACRO)) ;
812 }
813
814 extern inline Boolean
lispEntity_Optionalp(register TLispManager * pLispMgr,register TLispEntity * pEntity)815 lispEntity_Optionalp (
816 register TLispManager* pLispMgr,
817 register TLispEntity* pEntity)
818 {
819 return lispEntity_Eq (pLispMgr, pEntity, lispMgr_GetReservedEntity (pLispMgr, LISPMGR_INDEX_OPTIONAL)) ;
820 }
821
822 extern inline Boolean
lispEntity_Restp(register TLispManager * pLispMgr,register TLispEntity * pEntity)823 lispEntity_Restp (
824 register TLispManager* pLispMgr,
825 register TLispEntity* pEntity)
826 {
827 return lispEntity_Eq (pLispMgr, pEntity, lispMgr_GetReservedEntity (pLispMgr, LISPMGR_INDEX_REST)) ;
828 }
829
830 extern inline Boolean
lispEntity_GetVectorValue(register TLispManager * pLispMgr,register TLispEntity * pEntity,register TLispEntity *** const pppElement,register int * pnElement)831 lispEntity_GetVectorValue (
832 register TLispManager* pLispMgr,
833 register TLispEntity* pEntity,
834 register TLispEntity*** const pppElement,
835 register int* pnElement)
836 {
837 register TLispVector* pVector ;
838
839 assert (pLispMgr != NULL) ;
840 assert (pEntity != NULL) ;
841 assert (pppElement != NULL) ;
842 assert (pnElement != NULL) ;
843
844 if (pEntity->m_iType != LISPENTITY_VECTOR)
845 return False ;
846
847 pVector = lispEntity_GetVectorPtr (pEntity) ;
848 *pppElement = pVector->m_apElement ;
849 *pnElement = pVector->m_nElement ;
850 return True ;
851 }
852
853 extern inline Boolean
lispEntity_GetVectorElement(register TLispManager * pLispMgr,register TLispEntity * pEntity,register int nIndex,register TLispEntity ** const ppReturn)854 lispEntity_GetVectorElement (
855 register TLispManager* pLispMgr,
856 register TLispEntity* pEntity,
857 register int nIndex,
858 register TLispEntity** const ppReturn)
859 {
860 register TLispVector* pVector ;
861
862 assert (pLispMgr != NULL) ;
863 assert (pEntity != NULL) ;
864 assert (ppReturn != NULL) ;
865
866 if (pEntity->m_iType != LISPENTITY_VECTOR)
867 return False ;
868
869 pVector = lispEntity_GetVectorPtr (pEntity) ;
870 #if defined (DEBUG)
871 fprintf (stderr, "nIndex(%d), nElement(%d)\n",
872 nIndex, pVector->m_nElement) ;
873 #endif
874 if (nIndex < 0 || pVector->m_nElement <= nIndex)
875 return False ;
876
877 *ppReturn = pVector->m_apElement [nIndex] ;
878 return True ;
879 }
880
881 extern inline Boolean
lispEntity_SetVectorElement(register TLispManager * pLispMgr,register TLispEntity * pEntVector,register int nIndex,register TLispEntity * pEntValue)882 lispEntity_SetVectorElement (
883 register TLispManager* pLispMgr,
884 register TLispEntity* pEntVector,
885 register int nIndex,
886 register TLispEntity* pEntValue)
887 {
888 register TLispVector* pVector ;
889
890 assert (pLispMgr != NULL) ;
891 assert (pEntVector != NULL) ;
892 assert (pEntValue != NULL) ;
893
894 if (pEntVector->m_iType != LISPENTITY_VECTOR)
895 return False ;
896
897 pVector = lispEntity_GetVectorPtr (pEntVector) ;
898 if (nIndex < 0 || pVector->m_nElement <= nIndex)
899 return False ;
900
901 pVector->m_apElement [nIndex] = pEntValue ;
902 return True ;
903 }
904
905 extern inline Boolean
lispEntity_ShrinkVector(register TLispManager * pLispMgr,register TLispEntity * pEntVector,register int nShrink)906 lispEntity_ShrinkVector (
907 register TLispManager* pLispMgr,
908 register TLispEntity* pEntVector,
909 register int nShrink)
910 {
911 register TLispVector* pVector ;
912
913 assert (pLispMgr != NULL) ;
914 assert (pEntVector != NULL) ;
915 assert (nShrink >= 0) ;
916
917 if (pEntVector->m_iType != LISPENTITY_VECTOR)
918 return False ;
919
920 pVector = lispEntity_GetVectorPtr (pEntVector) ;
921 pVector->m_nElement -= nShrink ;
922 if (pVector->m_nElement < 0)
923 pVector->m_nElement = 0 ;
924 return True ;
925 }
926
927 extern inline Boolean
lispEntity_GetStringValue(register TLispManager * pLispMgr,register TLispEntity * pEntity,const Char ** const ppString,register int * pnLength)928 lispEntity_GetStringValue (
929 register TLispManager* pLispMgr,
930 register TLispEntity* pEntity,
931 const Char** const ppString,
932 register int* pnLength)
933 {
934 register TLispString* pLsString ;
935
936 assert (pLispMgr != NULL) ;
937 assert (pEntity != NULL) ;
938 assert (ppString != NULL) ;
939 assert (pnLength != NULL) ;
940
941 if (pEntity->m_iType != LISPENTITY_STRING)
942 return False ;
943
944 pLsString = lispEntity_GetStringPtr (pEntity) ;
945 *ppString = pLsString->m_achString ;
946 *pnLength = pLsString->m_nLength ;
947 return True ;
948 }
949
950 extern inline Boolean
lispEntity_GetStringElement(register TLispManager * pLispMgr,register TLispEntity * pEntity,register int nIndex,register Char * const pCh)951 lispEntity_GetStringElement (
952 register TLispManager* pLispMgr,
953 register TLispEntity* pEntity,
954 register int nIndex,
955 register Char* const pCh)
956 {
957 register TLispString* pLsString ;
958
959 assert (pLispMgr != NULL) ;
960 assert (pEntity != NULL) ;
961 assert (pCh != NULL) ;
962
963 if (pEntity->m_iType != LISPENTITY_STRING)
964 return False ;
965
966 pLsString = lispEntity_GetStringPtr (pEntity) ;
967 if (nIndex < 0 || nIndex >= pLsString->m_nLength)
968 return False ;
969
970 *pCh = pLsString->m_achString [nIndex] ;
971 return True ;
972 }
973
974 extern inline Boolean
lispEntity_SetStringElement(register TLispManager * pLispMgr,register TLispEntity * pEntity,register int nIndex,register const Char cc)975 lispEntity_SetStringElement (
976 register TLispManager* pLispMgr,
977 register TLispEntity* pEntity,
978 register int nIndex,
979 register const Char cc)
980 {
981 register TLispString* pLsString ;
982
983 assert (pLispMgr != NULL) ;
984 assert (pEntity != NULL) ;
985
986 if (pEntity->m_iType != LISPENTITY_STRING)
987 return False ;
988
989 pLsString = lispEntity_GetStringPtr (pEntity) ;
990 if (nIndex < 0 || nIndex >= pLsString->m_nLength)
991 return False ;
992
993 pLsString->m_achString [nIndex] = cc ;
994 return True ;
995 }
996
997 /* lsubr.c */
998 extern inline Boolean
lispEntity_Subrp(register TLispManager * pLispMgr,register TLispEntity * pEntity)999 lispEntity_Subrp (
1000 register TLispManager* pLispMgr,
1001 register TLispEntity* pEntity)
1002 {
1003 assert (pLispMgr != NULL) ;
1004 assert (pEntity != NULL) ;
1005 return (pEntity->m_iType == LISPENTITY_SUBR) ;
1006 }
1007
1008 extern inline Boolean
lispSubr_GetProc(register TLispManager * pLispMgr,register TLispEntity * pEntSubr,register struct tagLMCMDINFO const ** ppProcReturn)1009 lispSubr_GetProc (
1010 register TLispManager* pLispMgr,
1011 register TLispEntity* pEntSubr,
1012 register struct tagLMCMDINFO const** ppProcReturn)
1013 {
1014 if (pEntSubr->m_iType != LISPENTITY_SUBR)
1015 return False ;
1016 *ppProcReturn = *(lispEntity_GetSubrPtr (pEntSubr)) ;
1017 return True ;
1018 }
1019
1020 /* lbuffer.c */
1021 extern inline int
lispBuffer_GetTick(register TLispEntity * pEntBuffer)1022 lispBuffer_GetTick (
1023 register TLispEntity* pEntBuffer)
1024 {
1025 register TLispBuffer* pBuffer ;
1026 assert (pEntBuffer != NULL) ;
1027 pBuffer = lispEntity_GetBufferPtr (pEntBuffer) ;
1028 return pBuffer->m_nTick ;
1029 }
1030
1031 /* lwindow.c */
1032 extern inline Boolean
lispWindow_NeedUpdatep(register TLispManager * pLispMgr,register TLispEntity * pEntWindow)1033 lispWindow_NeedUpdatep (
1034 register TLispManager* pLispMgr,
1035 register TLispEntity* pEntWindow)
1036 {
1037 register TLispWindow* pWindow ;
1038 register TLispEntity* pEntBuffer ;
1039 int nPoint ;
1040
1041 assert (pEntWindow != NULL) ;
1042 assert (pEntWindow->m_iType == LISPENTITY_WINDOW) ;
1043 pWindow = lispEntity_GetWindowPtr (pEntWindow) ;
1044 pEntBuffer = pWindow->m_pBuffer ;
1045 assert (pEntBuffer != NULL) ;
1046 if (pWindow->m_nTick != lispBuffer_GetTick (pEntBuffer))
1047 return True ;
1048 lispBuffer_Point (pLispMgr, pEntBuffer, &nPoint) ;
1049 return (nPoint != pWindow->m_nPointBack) ;
1050 }
1051
1052 extern inline void
lispWindow_Sync(register TLispManager * pLispMgr,register TLispEntity * pEntWindow)1053 lispWindow_Sync (
1054 register TLispManager* pLispMgr,
1055 register TLispEntity* pEntWindow)
1056 {
1057 register TLispWindow* pWindow ;
1058 register TLispEntity* pEntBuffer ;
1059 int nPoint ;
1060
1061 assert (pEntWindow != NULL) ;
1062 assert (pEntWindow->m_iType == LISPENTITY_WINDOW) ;
1063 pWindow = lispEntity_GetWindowPtr (pEntWindow) ;
1064 pEntBuffer = pWindow->m_pBuffer ;
1065 assert (pEntBuffer != NULL) ;
1066 pWindow->m_nTick = lispBuffer_GetTick (pEntBuffer) ;
1067 lispBuffer_Point (pLispMgr, pEntBuffer, &nPoint) ;
1068 pWindow->m_nPointBack = nPoint ;
1069 return ;
1070 }
1071
1072 extern inline void
lispWindow_Desync(register TLispManager * pLispMgr,register TLispEntity * pEntWindow)1073 lispWindow_Desync (
1074 register TLispManager* pLispMgr,
1075 register TLispEntity* pEntWindow)
1076 {
1077 register TLispWindow* pWindow ;
1078 register TLispEntity* pEntBuffer ;
1079
1080 assert (pEntWindow != NULL) ;
1081 assert (pEntWindow->m_iType == LISPENTITY_WINDOW) ;
1082 pWindow = lispEntity_GetWindowPtr (pEntWindow) ;
1083 pEntBuffer = pWindow->m_pBuffer ;
1084 assert (pEntBuffer != NULL) ;
1085 pWindow->m_nTick = lispBuffer_GetTick (pEntBuffer) - 1 ;
1086 return ;
1087 }
1088
1089 extern inline Boolean
lispEntity_XEventp(register TLispManager * pLispMgr,register TLispEntity * pEntity)1090 lispEntity_XEventp (
1091 register TLispManager* pLispMgr,
1092 register TLispEntity* pEntity)
1093 {
1094 assert (pEntity != NULL) ;
1095 return (pEntity->m_iType == LISPENTITY_XEVENT) ;
1096 }
1097
1098 extern inline Boolean
lispEntity_GetXEvent(register TLispManager * pLispMgr,register TLispEntity * pEntity,register XEvent ** ppEvent)1099 lispEntity_GetXEvent (
1100 register TLispManager* pLispMgr,
1101 register TLispEntity* pEntity,
1102 register XEvent** ppEvent)
1103 {
1104 register TLispXEventInt* pEvent ;
1105
1106 assert (pEntity != NULL) ;
1107 assert (ppEvent != NULL) ;
1108
1109 if (pEntity->m_iType != LISPENTITY_XEVENT)
1110 return False ;
1111
1112 pEvent = lispEntity_GetXEventPtr (pEntity) ;
1113 *ppEvent = &pEvent->m_evX ;
1114 return True ;
1115 }
1116
1117 #endif
1118