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 (lispmachinep_h)
22 #define	lispmachinep_h
23 
24 #include "lmachine.h"
25 #include "lmstate.h"
26 #include "lmcode.h"
27 #include "lmsymbol.h"
28 #if !defined (regcustom_h)
29 #define	regcustom_h
30 #include "regcustom.h"
31 #endif
32 
33 #define	LISPMACHINE_EXCEPTIONP(pLM)				 ((pLM)->m_uStatusFlag & LMSTATE_EXCEPTION)
34 #define	LISPMACHINE_SIGNALP(pLM)				 ((pLM)->m_uStatusFlag & LMSTATE_SIGNAL)
35 #define	LISPMACHINE_EXIT_RECURSIVE_EDITP(pLM)	 ((pLM)->m_uStatusFlag & LMSTATE_EXIT_RECURSIVE_EDIT)
36 #define	LISPMACHINE_EXCEPTIONORSIGNALP(pLM) ((pLM)->m_uStatusFlag & (LMSTATE_EXCEPTION | LMSTATE_SIGNAL | LMSTATE_EXIT_RECURSIVE_EDIT))
37 
38 #define	LISPMACHINE_RESET_EXCEPTION(pLM)	{ (pLM)->m_uStatusFlag &= ~LMSTATE_EXCEPTION ; }
39 #define	LISPMACHINE_RESET_SIGNAL(pLM)		{ (pLM)->m_uStatusFlag &= ~LMSTATE_SIGNAL ; }
40 #define	LISPMACHINE_RESET_ERROR(pLM)		{ (pLM)->m_uStatusFlag &= ~LMSTATE_ERROR ; }
41 #define	LISPMACHINE_RESET_EXIT_RECURSIVE_EDIT(pLM)	{ (pLM)->m_uStatusFlag &= ~LMSTATE_EXIT_RECURSIVE_EDIT ; }
42 
43 enum {
44 	LISPCMD_ARGTYPE_NORMAL	= 0,
45 	LISPCMD_ARGTYPE_LOWER,
46 	LISPCMD_ARGTYPE_UPPER,
47 	LISPCMD_ARGTYPE_NOBOUND,
48 	LISPCMD_ARGTYPE_CDR,
49 	LISPCMD_ARGTYPE_LAMBDA,
50 	LISPCMD_ARGTYPE_MACRO,
51 	LISPCMD_ARGTYPE_SPECIAL,
52 } ;
53 
54 enum {
55 	LMSTATE_SIGNAL				= 1 << 0,
56 	LMSTATE_EXCEPTION			= 1 << 1,
57 	LMSTATE_EXIT_RECURSIVE_EDIT	= 1 << 2,	/* abort �� + SIGNAL �� QUIT */
58 } ;
59 
60 enum {
61 	LM_LREG_ACC			= 0,
62 	LM_LREG_1,
63 	LM_LREG_2,
64 	LM_LREG_3,
65 	LM_LREG_4,
66 	LM_LREG_5,
67 	LM_LREG_6,
68 	LM_LREG_7,
69 	LM_LREG_8,
70 	MAX_LISPOBJ_REGS,
71 } ;
72 
73 enum {
74 	LM_VREG_1			= 0,
75 	LM_VREG_2,
76 	LM_VREG_3,
77 	LM_VREG_4,
78 	MAX_NONLISPOBJ_REGS,
79 } ;
80 
81 
82 #define	MAX_REGEXP_MATCHES		(32)
83 
84 typedef union tagTNotLispValue {
85 	long		m_lValue ;
86 	void*		m_pvValue ;
87 	TLMRESULT	(*m_pState)(struct tagTLispMachine*) ;
88 }	TNotLispValue ;	/* not-lispobject value */
89 
90 /*
91  *	Lisp ���۵�����
92  */
93 struct tagTLispMachine {
94 	struct tagTLispManager*	m_pLispMgr ;
95 
96 	struct tagTLispEntity*	m_apLREGS [MAX_LISPOBJ_REGS] ;
97 	union  tagTNotLispValue	m_alVREGS [MAX_NONLISPOBJ_REGS] ;
98 
99 	struct tagTLispEntity*	m_pTarget ;			/* ����ɾ����� symbol */
100 	struct tagTLispEntity*	m_pEntSignal ;
101 	struct tagTLispEntity*	m_pEntSignalValue ;
102 	struct tagTLispEntity*	m_pEntException ;	/* �㳰��*/
103 	struct tagTLispEntity*	m_pEntExceptionValue ;
104 
105 	unsigned				m_uStatusFlag ;
106 	VStack					m_vstLispObj ;		/* Lisp Object �Ѥ� stack */
107 	VStack					m_vstNonLispObj ;	/* �� Lisp Object �Ѥ� stack */
108 	Boolean					m_fCalledInteractively ;
109 	Boolean					m_fInteractive ;
110 
111 	struct tagTLispEntity*	m_lstBuffer ;		/* ring list �ˤ��褦��*/
112 	struct tagTLispEntity*	m_lstFrame ;		/* ring list �ˤ��褦��*/
113 
114 	struct tagTLispEntity*	m_pCurBuffer ;
115 	struct tagTLispEntity*	m_pCurWindow ;
116 	struct tagTLispEntity*	m_pCurFrame ;
117 
118 	/*	Lisp Machine �� Local �ѿ���������������� Lisp ����
119 	 *	����Ǥ����ΤǤϤʤ���*/
120 	struct tagTLispBind*	m_apSymbol2SymbolTable [SIZE_LISP_BIND_TABLE] ;
121 	struct tagTLispBind*	m_apVariableTable [SIZE_LISP_BIND_TABLE] ;
122 	struct tagTLispBind*	m_apFunctionTable [SIZE_LISP_BIND_TABLE] ;
123 	struct tagTLispBind*	m_apPropertyTable [SIZE_LISP_BIND_TABLE] ;
124 
125 	TLMRESULT				(*m_pState)(struct tagTLispMachine*) ;
126 	struct tagTLispMachine*	m_pMacParent ;
127 
128 	/*	LispMachine ���Ф��볰������Υ��٥�Ȥ��Ǽ����Хåե���
129 	 *	��������Ĺ��(������̵�̤��ΰ���礭�����᤮�Ƥ����ǽ���Ϥ��롣*/
130 	TVarbuffer				m_vbufCmdEvents ;
131 
132 	/*	match-data ���оݤȤʤä�enitity��ʸ����ޤ��ϥХåե������롣*/
133 	struct tagTLispEntity*	m_pEntRegMatch ;
134 	regmatch_t				m_aRegMatch [MAX_REGEXP_MATCHES] ;
135 } ;
136 
137 typedef struct tagLMCMDINFO {
138 	const Char*	m_pName ;
139 	const Char*	m_pInteractive ;
140 	int			m_iArgtype ;
141 	int			m_nMinArgNum ;
142 	int			m_nMaxArgNum ;
143 	TLMRESULT	(*m_pProc)(struct tagTLispMachine*) ;
144 }	LMCMDINFO ;
145 
146 /*	Prototypes */
147 TLMRESULT	lispMachine_ExecuteLoop		(TLispMachine*) ;
148 Boolean		lispMachine_ActivateAllFrame(TLispMachine*, Boolean) ;
149 Boolean		lispMachine_CheckArgument	(TLispMachine*, TLispEntity*, LMCMDINFO const*, int*) ;
150 Boolean		lispMachine_Errorp			(TLispMachine*) ;
151 Boolean		lispMachine_ErrorExceptionOrSignalp	(TLispMachine*) ;
152 Boolean		lispMachine_ShowRegisterValue	(TLispMachine*) ;
153 
154 Boolean		lispMachine_SearchBuiltinFunction	(TLispManager*, TLispEntity*, LMCMDINFO const **) ;
155 
156 Boolean		lispMachine_InsertBuffer	(TLispMachine*, TLispEntity*) ;
157 Boolean		lispMachine_RemoveBuffer	(TLispMachine*, TLispEntity*) ;
158 Boolean		lispMachine_InsertFrame		(TLispMachine*, TLispEntity*) ;
159 Boolean		lispMachine_RemoveFrame		(TLispMachine*, TLispEntity*) ;
160 Boolean		lispMachine_QueueInEvent	(TLispMachine*, TLispEntity*, TLispEntity*) ;
161 Boolean		lispMachine_GetBuffer		(TLispMachine*, const Char*, int, TLispEntity**) ;
162 Boolean		lispMachine_GetFileBuffer	(TLispMachine*, const Char*, int, TLispEntity**) ;
163 Boolean		lispMachine_GenerateNewBufferName (TLispMachine*, const Char*, int, TLispEntity**) ;
164 Boolean		lispMachine_EnumBuffer		(TLispMachine*, Boolean, Boolean (*)(TLispMachine*, TLispEntity*, void*, Boolean*), void*) ;
165 
166 TLMRESULT	lispMachine_ReadStringStart	(TLispMachine*, const Char*, int, TLispEntity*) ;
167 
168 Boolean		lispMachine_EnumFrame			(TLispMachine*, Boolean (*)(TLispMachine*, TLispEntity*, void*, Boolean*), void*) ;
169 Boolean		lispMachine_UpdateCurrentFrame	(TLispMachine*) ;
170 Boolean		lispMachine_UpdateAllFrame		(TLispMachine*) ;
171 void		lispMachine_ScheduleUpdateAllFrame	(TLispMachine*) ;
172 Boolean		lispMachine_ResizeFrame			(TLispMachine*, TLispEntity*, const XRectangle*) ;
173 Boolean		lispMachine_EnumWindow			(TLispMachine*, TLispEntity*, Boolean (*)(TLispMachine*, TLispEntity*, void*, Boolean*), void*) ;
174 Boolean		lispMachine_UpdateWindow		(TLispMachine*, TLispEntity*, TLispEntity*) ;
175 Boolean		lispMachine_UpdateOverTheSpotFrameWindow(TLispMachine*, TLispEntity*, TLispEntity*) ;
176 Char		lispMachine_lispKeyEventSymbol2Char	(TLispManager* pLispMgr, TLispEntity*) ;
177 
178 int			lispMachine_GetCodingSystemForRead	(TLispMachine*) ;
179 int			lispMachine_GetCodingSystemForWrite	(TLispMachine*) ;
180 Boolean		lispMachine_CodingSystemp			(TLispManager*, TLispEntity*) ;
181 
182 #include	"lmachine-inl.h"
183 
184 #endif
185 
186