////////////////////////////////////////////////////////////////
//
//  Roast+ プリプロセッサ 算術系
//  Roast+ Preprocessor Arithmetic
//                                           2009/07/01 myun2
//                             Copyright 2009 Open-MGL Project
//
//                    http://sourceforge.jp/projects/open-mgl/
//
////////////////////////////////////////////////////////////////

#ifndef __SFJP_OPENMGL__roast_pp_arithmetic_H__
#define __SFJP_OPENMGL__roast_pp_arithmetic_H__

//	Incriment - インクリメント
#define ROAST_PP_INC__0		1
#define ROAST_PP_INC__1		2
#define ROAST_PP_INC__2		3
#define ROAST_PP_INC__3		4
#define ROAST_PP_INC__4		5
#define ROAST_PP_INC__5		6
#define ROAST_PP_INC__6		7
#define ROAST_PP_INC__7		8
#define ROAST_PP_INC__8		9
#define ROAST_PP_INC__9		10
#define ROAST_PP_INC__10	11
#define ROAST_PP_INC__11	12
#define ROAST_PP_INC__12	13
#define ROAST_PP_INC__13	14
#define ROAST_PP_INC__14	15
#define ROAST_PP_INC__15	16
#define ROAST_PP_INC__16	17
#define ROAST_PP_INC__17	18
#define ROAST_PP_INC__18	19
#define ROAST_PP_INC__19	20
#define ROAST_PP_INC__20	21
#define ROAST_PP_INC__21	22
#define ROAST_PP_INC__22	23
#define ROAST_PP_INC__23	24
#define ROAST_PP_INC__24	25
#define ROAST_PP_INC__25	26
#define ROAST_PP_INC__26	27
#define ROAST_PP_INC__27	28
#define ROAST_PP_INC__28	29
#define ROAST_PP_INC__29	30
#define ROAST_PP_INC__30	31
#define ROAST_PP_INC__31	32
#define ROAST_PP_INC__32	33
#define ROAST_PP_INC__33	34
#define ROAST_PP_INC__34	35
#define ROAST_PP_INC__35	36
#define ROAST_PP_INC__36	37
#define ROAST_PP_INC__37	38
#define ROAST_PP_INC__38	39
#define ROAST_PP_INC__39	40
#define ROAST_PP_INC__40	41
#define ROAST_PP_INC__41	42
#define ROAST_PP_INC__42	43
#define ROAST_PP_INC__43	44
#define ROAST_PP_INC__44	45
#define ROAST_PP_INC__45	46
#define ROAST_PP_INC__46	47
#define ROAST_PP_INC__47	48
#define ROAST_PP_INC__48	49
#define ROAST_PP_INC__49	50
#define ROAST_PP_INC__50	51
#define ROAST_PP_INC__51	52
#define ROAST_PP_INC__52	53
#define ROAST_PP_INC__53	54
#define ROAST_PP_INC__54	55
#define ROAST_PP_INC__55	56
#define ROAST_PP_INC__56	57
#define ROAST_PP_INC__57	58
#define ROAST_PP_INC__58	59
#define ROAST_PP_INC__59	60
#define ROAST_PP_INC__60	61
#define ROAST_PP_INC__61	62
#define ROAST_PP_INC__62	63
#define ROAST_PP_INC__63	64
#define ROAST_PP_INC__64	65
#define ROAST_PP_INC__65	66
#define ROAST_PP_INC__66	67
#define ROAST_PP_INC__67	68
#define ROAST_PP_INC__68	69
#define ROAST_PP_INC__69	70
#define ROAST_PP_INC__70	71
#define ROAST_PP_INC__71	72
#define ROAST_PP_INC__72	73
#define ROAST_PP_INC__73	74
#define ROAST_PP_INC__74	75
#define ROAST_PP_INC__75	76
#define ROAST_PP_INC__76	77
#define ROAST_PP_INC__77	78
#define ROAST_PP_INC__78	79
#define ROAST_PP_INC__79	80
#define ROAST_PP_INC__80	81
#define ROAST_PP_INC__81	82
#define ROAST_PP_INC__82	83
#define ROAST_PP_INC__83	84
#define ROAST_PP_INC__84	85
#define ROAST_PP_INC__85	86
#define ROAST_PP_INC__86	87
#define ROAST_PP_INC__87	88
#define ROAST_PP_INC__88	89
#define ROAST_PP_INC__89	90
#define ROAST_PP_INC__90	91
#define ROAST_PP_INC__91	92
#define ROAST_PP_INC__92	93
#define ROAST_PP_INC__93	94
#define ROAST_PP_INC__94	95
#define ROAST_PP_INC__95	96
#define ROAST_PP_INC__96	97
#define ROAST_PP_INC__97	98
#define ROAST_PP_INC__98	99
#define ROAST_PP_INC__99	100
#define ROAST_PP_INC__100	101
#define ROAST_PP_INC__101	102
#define ROAST_PP_INC__102	103
#define ROAST_PP_INC__103	104
#define ROAST_PP_INC__104	105
#define ROAST_PP_INC__105	106
#define ROAST_PP_INC__106	107
#define ROAST_PP_INC__107	108
#define ROAST_PP_INC__108	109
#define ROAST_PP_INC__109	110
#define ROAST_PP_INC__110	111
#define ROAST_PP_INC__111	112
#define ROAST_PP_INC__112	113
#define ROAST_PP_INC__113	114
#define ROAST_PP_INC__114	115
#define ROAST_PP_INC__115	116
#define ROAST_PP_INC__116	117
#define ROAST_PP_INC__117	118
#define ROAST_PP_INC__118	119
#define ROAST_PP_INC__119	120
#define ROAST_PP_INC__120	121
#define ROAST_PP_INC__121	122
#define ROAST_PP_INC__122	123
#define ROAST_PP_INC__123	124
#define ROAST_PP_INC__124	125
#define ROAST_PP_INC__125	126
#define ROAST_PP_INC__126	127
#define ROAST_PP_INC__127	128
#define ROAST_PP_INC__128	129
#define ROAST_PP_INC__129	130
#define ROAST_PP_INC__130	131
#define ROAST_PP_INC__131	132
#define ROAST_PP_INC__132	133
#define ROAST_PP_INC__133	134
#define ROAST_PP_INC__134	135
#define ROAST_PP_INC__135	136
#define ROAST_PP_INC__136	137
#define ROAST_PP_INC__137	138
#define ROAST_PP_INC__138	139
#define ROAST_PP_INC__139	140
#define ROAST_PP_INC__140	141
#define ROAST_PP_INC__141	142
#define ROAST_PP_INC__142	143
#define ROAST_PP_INC__143	144
#define ROAST_PP_INC__144	145
#define ROAST_PP_INC__145	146
#define ROAST_PP_INC__146	147
#define ROAST_PP_INC__147	148
#define ROAST_PP_INC__148	149
#define ROAST_PP_INC__149	150
#define ROAST_PP_INC__150	151
#define ROAST_PP_INC__151	152
#define ROAST_PP_INC__152	153
#define ROAST_PP_INC__153	154
#define ROAST_PP_INC__154	155
#define ROAST_PP_INC__155	156
#define ROAST_PP_INC__156	157
#define ROAST_PP_INC__157	158
#define ROAST_PP_INC__158	159
#define ROAST_PP_INC__159	160
#define ROAST_PP_INC__160	161
#define ROAST_PP_INC__161	162
#define ROAST_PP_INC__162	163
#define ROAST_PP_INC__163	164
#define ROAST_PP_INC__164	165
#define ROAST_PP_INC__165	166
#define ROAST_PP_INC__166	167
#define ROAST_PP_INC__167	168
#define ROAST_PP_INC__168	169
#define ROAST_PP_INC__169	170
#define ROAST_PP_INC__170	171
#define ROAST_PP_INC__171	172
#define ROAST_PP_INC__172	173
#define ROAST_PP_INC__173	174
#define ROAST_PP_INC__174	175
#define ROAST_PP_INC__175	176
#define ROAST_PP_INC__176	177
#define ROAST_PP_INC__177	178
#define ROAST_PP_INC__178	179
#define ROAST_PP_INC__179	180
#define ROAST_PP_INC__180	181
#define ROAST_PP_INC__181	182
#define ROAST_PP_INC__182	183
#define ROAST_PP_INC__183	184
#define ROAST_PP_INC__184	185
#define ROAST_PP_INC__185	186
#define ROAST_PP_INC__186	187
#define ROAST_PP_INC__187	188
#define ROAST_PP_INC__188	189
#define ROAST_PP_INC__189	190
#define ROAST_PP_INC__190	191
#define ROAST_PP_INC__191	192
#define ROAST_PP_INC__192	193
#define ROAST_PP_INC__193	194
#define ROAST_PP_INC__194	195
#define ROAST_PP_INC__195	196
#define ROAST_PP_INC__196	197
#define ROAST_PP_INC__197	198
#define ROAST_PP_INC__198	199
#define ROAST_PP_INC__199	200
#define ROAST_PP_INC__200	201
#define ROAST_PP_INC__201	202
#define ROAST_PP_INC__202	203
#define ROAST_PP_INC__203	204
#define ROAST_PP_INC__204	205
#define ROAST_PP_INC__205	206
#define ROAST_PP_INC__206	207
#define ROAST_PP_INC__207	208
#define ROAST_PP_INC__208	209
#define ROAST_PP_INC__209	210
#define ROAST_PP_INC__210	211
#define ROAST_PP_INC__211	212
#define ROAST_PP_INC__212	213
#define ROAST_PP_INC__213	214
#define ROAST_PP_INC__214	215
#define ROAST_PP_INC__215	216
#define ROAST_PP_INC__216	217
#define ROAST_PP_INC__217	218
#define ROAST_PP_INC__218	219
#define ROAST_PP_INC__219	220
#define ROAST_PP_INC__220	221
#define ROAST_PP_INC__221	222
#define ROAST_PP_INC__222	223
#define ROAST_PP_INC__223	224
#define ROAST_PP_INC__224	225
#define ROAST_PP_INC__225	226
#define ROAST_PP_INC__226	227
#define ROAST_PP_INC__227	228
#define ROAST_PP_INC__228	229
#define ROAST_PP_INC__229	230
#define ROAST_PP_INC__230	231
#define ROAST_PP_INC__231	232
#define ROAST_PP_INC__232	233
#define ROAST_PP_INC__233	234
#define ROAST_PP_INC__234	235
#define ROAST_PP_INC__235	236
#define ROAST_PP_INC__236	237
#define ROAST_PP_INC__237	238
#define ROAST_PP_INC__238	239
#define ROAST_PP_INC__239	240
#define ROAST_PP_INC__240	241
#define ROAST_PP_INC__241	242
#define ROAST_PP_INC__242	243
#define ROAST_PP_INC__243	244
#define ROAST_PP_INC__244	245
#define ROAST_PP_INC__245	246
#define ROAST_PP_INC__246	247
#define ROAST_PP_INC__247	248
#define ROAST_PP_INC__248	249
#define ROAST_PP_INC__249	250
#define ROAST_PP_INC__250	251
#define ROAST_PP_INC__251	252
#define ROAST_PP_INC__252	253
#define ROAST_PP_INC__253	254
#define ROAST_PP_INC__254	255
#define ROAST_PP_INC__255	256
#define ROAST_PP_INC__256	257

