2 SuperCollider real time audio synthesis system
3 Copyright (c) 2002 James McCartney. All rights reserved.
4 http://www.audiosynth.com
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27 #include "PyrPrimitive.h"
28 #include "VMGlobals.h"
31 int prToLower(struct VMGlobals
*g
, int numArgsPushed
);
32 int prToLower(struct VMGlobals
*g
, int numArgsPushed
)
38 SetRawChar(a
, tolower(slotRawChar(a
)));
43 int prToUpper(struct VMGlobals
*g
, int numArgsPushed
);
44 int prToUpper(struct VMGlobals
*g
, int numArgsPushed
)
50 SetRawChar(a
, toupper(slotRawChar(a
)));
55 int prIsAlpha(struct VMGlobals
*g
, int numArgsPushed
);
56 int prIsAlpha(struct VMGlobals
*g
, int numArgsPushed
)
62 if (isalpha(slotRawChar(a
))) { SetTrue(a
); }
68 int prIsAlphaNum(struct VMGlobals
*g
, int numArgsPushed
);
69 int prIsAlphaNum(struct VMGlobals
*g
, int numArgsPushed
)
75 if (isalnum(slotRawChar(a
))) { SetTrue(a
); }
81 int prIsControl(struct VMGlobals
*g
, int numArgsPushed
);
82 int prIsControl(struct VMGlobals
*g
, int numArgsPushed
)
88 if (iscntrl(slotRawChar(a
))) { SetTrue(a
); }
94 int prIsDigit(struct VMGlobals
*g
, int numArgsPushed
);
95 int prIsDigit(struct VMGlobals
*g
, int numArgsPushed
)
101 if (isdigit(slotRawChar(a
))) { SetTrue(a
); }
102 else { SetFalse(a
); }
107 int prIsPrint(struct VMGlobals
*g
, int numArgsPushed
);
108 int prIsPrint(struct VMGlobals
*g
, int numArgsPushed
)
114 if (isprint(slotRawChar(a
))) { SetTrue(a
); }
115 else { SetFalse(a
); }
120 int prIsPunct(struct VMGlobals
*g
, int numArgsPushed
);
121 int prIsPunct(struct VMGlobals
*g
, int numArgsPushed
)
127 if (ispunct(slotRawChar(a
))) { SetTrue(a
); }
128 else { SetFalse(a
); }
133 int prIsSpace(struct VMGlobals
*g
, int numArgsPushed
);
134 int prIsSpace(struct VMGlobals
*g
, int numArgsPushed
)
140 if (isspace(slotRawChar(a
))) { SetTrue(a
); }
141 else { SetFalse(a
); }
146 int prAsciiValue(struct VMGlobals
*g
, int numArgsPushed
);
147 int prAsciiValue(struct VMGlobals
*g
, int numArgsPushed
)
153 SetTagRaw(a
, tagInt
);
158 int prDigitValue(struct VMGlobals
*g
, int numArgsPushed
);
159 int prDigitValue(struct VMGlobals
*g
, int numArgsPushed
)
167 if (c
>= '0' && c
<= '9') {
169 } else if (c
>= 'a' && c
<= 'z') {
170 SetInt(a
, c
- 'a' + 10);
171 } else if (c
>= 'A' && c
<= 'Z') {
172 SetInt(a
, c
- 'A' + 10);
181 int prAsAscii(struct VMGlobals
*g
, int numArgsPushed
);
182 int prAsAscii(struct VMGlobals
*g
, int numArgsPushed
)
187 SetChar(a
, slotRawInt(a
) & 255);
192 int prAsDigit(struct VMGlobals
*g
, int numArgsPushed
);
193 int prAsDigit(struct VMGlobals
*g
, int numArgsPushed
)
201 if (c
>= 0 && c
<= 9) {
202 SetChar(a
, slotRawInt(a
) + '0');
203 } else if (c
>= 10 && c
<= 35) {
204 SetChar(a
, slotRawInt(a
) + 'A' - 10);
212 void initCharPrimitives();
213 void initCharPrimitives()
217 base
= nextPrimitiveIndex();
219 definePrimitive(base
, index
++, "_AsciiValue", prAsciiValue
, 1, 0);
220 definePrimitive(base
, index
++, "_DigitValue", prDigitValue
, 1, 0);
221 definePrimitive(base
, index
++, "_AsAscii", prAsAscii
, 1, 0);
222 definePrimitive(base
, index
++, "_AsDigit", prAsDigit
, 1, 0);
223 definePrimitive(base
, index
++, "_ToLower", prToLower
, 1, 0);
224 definePrimitive(base
, index
++, "_ToUpper", prToUpper
, 1, 0);
225 definePrimitive(base
, index
++, "_IsAlpha", prIsAlpha
, 1, 0);
226 definePrimitive(base
, index
++, "_IsAlphaNum", prIsAlphaNum
, 1, 0);
227 definePrimitive(base
, index
++, "_IsPrint", prIsPrint
, 1, 0);
228 definePrimitive(base
, index
++, "_IsPunct", prIsPunct
, 1, 0);
229 definePrimitive(base
, index
++, "_IsControl", prIsControl
, 1, 0);
230 definePrimitive(base
, index
++, "_IsSpace", prIsSpace
, 1, 0);
231 definePrimitive(base
, index
++, "_IsDecDigit", prIsDigit
, 1, 0);
240 #include "SCPlugin.h"
242 // export the function that SC will call to load the plug in.
244 extern "C" { SCPlugIn
* loadPlugIn(void); }
248 // define plug in object
249 class APlugIn
: public SCPlugIn
255 virtual void AboutToCompile();
260 // constructor for plug in
265 // destructor for plug in
268 void APlugIn::AboutToCompile()
270 // this is called each time the class library is compiled.
271 initCharPrimitives();
274 // This function is called when the plug in is loaded into SC.
275 // It returns an instance of APlugIn.
276 SCPlugIn
* loadPlugIn()
278 return new APlugIn();