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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
// Shave and a Haircut
// (c) 2019 Epic Games
// US Patent 6720962
//
// Script to create sample/include/shaveSDKFUNCS2.h & shaveSDKCALLBACKS2.h
//
// To execute: cscript mkSDKincludes.js
//
var fs = WScript.CreateObject("Scripting.FileSystemObject");
var altNamesFile;
var sdkFuncsFile;
var sdkCallbacksFile;
try
{
altNamesFile = fs.OpenTextFile("shaveSDKALTNAMES.h", 1, false, 0);
}
catch(e)
{
WScript.Echo("Could not find shaveSDKALTNAMES.h");
WScript.Quit();
}
try
{
sdkFuncsFile = fs.OpenTextFile("shaveSDKFUNCS.h", 1, false, 0);
}
catch(e)
{
WScript.Echo("Could not find shaveSDKFUNCS.h");
WScript.Quit();
}
try
{
sdkCallbacksFile = fs.OpenTextFile("shaveSDKCALLBACKS.h", 1, false, 0);
}
catch(e)
{
WScript.Echo("Could not find shaveSDKCALLBACKS.h");
WScript.Quit();
}
//
// Find the '#ifdef ALTERNATE_DEFS' line.
//
var line;
while (!altNamesFile.AtEndOfStream)
{
line = altNamesFile.ReadLine();
if ((line.indexOf("#ifdef") >= 0) && (line.indexOf("ALTERNATE_DEFS") >= 0))
break;
}
//
// Store all the name pairs in a pair of arrays.
//
var names = new Array();
var altNames = new Array();
while (!altNamesFile.AtEndOfStream)
{
line = altNamesFile.ReadLine();
var words = line.split(/[ \t]/);
if (words.length > 0)
{
if (words[0] == "#endif") break;
if ((words[0] == "#define") && (words.length == 3))
{
names[names.length] = new RegExp(words[1] + "[ \\t]*\\(");
altNames[altNames.length] = words[2] + "(";
}
}
}
altNamesFile.Close();
//
// Create the shaveSDKFUNCS2.h file in sample\include.
//
var sdkFuncs2File;
try
{
sdkFuncs2File = fs.CreateTextFile("sample\\include\\shaveSDKFUNCS2.h", true);
}
catch(e)
{
WScript.Echo("Cannot create sample\\include\\shaveSDKFUNCS2.h.");
}
//
// Step through each line of the original sdkFuncsFile, replacing the func
// names with their alternate names.
//
while (!sdkFuncsFile.AtEndOfStream)
{
line = sdkFuncsFile.ReadLine();
//
// Don't even both trying to do substitutions on blank lines or comment
// lines.
//
if ((line.match(/^[ \t]*$/) == null) && (line.match(/^[ \t]*\/\//) == null))
{
for (i = 0; i < names.length; i++)
{
line = line.replace(names[i], altNames[i]);
}
}
sdkFuncs2File.WriteLine(line);
}
sdkFuncsFile.Close();
sdkFuncs2File.Close();
//
// Create the shaveSDKCALLBACKS2.h file in sample\include.
//
var sdkCallbacks2File;
try
{
sdkCallbacks2File = fs.CreateTextFile("sample\\include\\shaveSDKCALLBACKS2.h", true);
}
catch(e)
{
WScript.Echo("Cannot create sample\\include\\shaveSDKCALLBACKS2.h.");
}
//
// Step through each line of the original sdkCallbacksFile, replacing the func
// names with their alternate names.
//
while (!sdkCallbacksFile.AtEndOfStream)
{
line = sdkCallbacksFile.ReadLine();
//
// Don't even both trying to do substitutions on blank lines or comment
// lines.
//
if ((line.match(/^[ \t]*$/) == null) && (line.match(/^[ \t]*\/\//) == null))
{
for (i = 0; i < names.length; i++)
{
line = line.replace(names[i], altNames[i]);
}
}
sdkCallbacks2File.WriteLine(line);
}
sdkCallbacksFile.Close();
sdkCallbacks2File.Close();
|