#define ROAST_PP_INC_(x)	ROAST_PP_INC__##x
#define ROAST_PP_INC(x)		ROAST_PP_INC_(x)

//////////////////////////////////////////////////////////////

//	Decriment - デクリメント
#define ROAST_PP_DEC__0		-1
#define ROAST_PP_DEC__1		0
#define ROAST_PP_DEC__2		1
#define ROAST_PP_DEC__3		2
#define ROAST_PP_DEC__4		3
#define ROAST_PP_DEC__5		4
#define ROAST_PP_DEC__6		5
#define ROAST_PP_DEC__7		6
#define ROAST_PP_DEC__8		7
#define ROAST_PP_DEC__9		8
#define ROAST_PP_DEC__10	9
#define ROAST_PP_DEC__11	10
#define ROAST_PP_DEC__12	11
#define ROAST_PP_DEC__13	12
#define ROAST_PP_DEC__14	13
#define ROAST_PP_DEC__15	14
#define ROAST_PP_DEC__16	15
#define ROAST_PP_DEC__17	16
#define ROAST_PP_DEC__18	17
#define ROAST_PP_DEC__19	18
#define ROAST_PP_DEC__20	19
#define ROAST_PP_DEC__21	20
#define ROAST_PP_DEC__22	21
#define ROAST_PP_DEC__23	22
#define ROAST_PP_DEC__24	23
#define ROAST_PP_DEC__25	24
#define ROAST_PP_DEC__26	25
#define ROAST_PP_DEC__27	26
#define ROAST_PP_DEC__28	27
#define ROAST_PP_DEC__29	28
#define ROAST_PP_DEC__30	29
#define ROAST_PP_DEC__31	30
#define ROAST_PP_DEC__32	31
#define ROAST_PP_DEC__33	32
#define ROAST_PP_DEC__34	33
#define ROAST_PP_DEC__35	34
#define ROAST_PP_DEC__36	35
#define ROAST_PP_DEC__37	36
#define ROAST_PP_DEC__38	37
#define ROAST_PP_DEC__39	38
#define ROAST_PP_DEC__40	39
#define ROAST_PP_DEC__41	40
#define ROAST_PP_DEC__42	41
#define ROAST_PP_DEC__43	42
#define ROAST_PP_DEC__44	43
#define ROAST_PP_DEC__45	44
#define ROAST_PP_DEC__46	45
#define ROAST_PP_DEC__47	46
#define ROAST_PP_DEC__48	47
#define ROAST_PP_DEC__49	48
#define ROAST_PP_DEC__50	49
#define ROAST_PP_DEC__51	50
#define ROAST_PP_DEC__52	51
#define ROAST_PP_DEC__53	52
#define ROAST_PP_DEC__54	53
#define ROAST_PP_DEC__55	54
#define ROAST_PP_DEC__56	55
#define ROAST_PP_DEC__57	56
#define ROAST_PP_DEC__58	57
#define ROAST_PP_DEC__59	58
#define ROAST_PP_DEC__60	59
#define ROAST_PP_DEC__61	60
#define ROAST_PP_DEC__62	61
#define ROAST_PP_DEC__63	62
#define ROAST_PP_DEC__64	63
#define ROAST_PP_DEC__65	64
#define ROAST_PP_DEC__66	65
#define ROAST_PP_DEC__67	66
#define ROAST_PP_DEC__68	67
#define ROAST_PP_DEC__69	68
#define ROAST_PP_DEC__70	69
#define ROAST_PP_DEC__71	70
#define ROAST_PP_DEC__72	71
#define ROAST_PP_DEC__73	72
#define ROAST_PP_DEC__74	73
#define ROAST_PP_DEC__75	74
#define ROAST_PP_DEC__76	75
#define ROAST_PP_DEC__77	76
#define ROAST_PP_DEC__78	77
#define ROAST_PP_DEC__79	78
#define ROAST_PP_DEC__80	79
#define ROAST_PP_DEC__81	80
#define ROAST_PP_DEC__82	81
#define ROAST_PP_DEC__83	82
#define ROAST_PP_DEC__84	83
#define ROAST_PP_DEC__85	84
#define ROAST_PP_DEC__86	85
#define ROAST_PP_DEC__87	86
#define ROAST_PP_DEC__88	87
#define ROAST_PP_DEC__89	88
#define ROAST_PP_DEC__90	89
#define ROAST_PP_DEC__91	90
#define ROAST_PP_DEC__92	91
#define ROAST_PP_DEC__93	92
#define ROAST_PP_DEC__94	93
#define ROAST_PP_DEC__95	94
#define ROAST_PP_DEC__96	95
#define ROAST_PP_DEC__97	96
#define ROAST_PP_DEC__98	97
#define ROAST_PP_DEC__99	98
#define ROAST_PP_DEC__100	99
#define ROAST_PP_DEC__101	100
#define ROAST_PP_DEC__102	101
#define ROAST_PP_DEC__103	102
#define ROAST_PP_DEC__104	103
#define ROAST_PP_DEC__105	104
#define ROAST_PP_DEC__106	105
#define ROAST_PP_DEC__107	106
#define ROAST_PP_DEC__108	107
#define ROAST_PP_DEC__109	108
#define ROAST_PP_DEC__110	109
#define ROAST_PP_DEC__111	110
#define ROAST_PP_DEC__112	111
#define ROAST_PP_DEC__113	112
#define ROAST_PP_DEC__114	113
#define ROAST_PP_DEC__115	114
#define ROAST_PP_DEC__116	115
#define ROAST_PP_DEC__117	116
#define ROAST_PP_DEC__118	117
#define ROAST_PP_DEC__119	118
#define ROAST_PP_DEC__120	119
#define ROAST_PP_DEC__121	120
#define ROAST_PP_DEC__122	121
#define ROAST_PP_DEC__123	122
#define ROAST_PP_DEC__124	123
#define ROAST_PP_DEC__125	124
#define ROAST_PP_DEC__126	125
#define ROAST_PP_DEC__127	126
#define ROAST_PP_DEC__128	127
#define ROAST_PP_DEC__129	128
#define ROAST_PP_DEC__130	129
#define ROAST_PP_DEC__131	130
#define ROAST_PP_DEC__132	131
#define ROAST_PP_DEC__133	132
#define ROAST_PP_DEC__134	133
#define ROAST_PP_DEC__135	134
#define ROAST_PP_DEC__136	135
#define ROAST_PP_DEC__137	136
#define ROAST_PP_DEC__138	137
#define ROAST_PP_DEC__139	138
#define ROAST_PP_DEC__140	139
#define ROAST_PP_DEC__141	140
#define ROAST_PP_DEC__142	141
#define ROAST_PP_DEC__143	142
#define ROAST_PP_DEC__144	143
#define ROAST_PP_DEC__145	144
#define ROAST_PP_DEC__146	145
#define ROAST_PP_DEC__147	146
#define ROAST_PP_DEC__148	147
#define ROAST_PP_DEC__149	148
#define ROAST_PP_DEC__150	149
#define ROAST_PP_DEC__151	150
#define ROAST_PP_DEC__152	151
#define ROAST_PP_DEC__153	152
#define ROAST_PP_DEC__154	153
#define ROAST_PP_DEC__155	154
#define ROAST_PP_DEC__156	155
#define ROAST_PP_DEC__157	156
#define ROAST_PP_DEC__158	157
#define ROAST_PP_DEC__159	158
#define ROAST_PP_DEC__160	159
#define ROAST_PP_DEC__161	160
#define ROAST_PP_DEC__162	161
#define ROAST_PP_DEC__163	162
#define ROAST_PP_DEC__164	163
#define ROAST_PP_DEC__165	164
#define ROAST_PP_DEC__166	165
#define ROAST_PP_DEC__167	166
#define ROAST_PP_DEC__168	167
#define ROAST_PP_DEC__169	168
#define ROAST_PP_DEC__170	169
#define ROAST_PP_DEC__171	170
#define ROAST_PP_DEC__172	171
#define ROAST_PP_DEC__173	172
#define ROAST_PP_DEC__174	173
#define ROAST_PP_DEC__175	174
#define ROAST_PP_DEC__176	175
#define ROAST_PP_DEC__177	176
#define ROAST_PP_DEC__178	177
#define ROAST_PP_DEC__179	178
#define ROAST_PP_DEC__180	179
#define ROAST_PP_DEC__181	180
#define ROAST_PP_DEC__182	181
#define ROAST_PP_DEC__183	182
#define ROAST_PP_DEC__184	183
#define ROAST_PP_DEC__185	184
#define ROAST_PP_DEC__186	185
#define ROAST_PP_DEC__187	186
#define ROAST_PP_DEC__188	187
#define ROAST_PP_DEC__189	188
#define ROAST_PP_DEC__190	189
#define ROAST_PP_DEC__191	190
#define ROAST_PP_DEC__192	191
#define ROAST_PP_DEC__193	192
#define ROAST_PP_DEC__194	193
#define ROAST_PP_DEC__195	194
#define ROAST_PP_DEC__196	195
#define ROAST_PP_DEC__197	196
#define ROAST_PP_DEC__198	197
#define ROAST_PP_DEC__199	198
#define ROAST_PP_DEC__200	199
#define ROAST_PP_DEC__201	200
#define ROAST_PP_DEC__202	201
#define ROAST_PP_DEC__203	202
#define ROAST_PP_DEC__204	203
#define ROAST_PP_DEC__205	204
#define ROAST_PP_DEC__206	205
#define ROAST_PP_DEC__207	206
#define ROAST_PP_DEC__208	207
#define ROAST_PP_DEC__209	208
#define ROAST_PP_DEC__210	209
#define ROAST_PP_DEC__211	210
#define ROAST_PP_DEC__212	211
#define ROAST_PP_DEC__213	212
#define ROAST_PP_DEC__214	213
#define ROAST_PP_DEC__215	214
#define ROAST_PP_DEC__216	215
#define ROAST_PP_DEC__217	216
#define ROAST_PP_DEC__218	217
#define ROAST_PP_DEC__219	218
#define ROAST_PP_DEC__220	219
#define ROAST_PP_DEC__221	220
#define ROAST_PP_DEC__222	221
#define ROAST_PP_DEC__223	222
#define ROAST_PP_DEC__224	223
#define ROAST_PP_DEC__225	224
#define ROAST_PP_DEC__226	225
#define ROAST_PP_DEC__227	226
#define ROAST_PP_DEC__228	227
#define ROAST_PP_DEC__229	228
#define ROAST_PP_DEC__230	229
#define ROAST_PP_DEC__231	230
#define ROAST_PP_DEC__232	231
#define ROAST_PP_DEC__233	232
#define ROAST_PP_DEC__234	233
#define ROAST_PP_DEC__235	234
#define ROAST_PP_DEC__236	235
#define ROAST_PP_DEC__237	236
#define ROAST_PP_DEC__238	237
#define ROAST_PP_DEC__239	238
#define ROAST_PP_DEC__240	239
#define ROAST_PP_DEC__241	240
#define ROAST_PP_DEC__242	241
#define ROAST_PP_DEC__243	242
#define ROAST_PP_DEC__244	243
#define ROAST_PP_DEC__245	244
#define ROAST_PP_DEC__246	245
#define ROAST_PP_DEC__247	246
#define ROAST_PP_DEC__248	247
#define ROAST_PP_DEC__249	248
#define ROAST_PP_DEC__250	249
#define ROAST_PP_DEC__251	250
#define ROAST_PP_DEC__252	251
#define ROAST_PP_DEC__253	252
#define ROAST_PP_DEC__254	253
#define ROAST_PP_DEC__255	254
#define ROAST_PP_DEC__256	255

