mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
104 lines
2.4 KiB
C++
104 lines
2.4 KiB
C++
string read_file (string filename)
|
|
{
|
|
local QFile file;
|
|
local string data = NIL, d;
|
|
file = Qopen (filename, "rtz");
|
|
if (!file) {
|
|
printf ("Can't open %s for reading."
|
|
" Probably a bad hardcoded filename:)\n", filename);
|
|
return NIL;
|
|
}
|
|
while ((d = Qgetline (file)))
|
|
data = data + d;
|
|
//FIXME can't read to a string, can't convert a pointer to a string ...
|
|
//Qread (file, data, 1023);
|
|
Qclose (file);
|
|
d = str_new ();
|
|
str_copy (d, data);
|
|
return d;
|
|
}
|
|
|
|
void test_plist (void)
|
|
{
|
|
local string data, l;
|
|
local plitem_t pl;
|
|
|
|
data = read_file ("/home/bill/.quakeforge.dir");
|
|
pl = PL_GetPropertyList ("{" + data + "}");
|
|
l = PL_WritePropertyList (pl);
|
|
printf ("%s", data);
|
|
printf ("%s", l);
|
|
PL_Free (pl);
|
|
str_free (data);
|
|
}
|
|
|
|
void test_script (void)
|
|
{
|
|
local script_t script;
|
|
local string token;
|
|
local string data;
|
|
|
|
data = read_file ("progs.src");
|
|
script = Script_New ();
|
|
token = Script_Start (script, "progs.src", data);
|
|
while (Script_GetToken (script, 1)) {
|
|
printf ("%s\n", token);
|
|
}
|
|
Script_Delete (script);
|
|
str_free (data);
|
|
}
|
|
|
|
void () test_str =
|
|
{
|
|
local string a,b,c,d;
|
|
a = "testing ";
|
|
b = "temp ";
|
|
c = "strings ";
|
|
d = "\n";
|
|
print (a + b + c + d);
|
|
printf ("%i \"%.5s\" %3.4f %v\n", 14, "hi there", 3.1415926, '4 1 3');
|
|
};
|
|
void (...) dprint = #0;
|
|
integer (integer argc, string []argv) main =
|
|
{
|
|
local integer i;
|
|
local SEL sel;
|
|
dprint ("foo", "bar\n");
|
|
for (i = 0; i < argc; i++) {
|
|
print (argv[i]);
|
|
print ("\n");
|
|
}
|
|
local id foo = [[Foo alloc] init];
|
|
[foo run];
|
|
sel = sel_get_uid ("run");
|
|
if (sel) {
|
|
print ("found selector for `run'\n");
|
|
if ([foo respondsToSelector:sel])
|
|
print ("foo responds to `run'\n");
|
|
else
|
|
print ("foo does not repond to `run'\n");
|
|
} else
|
|
print ("did not find selector for `run'\n");
|
|
sel = sel_get_uid ("alloc");
|
|
if (sel) {
|
|
print ("found selector for `alloc'\n");
|
|
if ([Object instancesRespondToSelector:sel])
|
|
print ("Object instances respond to `alloc'\n");
|
|
else
|
|
print ("Object instances do not repond to `alloc'\n");
|
|
} else
|
|
print ("did not find selector for `alloc'\n");
|
|
sel = sel_get_uid ("run:with:me:");
|
|
if (sel) {
|
|
print ("found selector for `run:with:me:'\n");
|
|
if ([Object instancesRespondToSelector:sel])
|
|
print ("Object instances respond to `run:with:me:'\n");
|
|
else
|
|
print ("Object instances do not repond to `run:with:me:'\n");
|
|
} else
|
|
print ("did not find selector for `run:with:me:'\n");
|
|
test_str ();
|
|
test_script ();
|
|
test_plist ();
|
|
return 0;
|
|
};
|