1 /*
2     SuperCollider real time audio synthesis system
3     Copyright (c) 2002 James McCartney. All rights reserved.
4     http://www.audiosynth.com
5 
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.
10 
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.
15 
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
19 */
20 /*
21 
22 PyrSlot is a value holder for SC variables.
23 A PyrSlot is an 8-byte value which is either a double precision float or a
24 32-bit tag plus a 32-bit value.
25 
26 */
27 
28 #pragma once
29 
30 #if (__SIZEOF_POINTER__ == 8) || defined(__x86_64__) || defined(_M_X64) || defined(__LP64__) || defined(_WIN64)
31 #    include "PyrSlot64.h"
32 #elif (__SIZEOF_POINTER__ == 4) || defined(__i386__) || defined(_M_IX86) || defined(__ILP32__) || defined(_WIN32)      \
33     || defined(__ppc__) || defined(__arm__)
34 #    include "PyrSlot32.h"
35 #else
36 #    error "no PyrSlot imlementation for this platform"
37 #endif
38 
39 #include <string>
40 
41 extern PyrSlot o_nil, o_true, o_false, o_inf;
42 extern PyrSlot o_fhalf, o_fnegone, o_fzero, o_fone, o_ftwo;
43 extern PyrSlot o_negone, o_zero, o_one, o_two;
44 extern PyrSlot o_emptyarray, o_onenilarray, o_argnamethis;
45 
46 extern PyrSymbol* s_object; // "Object"
47 extern PyrSymbol* s_this; // "this"
48 extern PyrSymbol* s_super; // "super"
49 
50 void dumpPyrSlot(PyrSlot* slot);
51 void slotString(PyrSlot* slot, char* str);
52 void slotOneWord(PyrSlot* slot, char* str);
53 bool postString(PyrSlot* slot, char* str);
54 const char* slotSymString(PyrSlot* slot);
55 int asCompileString(PyrSlot* slot, char* str);
56 
57 int slotIntVal(PyrSlot* slot, int* value);
58 int slotFloatVal(PyrSlot* slot, float* value);
59 int slotDoubleVal(PyrSlot* slot, double* value);
60 int slotStrVal(PyrSlot* slot, char* str, int maxlen);
61 std::tuple<int, std::string> slotStdStrVal(PyrSlot* slot);
62 std::tuple<int, std::string> slotStrStdStrVal(PyrSlot* slot);
63 int slotStrLen(PyrSlot* slot);
64 int slotPStrVal(PyrSlot* slot, unsigned char* str);
65 int slotSymbolVal(PyrSlot* slot, PyrSymbol** symbol);
66 
67 template <typename numeric_type> inline void setSlotVal(PyrSlot* slot, numeric_type value);
68 
69 template <> inline void setSlotVal<int>(PyrSlot* slot, int value) { SetInt(slot, value); }
70 
71 template <> inline void setSlotVal<double>(PyrSlot* slot, double value) { SetFloat(slot, value); }
72