#define ROAST_PP_DEC_(x)	ROAST_PP_DEC__##x
#define ROAST_PP_DEC(x)		ROAST_PP_DEC_(x)

////////////////////////////////////////////////////////////////////////////

//	Plus/Addition - 足し算
#define ROAST_PP_PLUS_CALLBACK1(x)	ROAST_PP_INC ROAST_PP_LPARE
#define ROAST_PP_PLUS_CALLBACK2(x)	)
#define ROAST_PP_PLUS_(x,y)			ROAST_PP_REPEART_INC(x,ROAST_PP_PLUS_CALLBACK1) y ROAST_PP_REPEART_INC(x,ROAST_PP_PLUS_CALLBACK2)
#define ROAST_PP_PLUS(x,y)			ROAST_PP_PLUS_(x,y)
#define ROAST_PP_ADD(x,y)			ROAST_PP_PLUS_(x,y)

//	Minus/Subtraction - 引き算
#define ROAST_PP_MINUS_CALLBACK1(x)	ROAST_PP_DEC ROAST_PP_LPARE
#define ROAST_PP_MINUS_CALLBACK2(x)	)
#define ROAST_PP_MINUS_(x,y)		ROAST_PP_REPEART_INC(y,ROAST_PP_MINUS_CALLBACK1) x ROAST_PP_REPEART_INC(y,ROAST_PP_MINUS_CALLBACK2)
#define ROAST_PP_MINUS(x,y)			ROAST_PP_MINUS_(x,y)
#define ROAST_PP_SUB(x,y)			ROAST_PP_MINUS_(x,y)

//	Multiplication - 掛け算
#define ROAST_PP_MUL_CALLBACK1(x,param)	ROAST_PP_PLUS ROAST_PP_LPARE param,
#define ROAST_PP_MUL_CALLBACK2(x,param)	)
#define ROAST_PP_MUL_(x,y)				ROAST_PP_REPEART_INC_2(ROAST_PP_DEC(x),ROAST_PP_MUL_CALLBACK1,y) y ROAST_PP_REPEART_INC_2(ROAST_PP_DEC(x),ROAST_PP_MUL_CALLBACK2,y)
#define ROAST_PP_MUL(x,y)				ROAST_PP_MUL_(x,y)


#endif//__SFJP_OPENMGL__roast_pp_arithmetic_H__