/
PyrPlatformPrim.cpp
92 lines (74 loc) · 2.98 KB
/
PyrPlatformPrim.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
SuperCollider real time audio synthesis system
Copyright (c) 2002 James McCartney. All rights reserved.
http://www.audiosynth.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
Primitives for platform dependent directories, constants etc.
*/
#include "SC_DirUtils.h"
#include "PyrPrimitive.h"
#include "PyrKernel.h"
#define PATH_CONSTANT_PRIM_BODY(func) \
PyrSlot *a = g->sp; \
char path[PATH_MAX]; \
func(path, PATH_MAX); \
PyrString* string = newPyrString(g->gc, path, 0, true); \
SetObject(a, string); \
return errNone
static int prPlatform_systemAppSupportDir(struct VMGlobals *g, int numArgsPushed)
{
PATH_CONSTANT_PRIM_BODY(sc_GetSystemAppSupportDirectory);
}
static int prPlatform_userAppSupportDir(struct VMGlobals *g, int numArgsPushed)
{
PATH_CONSTANT_PRIM_BODY(sc_GetUserAppSupportDirectory);
}
static int prPlatform_systemExtensionDir(struct VMGlobals *g, int numArgsPushed)
{
PATH_CONSTANT_PRIM_BODY(sc_GetSystemExtensionDirectory);
}
static int prPlatform_userExtensionDir(struct VMGlobals *g, int numArgsPushed)
{
PATH_CONSTANT_PRIM_BODY(sc_GetUserExtensionDirectory);
}
static int prPlatform_userConfigDir(struct VMGlobals *g, int numArgsPushed)
{
PATH_CONSTANT_PRIM_BODY(sc_GetUserConfigDirectory);
}
static int prPlatform_resourceDir(struct VMGlobals *g, int numArgsPushed)
{
PATH_CONSTANT_PRIM_BODY(sc_GetResourceDirectory);
}
static int prPlatform_ideName(struct VMGlobals *g, int numArgsPushed)
{
PyrSlot *a = g->sp;
PyrString* string = newPyrString(g->gc, gIdeName, 0, true);
SetObject(a, string);
return errNone;
}
void initPlatformPrimitives();
void initPlatformPrimitives()
{
int base, index = 0;
base = nextPrimitiveIndex();
definePrimitive(base, index++, "_Platform_systemAppSupportDir", prPlatform_systemAppSupportDir, 1, 0);
definePrimitive(base, index++, "_Platform_userAppSupportDir", prPlatform_userAppSupportDir, 1, 0);
definePrimitive(base, index++, "_Platform_systemExtensionDir", prPlatform_systemExtensionDir, 1, 0);
definePrimitive(base, index++, "_Platform_userExtensionDir", prPlatform_userExtensionDir, 1, 0);
definePrimitive(base, index++, "_Platform_userConfigDir", prPlatform_userConfigDir, 1, 0);
definePrimitive(base, index++, "_Platform_resourceDir", prPlatform_resourceDir, 1, 0);
definePrimitive(base, index++, "_Platform_ideName", prPlatform_ideName, 1, 0);
}
// EOF