Normalize line endings
This commit is contained in:
parent
07802f741a
commit
5ecee7c582
@ -1,10 +1,10 @@
|
||||
#include <args>
|
||||
|
||||
main()
|
||||
{
|
||||
printf "Argument count = %d\n", argcount()
|
||||
|
||||
new opt[100]
|
||||
for (new index = 0; argindex(index, opt); index++)
|
||||
printf "Argument %d = %s\n", index, opt
|
||||
}
|
||||
#include <args>
|
||||
|
||||
main()
|
||||
{
|
||||
printf "Argument count = %d\n", argcount()
|
||||
|
||||
new opt[100]
|
||||
for (new index = 0; argindex(index, opt); index++)
|
||||
printf "Argument %d = %s\n", index, opt
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
#include <rational>
|
||||
|
||||
main()
|
||||
{
|
||||
new Rational: Celsius
|
||||
new Rational: Fahrenheit
|
||||
|
||||
print "Celsius\t Fahrenheit\n"
|
||||
for (Celsius = 5; Celsius <= 25; Celsius++)
|
||||
{
|
||||
Fahrenheit = (Celsius * 1.8) + 32
|
||||
printf "%r \t %r\n", Celsius, Fahrenheit
|
||||
}
|
||||
}
|
||||
#include <rational>
|
||||
|
||||
main()
|
||||
{
|
||||
new Rational: Celsius
|
||||
new Rational: Fahrenheit
|
||||
|
||||
print "Celsius\t Fahrenheit\n"
|
||||
for (Celsius = 5; Celsius <= 25; Celsius++)
|
||||
{
|
||||
Fahrenheit = (Celsius * 1.8) + 32
|
||||
printf "%r \t %r\n", Celsius, Fahrenheit
|
||||
}
|
||||
}
|
||||
|
@ -1,37 +1,37 @@
|
||||
bool: ispacked(string[])
|
||||
return bool: (string[0] > charmax)
|
||||
|
||||
my_strlen(string[])
|
||||
{
|
||||
new len = 0
|
||||
if (ispacked(string))
|
||||
while (string{len} != EOS) /* get character from pack */
|
||||
++len
|
||||
else
|
||||
while (string[len] != EOS) /* get cell */
|
||||
++len
|
||||
return len
|
||||
}
|
||||
|
||||
strupper(string[])
|
||||
{
|
||||
assert ispacked(string)
|
||||
|
||||
for (new i=0; string{i} != EOS; ++i)
|
||||
string{i} = toupper(string{i})
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
new s[10]
|
||||
|
||||
for (new i = 0; i < 5; i++)
|
||||
s{i}=i+'a'
|
||||
s{5}=EOS
|
||||
|
||||
printf("String is %s\n", ispacked(s) ? "packed" : "unpacked")
|
||||
printf("String length is %d\n", my_strlen(s))
|
||||
printf("Original: %s\n", s)
|
||||
strupper(s)
|
||||
printf("Upper case: %s\n", s)
|
||||
}
|
||||
bool: ispacked(string[])
|
||||
return bool: (string[0] > charmax)
|
||||
|
||||
my_strlen(string[])
|
||||
{
|
||||
new len = 0
|
||||
if (ispacked(string))
|
||||
while (string{len} != EOS) /* get character from pack */
|
||||
++len
|
||||
else
|
||||
while (string[len] != EOS) /* get cell */
|
||||
++len
|
||||
return len
|
||||
}
|
||||
|
||||
strupper(string[])
|
||||
{
|
||||
assert ispacked(string)
|
||||
|
||||
for (new i=0; string{i} != EOS; ++i)
|
||||
string{i} = toupper(string{i})
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
new s[10]
|
||||
|
||||
for (new i = 0; i < 5; i++)
|
||||
s{i}=i+'a'
|
||||
s{5}=EOS
|
||||
|
||||
printf("String is %s\n", ispacked(s) ? "packed" : "unpacked")
|
||||
printf("String length is %d\n", my_strlen(s))
|
||||
printf("Original: %s\n", s)
|
||||
strupper(s)
|
||||
printf("Upper case: %s\n", s)
|
||||
}
|
||||
|
130
examples/cards.p
130
examples/cards.p
@ -1,65 +1,65 @@
|
||||
enum _: CardSuits
|
||||
{
|
||||
Clubs,
|
||||
Diamonds,
|
||||
Hearts,
|
||||
Spades,
|
||||
}
|
||||
|
||||
const CardTypes = 13
|
||||
const TotalCards = CardSuits * CardTypes
|
||||
|
||||
enum CardDescription
|
||||
{
|
||||
CardName[10 char],
|
||||
CardSuit,
|
||||
CardValue,
|
||||
}
|
||||
|
||||
new CardNames[CardTypes][] = { !"Ace", !"Two", !"Three", !"Four", !"Five",
|
||||
!"Six", !"Seven", !"Eight", !"Nine", !"Ten",
|
||||
!"Jack", !"Queen", !"King" }
|
||||
new CardValues[CardTypes] = { 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10 }
|
||||
|
||||
main()
|
||||
{
|
||||
new Cards[ TotalCards ][ CardDescription ]
|
||||
|
||||
/* fill in the cards */
|
||||
for (new suit = 0; suit < CardSuits; suit++)
|
||||
{
|
||||
for (new card = 0; card < CardTypes; card++)
|
||||
{
|
||||
new index = suit*CardTypes + card
|
||||
strpack Cards[ index ][CardName], CardNames[ card ]
|
||||
Cards[ index ][ CardSuit ] = suit
|
||||
Cards[ index ][ CardValue ] = CardValues[ card ]
|
||||
}
|
||||
}
|
||||
|
||||
/* shuffle the cards (swap an arbitrary number of randomly selected cards) */
|
||||
for (new iter = 0; iter < 200; iter++)
|
||||
{
|
||||
new first = random(TotalCards)
|
||||
new second = random(TotalCards)
|
||||
new TempCard[ CardDescription ]
|
||||
TempCard = Cards[first]
|
||||
Cards[ first ] = Cards[ second ]
|
||||
Cards[ second ] = TempCard
|
||||
}
|
||||
|
||||
/* print the cards with a subroutine */
|
||||
for (new card = 0; card < TotalCards; card++)
|
||||
PrintCard Cards[ card]
|
||||
}
|
||||
|
||||
PrintCard( TheCard[ CardDescription ] )
|
||||
{
|
||||
new SuitNames[ CardSuits ][] = { !"Clubs", !"Diamonds",
|
||||
!"Hearts", !"Spades" }
|
||||
|
||||
printf !"%s of %s (valued %d)\n",
|
||||
TheCard[ CardName ],
|
||||
SuitNames[ TheCard[ CardSuit ] ],
|
||||
TheCard[ CardValue ]
|
||||
}
|
||||
enum _: CardSuits
|
||||
{
|
||||
Clubs,
|
||||
Diamonds,
|
||||
Hearts,
|
||||
Spades,
|
||||
}
|
||||
|
||||
const CardTypes = 13
|
||||
const TotalCards = CardSuits * CardTypes
|
||||
|
||||
enum CardDescription
|
||||
{
|
||||
CardName[10 char],
|
||||
CardSuit,
|
||||
CardValue,
|
||||
}
|
||||
|
||||
new CardNames[CardTypes][] = { !"Ace", !"Two", !"Three", !"Four", !"Five",
|
||||
!"Six", !"Seven", !"Eight", !"Nine", !"Ten",
|
||||
!"Jack", !"Queen", !"King" }
|
||||
new CardValues[CardTypes] = { 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10 }
|
||||
|
||||
main()
|
||||
{
|
||||
new Cards[ TotalCards ][ CardDescription ]
|
||||
|
||||
/* fill in the cards */
|
||||
for (new suit = 0; suit < CardSuits; suit++)
|
||||
{
|
||||
for (new card = 0; card < CardTypes; card++)
|
||||
{
|
||||
new index = suit*CardTypes + card
|
||||
strpack Cards[ index ][CardName], CardNames[ card ]
|
||||
Cards[ index ][ CardSuit ] = suit
|
||||
Cards[ index ][ CardValue ] = CardValues[ card ]
|
||||
}
|
||||
}
|
||||
|
||||
/* shuffle the cards (swap an arbitrary number of randomly selected cards) */
|
||||
for (new iter = 0; iter < 200; iter++)
|
||||
{
|
||||
new first = random(TotalCards)
|
||||
new second = random(TotalCards)
|
||||
new TempCard[ CardDescription ]
|
||||
TempCard = Cards[first]
|
||||
Cards[ first ] = Cards[ second ]
|
||||
Cards[ second ] = TempCard
|
||||
}
|
||||
|
||||
/* print the cards with a subroutine */
|
||||
for (new card = 0; card < TotalCards; card++)
|
||||
PrintCard Cards[ card]
|
||||
}
|
||||
|
||||
PrintCard( TheCard[ CardDescription ] )
|
||||
{
|
||||
new SuitNames[ CardSuits ][] = { !"Clubs", !"Diamonds",
|
||||
!"Hearts", !"Spades" }
|
||||
|
||||
printf !"%s of %s (valued %d)\n",
|
||||
TheCard[ CardName ],
|
||||
SuitNames[ TheCard[ CardSuit ] ],
|
||||
TheCard[ CardValue ]
|
||||
}
|
||||
|
@ -1,31 +1,31 @@
|
||||
#include <datagram>
|
||||
|
||||
@receivestring(const message[], const source[])
|
||||
printf "[%s] says: %s\n", source, message
|
||||
|
||||
@keypressed(key)
|
||||
{
|
||||
static string[100 char]
|
||||
static index
|
||||
|
||||
if (key == '\e')
|
||||
exit /* quit on 'Esc' key */
|
||||
|
||||
echo key
|
||||
if (key == '\r' || key == '\n' || index char == sizeof string)
|
||||
{
|
||||
string{index} = '\0' /* terminate string */
|
||||
sendstring string
|
||||
index = 0
|
||||
string[index] = '\0'
|
||||
}
|
||||
else
|
||||
string{index++} = key
|
||||
}
|
||||
|
||||
echo(key)
|
||||
{
|
||||
new string[2 char] = { 0 }
|
||||
string{0} = key == '\r' ? '\n' : key
|
||||
printf string
|
||||
}
|
||||
#include <datagram>
|
||||
|
||||
@receivestring(const message[], const source[])
|
||||
printf "[%s] says: %s\n", source, message
|
||||
|
||||
@keypressed(key)
|
||||
{
|
||||
static string[100 char]
|
||||
static index
|
||||
|
||||
if (key == '\e')
|
||||
exit /* quit on 'Esc' key */
|
||||
|
||||
echo key
|
||||
if (key == '\r' || key == '\n' || index char == sizeof string)
|
||||
{
|
||||
string{index} = '\0' /* terminate string */
|
||||
sendstring string
|
||||
index = 0
|
||||
string[index] = '\0'
|
||||
}
|
||||
else
|
||||
string{index++} = key
|
||||
}
|
||||
|
||||
echo(key)
|
||||
{
|
||||
new string[2 char] = { 0 }
|
||||
string{0} = key == '\r' ? '\n' : key
|
||||
printf string
|
||||
}
|
||||
|
@ -1,45 +1,45 @@
|
||||
/* parse C comments interactively, using events and a state machine */
|
||||
|
||||
main()
|
||||
state plain
|
||||
|
||||
@keypressed(key) <plain>
|
||||
{
|
||||
state (key == '/') slash
|
||||
if (key != '/')
|
||||
echo key
|
||||
}
|
||||
|
||||
@keypressed(key) <slash>
|
||||
{
|
||||
state (key != '/') plain
|
||||
state (key == '*') comment
|
||||
echo '/' /* print '/' held back from previous state */
|
||||
if (key != '/')
|
||||
echo key
|
||||
}
|
||||
|
||||
@keypressed(key) <comment>
|
||||
{
|
||||
echo key
|
||||
state (key == '*') star
|
||||
}
|
||||
|
||||
@keypressed(key) <star>
|
||||
{
|
||||
echo key
|
||||
state (key != '*') comment
|
||||
state (key == '/') plain
|
||||
}
|
||||
|
||||
echo(key) <plain, slash>
|
||||
printchar key, yellow
|
||||
|
||||
echo(key) <comment, star>
|
||||
printchar key, green
|
||||
|
||||
printchar(ch, colour)
|
||||
{
|
||||
setattr .foreground = colour
|
||||
printf "%c", ch
|
||||
}
|
||||
/* parse C comments interactively, using events and a state machine */
|
||||
|
||||
main()
|
||||
state plain
|
||||
|
||||
@keypressed(key) <plain>
|
||||
{
|
||||
state (key == '/') slash
|
||||
if (key != '/')
|
||||
echo key
|
||||
}
|
||||
|
||||
@keypressed(key) <slash>
|
||||
{
|
||||
state (key != '/') plain
|
||||
state (key == '*') comment
|
||||
echo '/' /* print '/' held back from previous state */
|
||||
if (key != '/')
|
||||
echo key
|
||||
}
|
||||
|
||||
@keypressed(key) <comment>
|
||||
{
|
||||
echo key
|
||||
state (key == '*') star
|
||||
}
|
||||
|
||||
@keypressed(key) <star>
|
||||
{
|
||||
echo key
|
||||
state (key != '*') comment
|
||||
state (key == '/') plain
|
||||
}
|
||||
|
||||
echo(key) <plain, slash>
|
||||
printchar key, yellow
|
||||
|
||||
echo(key) <comment, star>
|
||||
printchar key, green
|
||||
|
||||
printchar(ch, colour)
|
||||
{
|
||||
setattr .foreground = colour
|
||||
printf "%c", ch
|
||||
}
|
||||
|
@ -1,20 +1,20 @@
|
||||
/* Calculation of the faculty of a value */
|
||||
|
||||
main()
|
||||
{
|
||||
print "Enter a value: "
|
||||
new v = getvalue()
|
||||
new f = faculty(v)
|
||||
printf "The faculty of %d is %d\n", v, f
|
||||
}
|
||||
|
||||
faculty(n)
|
||||
{
|
||||
assert n >= 0
|
||||
|
||||
new result = 1
|
||||
while (n > 0)
|
||||
result *= n--
|
||||
|
||||
return result
|
||||
}
|
||||
/* Calculation of the faculty of a value */
|
||||
|
||||
main()
|
||||
{
|
||||
print "Enter a value: "
|
||||
new v = getvalue()
|
||||
new f = faculty(v)
|
||||
printf "The faculty of %d is %d\n", v, f
|
||||
}
|
||||
|
||||
faculty(n)
|
||||
{
|
||||
assert n >= 0
|
||||
|
||||
new result = 1
|
||||
while (n > 0)
|
||||
result *= n--
|
||||
|
||||
return result
|
||||
}
|
||||
|
@ -1,26 +1,26 @@
|
||||
/* Calculation of Fibonacci numbers by iteration */
|
||||
|
||||
main()
|
||||
{
|
||||
print "Enter a value: "
|
||||
new v = getvalue()
|
||||
if (v > 0)
|
||||
printf "The value of Fibonacci number %d is %d\n",
|
||||
v, fibonacci(v)
|
||||
else
|
||||
printf "The Fibonacci number %d does not exist\n", v
|
||||
}
|
||||
|
||||
fibonacci(n)
|
||||
{
|
||||
assert n > 0
|
||||
|
||||
new a = 0, b = 1
|
||||
for (new i = 2; i < n; i++)
|
||||
{
|
||||
new c = a + b
|
||||
a = b
|
||||
b = c
|
||||
}
|
||||
return a + b
|
||||
}
|
||||
/* Calculation of Fibonacci numbers by iteration */
|
||||
|
||||
main()
|
||||
{
|
||||
print "Enter a value: "
|
||||
new v = getvalue()
|
||||
if (v > 0)
|
||||
printf "The value of Fibonacci number %d is %d\n",
|
||||
v, fibonacci(v)
|
||||
else
|
||||
printf "The Fibonacci number %d does not exist\n", v
|
||||
}
|
||||
|
||||
fibonacci(n)
|
||||
{
|
||||
assert n > 0
|
||||
|
||||
new a = 0, b = 1
|
||||
for (new i = 2; i < n; i++)
|
||||
{
|
||||
new c = a + b
|
||||
a = b
|
||||
b = c
|
||||
}
|
||||
return a + b
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
The greatest common divisor of two values,
|
||||
using Euclides' algorithm .
|
||||
*/
|
||||
|
||||
main()
|
||||
{
|
||||
print "Input two values\n"
|
||||
new a = getvalue()
|
||||
new b = getvalue()
|
||||
while (a != b)
|
||||
if (a > b)
|
||||
a = a - b
|
||||
else
|
||||
b = b - a
|
||||
printf "The greatest common divisor is %d\n", a
|
||||
}
|
||||
/*
|
||||
The greatest common divisor of two values,
|
||||
using Euclides' algorithm .
|
||||
*/
|
||||
|
||||
main()
|
||||
{
|
||||
print "Input two values\n"
|
||||
new a = getvalue()
|
||||
new b = getvalue()
|
||||
while (a != b)
|
||||
if (a > b)
|
||||
a = a - b
|
||||
else
|
||||
b = b - a
|
||||
printf "The greatest common divisor is %d\n", a
|
||||
}
|
||||
|
@ -1,297 +1,297 @@
|
||||
/* A demo GTK application in Pawn, using gtk-server and the "process control"
|
||||
* module for Pawn. This example also illustrates the use of (communicating)
|
||||
* finite state machines.
|
||||
*/
|
||||
#include <process>
|
||||
#include <string>
|
||||
|
||||
enum Btn
|
||||
{
|
||||
Btn0, Btn1, Btn2,
|
||||
Btn3, Btn4, Btn5,
|
||||
Btn6, Btn7, Btn8,
|
||||
Btn9, BtnDot, BtnC,
|
||||
BtnCE, BtnPlus, BtnMin,
|
||||
BtnMul, BtnDiv, BtnEqual,
|
||||
BtnNone,
|
||||
}
|
||||
|
||||
static entry /* GTK "entry" widget */
|
||||
static numberstring[40 char]
|
||||
static accum
|
||||
static Btn:pending_op
|
||||
|
||||
adddigit(digit, bool:reset = false)
|
||||
{
|
||||
new command[80 char], charstr[2 char]
|
||||
charstr{0} = (0 <= digit <= 9) ? digit + '0' : digit
|
||||
if (reset)
|
||||
numberstring[0] = EOS
|
||||
strcat numberstring, charstr
|
||||
strformat command, _, true, "gtk_entry_set_text %d %s", entry, numberstring
|
||||
GTK(command)
|
||||
}
|
||||
|
||||
displayresult(value)
|
||||
{
|
||||
new command[80 char]
|
||||
valstr numberstring, value, true
|
||||
strformat command, _, true, "gtk_entry_set_text %d %s", entry, numberstring
|
||||
GTK(command)
|
||||
}
|
||||
|
||||
|
||||
resetentry(digit) <number:negated>
|
||||
{
|
||||
adddigit '-', .reset = true
|
||||
adddigit digit
|
||||
}
|
||||
|
||||
resetentry(digit) <>
|
||||
{
|
||||
adddigit digit, .reset = true
|
||||
}
|
||||
|
||||
|
||||
event_0() <number:zero, number:negated>
|
||||
{
|
||||
resetentry 0
|
||||
}
|
||||
|
||||
event_0() <number:int, number:frac>
|
||||
{
|
||||
adddigit 0
|
||||
}
|
||||
|
||||
event_1_9(Btn:idx) <number:zero, number:negated>
|
||||
{
|
||||
resetentry _:(idx - Btn0)
|
||||
state number:int
|
||||
}
|
||||
|
||||
event_1_9(Btn:idx) <number:int, number:frac>
|
||||
{
|
||||
adddigit _:(idx - Btn0)
|
||||
}
|
||||
|
||||
event_dot() <number:zero, number:negated>
|
||||
{
|
||||
resetentry 0
|
||||
adddigit '.'
|
||||
state number:frac
|
||||
}
|
||||
|
||||
event_dot() <number:int>
|
||||
{
|
||||
adddigit '.'
|
||||
state number:frac
|
||||
}
|
||||
|
||||
event_dot() <number:frac>
|
||||
{
|
||||
/* reject entry */
|
||||
}
|
||||
|
||||
event_minus() <number:zero, number:negated>
|
||||
{
|
||||
state number:negated
|
||||
resetentry 0
|
||||
}
|
||||
|
||||
event_minus() <>
|
||||
{
|
||||
event_oper BtnMin /* forward to the "calc" automaton */
|
||||
}
|
||||
|
||||
|
||||
/* helper function for the calculator automaton */
|
||||
performoperation()
|
||||
{
|
||||
/* get the other operand, perform the operation */
|
||||
new val = strval(numberstring)
|
||||
switch (pending_op)
|
||||
{
|
||||
case BtnPlus: accum += val
|
||||
case BtnMin: accum -= val
|
||||
case BtnMul: accum *= val
|
||||
case BtnDiv: accum = (val == 0) ? 0 : accum / val
|
||||
}
|
||||
displayresult accum
|
||||
}
|
||||
|
||||
event_oper(Btn:idx) <calc:idle>
|
||||
{
|
||||
/* save operand and operator */
|
||||
accum = strval(numberstring)
|
||||
pending_op = idx
|
||||
|
||||
state number:zero
|
||||
state calc:pending
|
||||
}
|
||||
|
||||
event_oper(Btn:idx) <calc:pending>
|
||||
{
|
||||
performoperation /* do the pending operation */
|
||||
pending_op = idx /* save the operator for the next operation */
|
||||
state number:zero
|
||||
}
|
||||
|
||||
event_equal() <calc:idle>
|
||||
{
|
||||
/* ignore */
|
||||
}
|
||||
|
||||
event_equal() <calc:pending>
|
||||
{
|
||||
performoperation /* do the pending operation */
|
||||
state calc:idle /* reset the calculator */
|
||||
state number:zero
|
||||
}
|
||||
|
||||
|
||||
event_C()
|
||||
{
|
||||
state calc:idle
|
||||
state number:zero
|
||||
resetentry 0
|
||||
}
|
||||
|
||||
event_CE()
|
||||
{
|
||||
state number:zero
|
||||
resetentry 0
|
||||
}
|
||||
|
||||
|
||||
main()
|
||||
{
|
||||
if (!procexec("gtk-server stdin") && !procexec("gtk-server.exe stdin"))
|
||||
fatal "unable to launch gtk-server"
|
||||
|
||||
/* make a window */
|
||||
GTK("gtk_init NULL NULL")
|
||||
new win = GTK("gtk_window_new 0")
|
||||
GTK("gtk_window_set_title %d \"Pawn calculator\"", win)
|
||||
GTK("gtk_widget_set_usize %d 200 200", win)
|
||||
|
||||
/* add a table (align the other controls) */
|
||||
new table = GTK("gtk_table_new 50 50 1")
|
||||
GTK("gtk_container_add %d %d", win, table)
|
||||
|
||||
/* the number entry */
|
||||
entry = GTK("gtk_entry_new")
|
||||
GTK("gtk_table_attach_defaults %d %d 1 49 1 9", table, entry)
|
||||
|
||||
/* the key pad */
|
||||
new buttons[Btn]
|
||||
buttons[BtnDot] = GTK("gtk_button_new_with_label .")
|
||||
GTK("gtk_table_attach_defaults %d %d 21 29 41 49", table, buttons[BtnDot])
|
||||
buttons[Btn0] = GTK("gtk_button_new_with_label 0")
|
||||
GTK("gtk_table_attach_defaults %d %d 1 19 41 49", table, buttons[Btn0])
|
||||
buttons[Btn1] = GTK("gtk_button_new_with_label 1")
|
||||
GTK("gtk_table_attach_defaults %d %d 1 9 31 39", table, buttons[Btn1])
|
||||
buttons[Btn2] = GTK("gtk_button_new_with_label 2")
|
||||
GTK("gtk_table_attach_defaults %d %d 11 19 31 39", table, buttons[Btn2])
|
||||
buttons[Btn3] = GTK("gtk_button_new_with_label 3")
|
||||
GTK("gtk_table_attach_defaults %d %d 21 29 31 39", table, buttons[Btn3])
|
||||
buttons[Btn4] = GTK("gtk_button_new_with_label 4")
|
||||
GTK("gtk_table_attach_defaults %d %d 1 9 21 29", table, buttons[Btn4])
|
||||
buttons[Btn5] = GTK("gtk_button_new_with_label 5")
|
||||
GTK("gtk_table_attach_defaults %d %d 11 19 21 29", table, buttons[Btn5])
|
||||
buttons[Btn6] = GTK("gtk_button_new_with_label 6")
|
||||
GTK("gtk_table_attach_defaults %d %d 21 29 21 29", table, buttons[Btn6])
|
||||
buttons[Btn7] = GTK("gtk_button_new_with_label 7")
|
||||
GTK("gtk_table_attach_defaults %d %d 1 9 11 19", table, buttons[Btn7])
|
||||
buttons[Btn8] = GTK("gtk_button_new_with_label 8")
|
||||
GTK("gtk_table_attach_defaults %d %d 11 19 11 19", table, buttons[Btn8])
|
||||
buttons[Btn9] = GTK("gtk_button_new_with_label 9")
|
||||
GTK("gtk_table_attach_defaults %d %d 21 29 11 19", table, buttons[Btn9])
|
||||
|
||||
buttons[BtnC] = GTK("gtk_button_new_with_label C")
|
||||
GTK("gtk_table_attach_defaults %d %d 31 39 11 19", table, buttons[BtnC])
|
||||
buttons[BtnCE] = GTK("gtk_button_new_with_label CE")
|
||||
GTK("gtk_table_attach_defaults %d %d 41 49 11 19", table, buttons[BtnCE])
|
||||
buttons[BtnPlus] = GTK("gtk_button_new_with_label +")
|
||||
GTK("gtk_table_attach_defaults %d %d 31 39 21 29", table, buttons[BtnPlus])
|
||||
buttons[BtnMin] = GTK("gtk_button_new_with_label -")
|
||||
GTK("gtk_table_attach_defaults %d %d 41 49 21 29", table, buttons[BtnMin])
|
||||
buttons[BtnMul] = GTK("gtk_button_new_with_label x")
|
||||
GTK("gtk_table_attach_defaults %d %d 31 39 31 39", table, buttons[BtnMul])
|
||||
buttons[BtnDiv] = GTK("gtk_button_new_with_label /")
|
||||
GTK("gtk_table_attach_defaults %d %d 41 49 31 39", table, buttons[BtnDiv])
|
||||
buttons[BtnEqual] = GTK("gtk_button_new_with_label =")
|
||||
GTK("gtk_table_attach_defaults %d %d 31 49 41 49", table, buttons[BtnEqual])
|
||||
|
||||
/* initialize automata */
|
||||
state number:zero
|
||||
state calc:idle
|
||||
|
||||
/* wait for events, and dispatch them */
|
||||
GTK("gtk_widget_show_all %d", win)
|
||||
|
||||
resetentry 0
|
||||
new event
|
||||
new Btn:idx
|
||||
do
|
||||
{
|
||||
event = GTK("gtk_server_callback wait")
|
||||
|
||||
/* find the button matching the event, generate the event */
|
||||
for (idx = Btn0; idx < BtnNone && buttons[idx] != event; idx++)
|
||||
{}
|
||||
switch (idx)
|
||||
{
|
||||
case Btn0:
|
||||
event_0
|
||||
case Btn1 .. Btn9:
|
||||
event_1_9 idx
|
||||
case BtnDot:
|
||||
event_dot
|
||||
case BtnMin:
|
||||
event_minus
|
||||
case BtnPlus, BtnMul, BtnDiv:
|
||||
event_oper idx
|
||||
case BtnEqual:
|
||||
event_equal
|
||||
case BtnC:
|
||||
event_C
|
||||
case BtnCE:
|
||||
event_CE
|
||||
}
|
||||
}
|
||||
while (event != win);
|
||||
|
||||
/* direct call, because we must not wait for a reply on this command */
|
||||
procwrite "gtk_exit 0", true
|
||||
}
|
||||
|
||||
GTK(const format[], ...)
|
||||
{
|
||||
new command[256 char]
|
||||
switch (numargs())
|
||||
{
|
||||
case 1:
|
||||
strpack command, format
|
||||
case 2:
|
||||
strformat command, _, true, format, getarg(1)
|
||||
case 3:
|
||||
strformat command, _, true, format, getarg(1), getarg(2)
|
||||
case 4:
|
||||
strformat command, _, true, format, getarg(1), getarg(2), getarg(3)
|
||||
case 5:
|
||||
strformat command, _, true, format, getarg(1), getarg(2), getarg(3), getarg(4)
|
||||
}
|
||||
procwrite command, true
|
||||
|
||||
new reply[30]
|
||||
procread reply, .striplf=true
|
||||
if (strcmp(reply, "ok") == 0)
|
||||
return true
|
||||
return strval(reply)
|
||||
}
|
||||
|
||||
fatal(const message[])
|
||||
{
|
||||
printf "FATAL: %s\n", message
|
||||
exit
|
||||
}
|
||||
/* A demo GTK application in Pawn, using gtk-server and the "process control"
|
||||
* module for Pawn. This example also illustrates the use of (communicating)
|
||||
* finite state machines.
|
||||
*/
|
||||
#include <process>
|
||||
#include <string>
|
||||
|
||||
enum Btn
|
||||
{
|
||||
Btn0, Btn1, Btn2,
|
||||
Btn3, Btn4, Btn5,
|
||||
Btn6, Btn7, Btn8,
|
||||
Btn9, BtnDot, BtnC,
|
||||
BtnCE, BtnPlus, BtnMin,
|
||||
BtnMul, BtnDiv, BtnEqual,
|
||||
BtnNone,
|
||||
}
|
||||
|
||||
static entry /* GTK "entry" widget */
|
||||
static numberstring[40 char]
|
||||
static accum
|
||||
static Btn:pending_op
|
||||
|
||||
adddigit(digit, bool:reset = false)
|
||||
{
|
||||
new command[80 char], charstr[2 char]
|
||||
charstr{0} = (0 <= digit <= 9) ? digit + '0' : digit
|
||||
if (reset)
|
||||
numberstring[0] = EOS
|
||||
strcat numberstring, charstr
|
||||
strformat command, _, true, "gtk_entry_set_text %d %s", entry, numberstring
|
||||
GTK(command)
|
||||
}
|
||||
|
||||
displayresult(value)
|
||||
{
|
||||
new command[80 char]
|
||||
valstr numberstring, value, true
|
||||
strformat command, _, true, "gtk_entry_set_text %d %s", entry, numberstring
|
||||
GTK(command)
|
||||
}
|
||||
|
||||
|
||||
resetentry(digit) <number:negated>
|
||||
{
|
||||
adddigit '-', .reset = true
|
||||
adddigit digit
|
||||
}
|
||||
|
||||
resetentry(digit) <>
|
||||
{
|
||||
adddigit digit, .reset = true
|
||||
}
|
||||
|
||||
|
||||
event_0() <number:zero, number:negated>
|
||||
{
|
||||
resetentry 0
|
||||
}
|
||||
|
||||
event_0() <number:int, number:frac>
|
||||
{
|
||||
adddigit 0
|
||||
}
|
||||
|
||||
event_1_9(Btn:idx) <number:zero, number:negated>
|
||||
{
|
||||
resetentry _:(idx - Btn0)
|
||||
state number:int
|
||||
}
|
||||
|
||||
event_1_9(Btn:idx) <number:int, number:frac>
|
||||
{
|
||||
adddigit _:(idx - Btn0)
|
||||
}
|
||||
|
||||
event_dot() <number:zero, number:negated>
|
||||
{
|
||||
resetentry 0
|
||||
adddigit '.'
|
||||
state number:frac
|
||||
}
|
||||
|
||||
event_dot() <number:int>
|
||||
{
|
||||
adddigit '.'
|
||||
state number:frac
|
||||
}
|
||||
|
||||
event_dot() <number:frac>
|
||||
{
|
||||
/* reject entry */
|
||||
}
|
||||
|
||||
event_minus() <number:zero, number:negated>
|
||||
{
|
||||
state number:negated
|
||||
resetentry 0
|
||||
}
|
||||
|
||||
event_minus() <>
|
||||
{
|
||||
event_oper BtnMin /* forward to the "calc" automaton */
|
||||
}
|
||||
|
||||
|
||||
/* helper function for the calculator automaton */
|
||||
performoperation()
|
||||
{
|
||||
/* get the other operand, perform the operation */
|
||||
new val = strval(numberstring)
|
||||
switch (pending_op)
|
||||
{
|
||||
case BtnPlus: accum += val
|
||||
case BtnMin: accum -= val
|
||||
case BtnMul: accum *= val
|
||||
case BtnDiv: accum = (val == 0) ? 0 : accum / val
|
||||
}
|
||||
displayresult accum
|
||||
}
|
||||
|
||||
event_oper(Btn:idx) <calc:idle>
|
||||
{
|
||||
/* save operand and operator */
|
||||
accum = strval(numberstring)
|
||||
pending_op = idx
|
||||
|
||||
state number:zero
|
||||
state calc:pending
|
||||
}
|
||||
|
||||
event_oper(Btn:idx) <calc:pending>
|
||||
{
|
||||
performoperation /* do the pending operation */
|
||||
pending_op = idx /* save the operator for the next operation */
|
||||
state number:zero
|
||||
}
|
||||
|
||||
event_equal() <calc:idle>
|
||||
{
|
||||
/* ignore */
|
||||
}
|
||||
|
||||
event_equal() <calc:pending>
|
||||
{
|
||||
performoperation /* do the pending operation */
|
||||
state calc:idle /* reset the calculator */
|
||||
state number:zero
|
||||
}
|
||||
|
||||
|
||||
event_C()
|
||||
{
|
||||
state calc:idle
|
||||
state number:zero
|
||||
resetentry 0
|
||||
}
|
||||
|
||||
event_CE()
|
||||
{
|
||||
state number:zero
|
||||
resetentry 0
|
||||
}
|
||||
|
||||
|
||||
main()
|
||||
{
|
||||
if (!procexec("gtk-server stdin") && !procexec("gtk-server.exe stdin"))
|
||||
fatal "unable to launch gtk-server"
|
||||
|
||||
/* make a window */
|
||||
GTK("gtk_init NULL NULL")
|
||||
new win = GTK("gtk_window_new 0")
|
||||
GTK("gtk_window_set_title %d \"Pawn calculator\"", win)
|
||||
GTK("gtk_widget_set_usize %d 200 200", win)
|
||||
|
||||
/* add a table (align the other controls) */
|
||||
new table = GTK("gtk_table_new 50 50 1")
|
||||
GTK("gtk_container_add %d %d", win, table)
|
||||
|
||||
/* the number entry */
|
||||
entry = GTK("gtk_entry_new")
|
||||
GTK("gtk_table_attach_defaults %d %d 1 49 1 9", table, entry)
|
||||
|
||||
/* the key pad */
|
||||
new buttons[Btn]
|
||||
buttons[BtnDot] = GTK("gtk_button_new_with_label .")
|
||||
GTK("gtk_table_attach_defaults %d %d 21 29 41 49", table, buttons[BtnDot])
|
||||
buttons[Btn0] = GTK("gtk_button_new_with_label 0")
|
||||
GTK("gtk_table_attach_defaults %d %d 1 19 41 49", table, buttons[Btn0])
|
||||
buttons[Btn1] = GTK("gtk_button_new_with_label 1")
|
||||
GTK("gtk_table_attach_defaults %d %d 1 9 31 39", table, buttons[Btn1])
|
||||
buttons[Btn2] = GTK("gtk_button_new_with_label 2")
|
||||
GTK("gtk_table_attach_defaults %d %d 11 19 31 39", table, buttons[Btn2])
|
||||
buttons[Btn3] = GTK("gtk_button_new_with_label 3")
|
||||
GTK("gtk_table_attach_defaults %d %d 21 29 31 39", table, buttons[Btn3])
|
||||
buttons[Btn4] = GTK("gtk_button_new_with_label 4")
|
||||
GTK("gtk_table_attach_defaults %d %d 1 9 21 29", table, buttons[Btn4])
|
||||
buttons[Btn5] = GTK("gtk_button_new_with_label 5")
|
||||
GTK("gtk_table_attach_defaults %d %d 11 19 21 29", table, buttons[Btn5])
|
||||
buttons[Btn6] = GTK("gtk_button_new_with_label 6")
|
||||
GTK("gtk_table_attach_defaults %d %d 21 29 21 29", table, buttons[Btn6])
|
||||
buttons[Btn7] = GTK("gtk_button_new_with_label 7")
|
||||
GTK("gtk_table_attach_defaults %d %d 1 9 11 19", table, buttons[Btn7])
|
||||
buttons[Btn8] = GTK("gtk_button_new_with_label 8")
|
||||
GTK("gtk_table_attach_defaults %d %d 11 19 11 19", table, buttons[Btn8])
|
||||
buttons[Btn9] = GTK("gtk_button_new_with_label 9")
|
||||
GTK("gtk_table_attach_defaults %d %d 21 29 11 19", table, buttons[Btn9])
|
||||
|
||||
buttons[BtnC] = GTK("gtk_button_new_with_label C")
|
||||
GTK("gtk_table_attach_defaults %d %d 31 39 11 19", table, buttons[BtnC])
|
||||
buttons[BtnCE] = GTK("gtk_button_new_with_label CE")
|
||||
GTK("gtk_table_attach_defaults %d %d 41 49 11 19", table, buttons[BtnCE])
|
||||
buttons[BtnPlus] = GTK("gtk_button_new_with_label +")
|
||||
GTK("gtk_table_attach_defaults %d %d 31 39 21 29", table, buttons[BtnPlus])
|
||||
buttons[BtnMin] = GTK("gtk_button_new_with_label -")
|
||||
GTK("gtk_table_attach_defaults %d %d 41 49 21 29", table, buttons[BtnMin])
|
||||
buttons[BtnMul] = GTK("gtk_button_new_with_label x")
|
||||
GTK("gtk_table_attach_defaults %d %d 31 39 31 39", table, buttons[BtnMul])
|
||||
buttons[BtnDiv] = GTK("gtk_button_new_with_label /")
|
||||
GTK("gtk_table_attach_defaults %d %d 41 49 31 39", table, buttons[BtnDiv])
|
||||
buttons[BtnEqual] = GTK("gtk_button_new_with_label =")
|
||||
GTK("gtk_table_attach_defaults %d %d 31 49 41 49", table, buttons[BtnEqual])
|
||||
|
||||
/* initialize automata */
|
||||
state number:zero
|
||||
state calc:idle
|
||||
|
||||
/* wait for events, and dispatch them */
|
||||
GTK("gtk_widget_show_all %d", win)
|
||||
|
||||
resetentry 0
|
||||
new event
|
||||
new Btn:idx
|
||||
do
|
||||
{
|
||||
event = GTK("gtk_server_callback wait")
|
||||
|
||||
/* find the button matching the event, generate the event */
|
||||
for (idx = Btn0; idx < BtnNone && buttons[idx] != event; idx++)
|
||||
{}
|
||||
switch (idx)
|
||||
{
|
||||
case Btn0:
|
||||
event_0
|
||||
case Btn1 .. Btn9:
|
||||
event_1_9 idx
|
||||
case BtnDot:
|
||||
event_dot
|
||||
case BtnMin:
|
||||
event_minus
|
||||
case BtnPlus, BtnMul, BtnDiv:
|
||||
event_oper idx
|
||||
case BtnEqual:
|
||||
event_equal
|
||||
case BtnC:
|
||||
event_C
|
||||
case BtnCE:
|
||||
event_CE
|
||||
}
|
||||
}
|
||||
while (event != win);
|
||||
|
||||
/* direct call, because we must not wait for a reply on this command */
|
||||
procwrite "gtk_exit 0", true
|
||||
}
|
||||
|
||||
GTK(const format[], ...)
|
||||
{
|
||||
new command[256 char]
|
||||
switch (numargs())
|
||||
{
|
||||
case 1:
|
||||
strpack command, format
|
||||
case 2:
|
||||
strformat command, _, true, format, getarg(1)
|
||||
case 3:
|
||||
strformat command, _, true, format, getarg(1), getarg(2)
|
||||
case 4:
|
||||
strformat command, _, true, format, getarg(1), getarg(2), getarg(3)
|
||||
case 5:
|
||||
strformat command, _, true, format, getarg(1), getarg(2), getarg(3), getarg(4)
|
||||
}
|
||||
procwrite command, true
|
||||
|
||||
new reply[30]
|
||||
procread reply, .striplf=true
|
||||
if (strcmp(reply, "ok") == 0)
|
||||
return true
|
||||
return strval(reply)
|
||||
}
|
||||
|
||||
fatal(const message[])
|
||||
{
|
||||
printf "FATAL: %s\n", message
|
||||
exit
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
/* The Towers of Hanoi, a game solved through recursion */
|
||||
|
||||
main()
|
||||
{
|
||||
print "How many disks: "
|
||||
new disks = getvalue()
|
||||
move 1, 3, 2, disks
|
||||
}
|
||||
|
||||
move(from, to, spare, numdisks)
|
||||
{
|
||||
if (numdisks > 1)
|
||||
move from, spare, to, numdisks-1
|
||||
printf "Move disk from pillar %d to pillar %d\n", from, to
|
||||
if (numdisks > 1)
|
||||
move spare, to, from, numdisks-1
|
||||
}
|
||||
/* The Towers of Hanoi, a game solved through recursion */
|
||||
|
||||
main()
|
||||
{
|
||||
print "How many disks: "
|
||||
new disks = getvalue()
|
||||
move 1, 3, 2, disks
|
||||
}
|
||||
|
||||
move(from, to, spare, numdisks)
|
||||
{
|
||||
if (numdisks > 1)
|
||||
move from, spare, to, numdisks-1
|
||||
printf "Move disk from pillar %d to pillar %d\n", from, to
|
||||
if (numdisks > 1)
|
||||
move spare, to, from, numdisks-1
|
||||
}
|
||||
|
@ -1,2 +1,2 @@
|
||||
main()
|
||||
printf "Hello world\n"
|
||||
main()
|
||||
printf "Hello world\n"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <console>
|
||||
|
||||
main()
|
||||
{
|
||||
printf("Hello world\n");
|
||||
#include <console>
|
||||
|
||||
main()
|
||||
{
|
||||
printf("Hello world\n");
|
||||
}
|
@ -1,61 +1,61 @@
|
||||
/* calculate Julian Day number from a date, and vice versa */
|
||||
|
||||
main()
|
||||
{
|
||||
new d, m, y, jdn
|
||||
|
||||
print "Give a date (dd-mm-yyyy): "
|
||||
d = getvalue(_, '-', '/')
|
||||
m = getvalue(_, '-', '/')
|
||||
y = getvalue()
|
||||
|
||||
jdn = DateToJulian(d, m, y)
|
||||
printf("Date %d/%d/%d = %d JD\n", d, m, y, jdn)
|
||||
|
||||
print "Give a Julian Day Number: "
|
||||
jdn = getvalue()
|
||||
JulianToDate jdn, d, m, y
|
||||
printf "%d JD = %d/%d/%d\n", jdn, d, m, y
|
||||
}
|
||||
|
||||
DateToJulian(day, month, year)
|
||||
{
|
||||
/* The first year is 1. Year 0 does not exist: it is 1 BC (or -1) */
|
||||
assert year != 0
|
||||
if (year < 0)
|
||||
year++
|
||||
|
||||
/* move January and February to the end of the previous year */
|
||||
if (month <= 2)
|
||||
year--, month += 12
|
||||
new jdn = 365*year + year/4 - year/100 + year/400
|
||||
+ (153*month - 457) / 5
|
||||
+ day + 1721119
|
||||
return jdn
|
||||
}
|
||||
|
||||
JulianToDate(jdn, &day, &month, &year)
|
||||
{
|
||||
jdn -= 1721119
|
||||
|
||||
/* approximate year, then adjust in a loop */
|
||||
year = (400 * jdn) / 146097
|
||||
while (365*year + year/4 - year/100 + year/400 < jdn)
|
||||
year++
|
||||
year--
|
||||
|
||||
/* determine month */
|
||||
jdn -= 365*year + year/4 - year/100 + year/400
|
||||
month = (5*jdn + 457) / 153
|
||||
|
||||
/* determine day */
|
||||
day = jdn - (153*month - 457) / 5
|
||||
|
||||
/* move January and February to start of the year */
|
||||
if (month > 12)
|
||||
month -= 12, year++
|
||||
|
||||
/* adjust negative years (year 0 must become 1 BC, or -1) */
|
||||
if (year <= 0)
|
||||
year--
|
||||
}
|
||||
/* calculate Julian Day number from a date, and vice versa */
|
||||
|
||||
main()
|
||||
{
|
||||
new d, m, y, jdn
|
||||
|
||||
print "Give a date (dd-mm-yyyy): "
|
||||
d = getvalue(_, '-', '/')
|
||||
m = getvalue(_, '-', '/')
|
||||
y = getvalue()
|
||||
|
||||
jdn = DateToJulian(d, m, y)
|
||||
printf("Date %d/%d/%d = %d JD\n", d, m, y, jdn)
|
||||
|
||||
print "Give a Julian Day Number: "
|
||||
jdn = getvalue()
|
||||
JulianToDate jdn, d, m, y
|
||||
printf "%d JD = %d/%d/%d\n", jdn, d, m, y
|
||||
}
|
||||
|
||||
DateToJulian(day, month, year)
|
||||
{
|
||||
/* The first year is 1. Year 0 does not exist: it is 1 BC (or -1) */
|
||||
assert year != 0
|
||||
if (year < 0)
|
||||
year++
|
||||
|
||||
/* move January and February to the end of the previous year */
|
||||
if (month <= 2)
|
||||
year--, month += 12
|
||||
new jdn = 365*year + year/4 - year/100 + year/400
|
||||
+ (153*month - 457) / 5
|
||||
+ day + 1721119
|
||||
return jdn
|
||||
}
|
||||
|
||||
JulianToDate(jdn, &day, &month, &year)
|
||||
{
|
||||
jdn -= 1721119
|
||||
|
||||
/* approximate year, then adjust in a loop */
|
||||
year = (400 * jdn) / 146097
|
||||
while (365*year + year/4 - year/100 + year/400 < jdn)
|
||||
year++
|
||||
year--
|
||||
|
||||
/* determine month */
|
||||
jdn -= 365*year + year/4 - year/100 + year/400
|
||||
month = (5*jdn + 457) / 153
|
||||
|
||||
/* determine day */
|
||||
day = jdn - (153*month - 457) / 5
|
||||
|
||||
/* move January and February to start of the year */
|
||||
if (month > 12)
|
||||
month -= 12, year++
|
||||
|
||||
/* adjust negative years (year 0 must become 1 BC, or -1) */
|
||||
if (year <= 0)
|
||||
year--
|
||||
}
|
||||
|
124
examples/ones.p
124
examples/ones.p
@ -1,62 +1,62 @@
|
||||
forward ones: operator+(ones: a, ones: b)
|
||||
forward ones: operator-(ones: a, ones: b)
|
||||
forward ones: operator-(ones: a)
|
||||
|
||||
main()
|
||||
{
|
||||
new ones: chksum = ones: 0xffffffff
|
||||
print "Input values in hexadecimal, zero to exit\n"
|
||||
|
||||
new ones: value
|
||||
do
|
||||
{
|
||||
print ">> "
|
||||
value = ones: getvalue(.base=16)
|
||||
chksum = chksum + value
|
||||
printf "Checksum = %x\n", chksum
|
||||
}
|
||||
while (value)
|
||||
}
|
||||
|
||||
stock ones: operator+(ones: a, ones: b)
|
||||
{
|
||||
const ones: mask = ones: 0xffff /* word mask */
|
||||
const ones: shift = ones: 16 /* word shift */
|
||||
|
||||
/* add low words and high words separately */
|
||||
new ones: r1 = (a & mask) + (b & mask)
|
||||
new ones: r2 = (a >>> shift) + (b >>> shift)
|
||||
|
||||
new ones: carry
|
||||
restart: /* code label (goto target) */
|
||||
|
||||
/* add carry of the new low word to the high word, then
|
||||
* strip it from the low word
|
||||
*/
|
||||
carry = (r1 >>> shift)
|
||||
r2 += carry
|
||||
r1 &= mask
|
||||
|
||||
/* add the carry from the new high word back to the low
|
||||
* word, then strip it from the high word
|
||||
*/
|
||||
carry = (r2 >>> shift)
|
||||
r1 += carry
|
||||
r2 &= mask
|
||||
|
||||
/* a carry from the high word injected back into the low
|
||||
* word may cause the new low to overflow, so restart in
|
||||
* that case
|
||||
*/
|
||||
if (carry)
|
||||
goto restart
|
||||
|
||||
return (r2 << shift) | r1
|
||||
}
|
||||
|
||||
stock ones: operator-(ones: a)
|
||||
return (a == ones: 0xffffffff) ? a : ~a
|
||||
|
||||
stock ones: operator-(ones: a, ones: b)
|
||||
return a + -b
|
||||
|
||||
forward ones: operator+(ones: a, ones: b)
|
||||
forward ones: operator-(ones: a, ones: b)
|
||||
forward ones: operator-(ones: a)
|
||||
|
||||
main()
|
||||
{
|
||||
new ones: chksum = ones: 0xffffffff
|
||||
print "Input values in hexadecimal, zero to exit\n"
|
||||
|
||||
new ones: value
|
||||
do
|
||||
{
|
||||
print ">> "
|
||||
value = ones: getvalue(.base=16)
|
||||
chksum = chksum + value
|
||||
printf "Checksum = %x\n", chksum
|
||||
}
|
||||
while (value)
|
||||
}
|
||||
|
||||
stock ones: operator+(ones: a, ones: b)
|
||||
{
|
||||
const ones: mask = ones: 0xffff /* word mask */
|
||||
const ones: shift = ones: 16 /* word shift */
|
||||
|
||||
/* add low words and high words separately */
|
||||
new ones: r1 = (a & mask) + (b & mask)
|
||||
new ones: r2 = (a >>> shift) + (b >>> shift)
|
||||
|
||||
new ones: carry
|
||||
restart: /* code label (goto target) */
|
||||
|
||||
/* add carry of the new low word to the high word, then
|
||||
* strip it from the low word
|
||||
*/
|
||||
carry = (r1 >>> shift)
|
||||
r2 += carry
|
||||
r1 &= mask
|
||||
|
||||
/* add the carry from the new high word back to the low
|
||||
* word, then strip it from the high word
|
||||
*/
|
||||
carry = (r2 >>> shift)
|
||||
r1 += carry
|
||||
r2 &= mask
|
||||
|
||||
/* a carry from the high word injected back into the low
|
||||
* word may cause the new low to overflow, so restart in
|
||||
* that case
|
||||
*/
|
||||
if (carry)
|
||||
goto restart
|
||||
|
||||
return (r2 << shift) | r1
|
||||
}
|
||||
|
||||
stock ones: operator-(ones: a)
|
||||
return (a == ones: 0xffffffff) ? a : ~a
|
||||
|
||||
stock ones: operator-(ones: a, ones: b)
|
||||
return a + -b
|
||||
|
||||
|
156
examples/queue.p
156
examples/queue.p
@ -1,78 +1,78 @@
|
||||
/* Priority queue (for simple text strings) */
|
||||
|
||||
enum message
|
||||
{
|
||||
text[40 char],
|
||||
priority
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
new msg[message]
|
||||
|
||||
/* insert a few items (read from console input) */
|
||||
printf "Please insert a few messages and their priorities; \
|
||||
end with an empty string\n"
|
||||
for ( ;; )
|
||||
{
|
||||
printf "Message: "
|
||||
getstring .string = msg[text], .maxlength = 40, .pack = true
|
||||
if (strlen(msg[text]) == 0)
|
||||
break
|
||||
printf "Priority: "
|
||||
msg[priority] = getvalue()
|
||||
if (!insert(msg))
|
||||
{
|
||||
printf "Queue is full, cannot insert more items\n"
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
/* now print the messages extracted from the queue */
|
||||
printf "\nContents of the queue:\n"
|
||||
while (extract(msg))
|
||||
printf "[%d] %s\n", msg[priority], msg[text]
|
||||
}
|
||||
|
||||
const queuesize = 10
|
||||
new queue[queuesize][message]
|
||||
new queueitems = 0
|
||||
|
||||
insert(const item[message])
|
||||
{
|
||||
/* check if the queue can hold one more message */
|
||||
if (queueitems == queuesize)
|
||||
return false /* queue is full */
|
||||
|
||||
/* find the position to insert it to */
|
||||
new pos = queueitems /* start at the bottom */
|
||||
while (pos > 0 && item[priority] > queue[pos-1][priority])
|
||||
--pos /* higher priority: move up a slot */
|
||||
|
||||
/* make place for the item at the insertion spot */
|
||||
for (new i = queueitems; i > pos; --i)
|
||||
queue[i] = queue[i-1]
|
||||
|
||||
/* add the message to the correct slot */
|
||||
queue[pos] = item
|
||||
queueitems++
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
extract(item[message])
|
||||
{
|
||||
/* check whether the queue has one more message */
|
||||
if (queueitems == 0)
|
||||
return false /* queue is empty */
|
||||
|
||||
/* copy the topmost item */
|
||||
item = queue[0]
|
||||
--queueitems
|
||||
|
||||
/* move the queue one position up */
|
||||
for (new i = 0; i < queueitems; ++i)
|
||||
queue[i] = queue[i+1]
|
||||
|
||||
return true
|
||||
}
|
||||
/* Priority queue (for simple text strings) */
|
||||
|
||||
enum message
|
||||
{
|
||||
text[40 char],
|
||||
priority
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
new msg[message]
|
||||
|
||||
/* insert a few items (read from console input) */
|
||||
printf "Please insert a few messages and their priorities; \
|
||||
end with an empty string\n"
|
||||
for ( ;; )
|
||||
{
|
||||
printf "Message: "
|
||||
getstring .string = msg[text], .maxlength = 40, .pack = true
|
||||
if (strlen(msg[text]) == 0)
|
||||
break
|
||||
printf "Priority: "
|
||||
msg[priority] = getvalue()
|
||||
if (!insert(msg))
|
||||
{
|
||||
printf "Queue is full, cannot insert more items\n"
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
/* now print the messages extracted from the queue */
|
||||
printf "\nContents of the queue:\n"
|
||||
while (extract(msg))
|
||||
printf "[%d] %s\n", msg[priority], msg[text]
|
||||
}
|
||||
|
||||
const queuesize = 10
|
||||
new queue[queuesize][message]
|
||||
new queueitems = 0
|
||||
|
||||
insert(const item[message])
|
||||
{
|
||||
/* check if the queue can hold one more message */
|
||||
if (queueitems == queuesize)
|
||||
return false /* queue is full */
|
||||
|
||||
/* find the position to insert it to */
|
||||
new pos = queueitems /* start at the bottom */
|
||||
while (pos > 0 && item[priority] > queue[pos-1][priority])
|
||||
--pos /* higher priority: move up a slot */
|
||||
|
||||
/* make place for the item at the insertion spot */
|
||||
for (new i = queueitems; i > pos; --i)
|
||||
queue[i] = queue[i-1]
|
||||
|
||||
/* add the message to the correct slot */
|
||||
queue[pos] = item
|
||||
queueitems++
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
extract(item[message])
|
||||
{
|
||||
/* check whether the queue has one more message */
|
||||
if (queueitems == 0)
|
||||
return false /* queue is empty */
|
||||
|
||||
/* copy the topmost item */
|
||||
item = queue[0]
|
||||
--queueitems
|
||||
|
||||
/* move the queue one position up */
|
||||
for (new i = 0; i < queueitems; ++i)
|
||||
queue[i] = queue[i+1]
|
||||
|
||||
return true
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
new s[]="new s[]=%c%s%c; main() printf s,34,s,34"; main() printf s,34,s,34
|
||||
new s[]="new s[]=%c%s%c; main() printf s,34,s,34"; main() printf s,34,s,34
|
||||
|
@ -1,39 +1,39 @@
|
||||
main()
|
||||
{
|
||||
new HandOfCards[10]
|
||||
FillRandom(HandOfCards, 52)
|
||||
|
||||
print "A draw of 10 numbers from a range of 0 to 51 \
|
||||
(inclusive) without duplicates:\n"
|
||||
for (new i = 0; i < sizeof HandOfCards; i++)
|
||||
printf "%d ", HandOfCards[i]
|
||||
}
|
||||
|
||||
FillRandom(Series[], Range, Number = sizeof Series)
|
||||
{
|
||||
assert Range >= Number /* cannot select 50 values
|
||||
* without duplicates in the
|
||||
* range 0..40, for example */
|
||||
new Index = 0
|
||||
for (new Seq = Range - Number; Seq < Range; Seq++)
|
||||
{
|
||||
new Val = random(Seq + 1)
|
||||
new Pos = InSeries(Series, Val, Index)
|
||||
if (Pos >= 0)
|
||||
{
|
||||
Series[Index] = Series[Pos]
|
||||
Series[Pos] = Seq
|
||||
}
|
||||
else
|
||||
Series[Index] = Val
|
||||
Index++
|
||||
}
|
||||
}
|
||||
|
||||
InSeries(Series[], Value, Top = sizeof Series)
|
||||
{
|
||||
for (new i = 0; i < Top; i++)
|
||||
if (Series[i] == Value)
|
||||
return i
|
||||
return -1
|
||||
}
|
||||
main()
|
||||
{
|
||||
new HandOfCards[10]
|
||||
FillRandom(HandOfCards, 52)
|
||||
|
||||
print "A draw of 10 numbers from a range of 0 to 51 \
|
||||
(inclusive) without duplicates:\n"
|
||||
for (new i = 0; i < sizeof HandOfCards; i++)
|
||||
printf "%d ", HandOfCards[i]
|
||||
}
|
||||
|
||||
FillRandom(Series[], Range, Number = sizeof Series)
|
||||
{
|
||||
assert Range >= Number /* cannot select 50 values
|
||||
* without duplicates in the
|
||||
* range 0..40, for example */
|
||||
new Index = 0
|
||||
for (new Seq = Range - Number; Seq < Range; Seq++)
|
||||
{
|
||||
new Val = random(Seq + 1)
|
||||
new Pos = InSeries(Series, Val, Index)
|
||||
if (Pos >= 0)
|
||||
{
|
||||
Series[Index] = Series[Pos]
|
||||
Series[Pos] = Seq
|
||||
}
|
||||
else
|
||||
Series[Index] = Val
|
||||
Index++
|
||||
}
|
||||
}
|
||||
|
||||
InSeries(Series[], Value, Top = sizeof Series)
|
||||
{
|
||||
for (new i = 0; i < Top; i++)
|
||||
if (Series[i] == Value)
|
||||
return i
|
||||
return -1
|
||||
}
|
||||
|
@ -1,25 +1,25 @@
|
||||
#include <file>
|
||||
|
||||
main()
|
||||
{
|
||||
/* ask for a filename */
|
||||
print "Please enter a filename: "
|
||||
new filename[128 char]
|
||||
getstring filename, .pack=true
|
||||
|
||||
/* try to open the file */
|
||||
new File: file = fopen(filename, io_read)
|
||||
if (!file)
|
||||
{
|
||||
printf "The file '%s' cannot be opened for reading\n", filename
|
||||
exit
|
||||
}
|
||||
|
||||
/* dump the file onto the console */
|
||||
new line[200]
|
||||
while (fread(file, line))
|
||||
print line, .highlight=true
|
||||
|
||||
/* done */
|
||||
fclose file
|
||||
}
|
||||
#include <file>
|
||||
|
||||
main()
|
||||
{
|
||||
/* ask for a filename */
|
||||
print "Please enter a filename: "
|
||||
new filename[128 char]
|
||||
getstring filename, .pack=true
|
||||
|
||||
/* try to open the file */
|
||||
new File: file = fopen(filename, io_read)
|
||||
if (!file)
|
||||
{
|
||||
printf "The file '%s' cannot be opened for reading\n", filename
|
||||
exit
|
||||
}
|
||||
|
||||
/* dump the file onto the console */
|
||||
new line[200]
|
||||
while (fread(file, line))
|
||||
print line, .highlight=true
|
||||
|
||||
/* done */
|
||||
fclose file
|
||||
}
|
||||
|
@ -1,21 +1,21 @@
|
||||
/* Simple encryption, using ROT13 */
|
||||
|
||||
main()
|
||||
{
|
||||
printf "Please type the string to mangle: "
|
||||
|
||||
new str[100]
|
||||
getstring str, sizeof str
|
||||
rot13 str
|
||||
|
||||
printf "After mangling, the string is: \"%s\"\n", str
|
||||
}
|
||||
|
||||
rot13(string[])
|
||||
{
|
||||
for (new index = 0; string[index]; index++)
|
||||
if ('a' <= string[index] <= 'z')
|
||||
string[index] = (string[index] - 'a' + 13) % 26 + 'a'
|
||||
else if ('A' <= string[index] <= 'Z')
|
||||
string[index] = (string[index] - 'A' + 13) % 26 + 'A'
|
||||
}
|
||||
/* Simple encryption, using ROT13 */
|
||||
|
||||
main()
|
||||
{
|
||||
printf "Please type the string to mangle: "
|
||||
|
||||
new str[100]
|
||||
getstring str, sizeof str
|
||||
rot13 str
|
||||
|
||||
printf "After mangling, the string is: \"%s\"\n", str
|
||||
}
|
||||
|
||||
rot13(string[])
|
||||
{
|
||||
for (new index = 0; string[index]; index++)
|
||||
if ('a' <= string[index] <= 'z')
|
||||
string[index] = (string[index] - 'a' + 13) % 26 + 'a'
|
||||
else if ('A' <= string[index] <= 'Z')
|
||||
string[index] = (string[index] - 'A' + 13) % 26 + 'A'
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* a simple RPN calculator */
|
||||
#include strtok
|
||||
#include stack
|
||||
#include rpnparse
|
||||
|
||||
main()
|
||||
{
|
||||
print "Type an expression in Reverse Polish Notation: "
|
||||
new string[100]
|
||||
getstring string, sizeof string
|
||||
rpncalc string
|
||||
}
|
||||
/* a simple RPN calculator */
|
||||
#include strtok
|
||||
#include stack
|
||||
#include rpnparse
|
||||
|
||||
main()
|
||||
{
|
||||
print "Type an expression in Reverse Polish Notation: "
|
||||
new string[100]
|
||||
getstring string, sizeof string
|
||||
rpncalc string
|
||||
}
|
||||
|
@ -1,71 +1,71 @@
|
||||
/* main rpn parser and lexical analysis, part of the RPN calculator */
|
||||
#include <rational>
|
||||
#include <string>
|
||||
|
||||
enum token
|
||||
{
|
||||
t_type, /* operator or token type */
|
||||
Rational: t_value, /* value, if t_type is "Number" */
|
||||
t_word[20], /* raw string */
|
||||
}
|
||||
|
||||
const Number = '0'
|
||||
const EndOfExpr = '#'
|
||||
|
||||
rpncalc(const string[])
|
||||
{
|
||||
new index
|
||||
new field[token]
|
||||
for ( ;; )
|
||||
{
|
||||
field = gettoken(string, index)
|
||||
switch (field[t_type])
|
||||
{
|
||||
case Number:
|
||||
push field[t_value]
|
||||
case '+':
|
||||
push pop() + pop()
|
||||
case '-':
|
||||
push - pop() + pop()
|
||||
case '*':
|
||||
push pop() * pop()
|
||||
case '/', ':':
|
||||
push 1.0 / pop() * pop()
|
||||
case EndOfExpr:
|
||||
break /* exit "for" loop */
|
||||
default:
|
||||
printf "Unknown operator '%s'\n", field[t_word]
|
||||
}
|
||||
}
|
||||
printf "Result = %r\n", pop()
|
||||
if (clearstack())
|
||||
print "Stack not empty\n", red
|
||||
}
|
||||
|
||||
gettoken(const string[], &index)
|
||||
{
|
||||
/* first get the next "word" from the string */
|
||||
new word[20]
|
||||
word = strtok(string, index)
|
||||
|
||||
/* then parse it */
|
||||
new field[token]
|
||||
field[t_word] = word
|
||||
if (strlen(word) == 0)
|
||||
{
|
||||
field[t_type] = EndOfExpr /* special "stop" symbol */
|
||||
field[t_value] = 0
|
||||
}
|
||||
else if ('0' <= word[0] <= '9')
|
||||
{
|
||||
field[t_type] = Number
|
||||
field[t_value] = rationalstr(word)
|
||||
}
|
||||
else
|
||||
{
|
||||
field[t_type] = word[0]
|
||||
field[t_value] = 0
|
||||
}
|
||||
|
||||
return field
|
||||
}
|
||||
/* main rpn parser and lexical analysis, part of the RPN calculator */
|
||||
#include <rational>
|
||||
#include <string>
|
||||
|
||||
enum token
|
||||
{
|
||||
t_type, /* operator or token type */
|
||||
Rational: t_value, /* value, if t_type is "Number" */
|
||||
t_word[20], /* raw string */
|
||||
}
|
||||
|
||||
const Number = '0'
|
||||
const EndOfExpr = '#'
|
||||
|
||||
rpncalc(const string[])
|
||||
{
|
||||
new index
|
||||
new field[token]
|
||||
for ( ;; )
|
||||
{
|
||||
field = gettoken(string, index)
|
||||
switch (field[t_type])
|
||||
{
|
||||
case Number:
|
||||
push field[t_value]
|
||||
case '+':
|
||||
push pop() + pop()
|
||||
case '-':
|
||||
push - pop() + pop()
|
||||
case '*':
|
||||
push pop() * pop()
|
||||
case '/', ':':
|
||||
push 1.0 / pop() * pop()
|
||||
case EndOfExpr:
|
||||
break /* exit "for" loop */
|
||||
default:
|
||||
printf "Unknown operator '%s'\n", field[t_word]
|
||||
}
|
||||
}
|
||||
printf "Result = %r\n", pop()
|
||||
if (clearstack())
|
||||
print "Stack not empty\n", red
|
||||
}
|
||||
|
||||
gettoken(const string[], &index)
|
||||
{
|
||||
/* first get the next "word" from the string */
|
||||
new word[20]
|
||||
word = strtok(string, index)
|
||||
|
||||
/* then parse it */
|
||||
new field[token]
|
||||
field[t_word] = word
|
||||
if (strlen(word) == 0)
|
||||
{
|
||||
field[t_type] = EndOfExpr /* special "stop" symbol */
|
||||
field[t_value] = 0
|
||||
}
|
||||
else if ('0' <= word[0] <= '9')
|
||||
{
|
||||
field[t_type] = Number
|
||||
field[t_value] = rationalstr(word)
|
||||
}
|
||||
else
|
||||
{
|
||||
field[t_type] = word[0]
|
||||
field[t_value] = 0
|
||||
}
|
||||
|
||||
return field
|
||||
}
|
||||
|
@ -1,46 +1,46 @@
|
||||
/* Set operations, using bit arithmetic */
|
||||
|
||||
main()
|
||||
{
|
||||
enum (<<= 1) { A = 1, B, C, D, E, F, G }
|
||||
new nextstep[] =
|
||||
{ C | E, /* A can reach C and E */
|
||||
D | E, /* B " " D and E */
|
||||
G, /* C " " G */
|
||||
C | F, /* D " " C and F */
|
||||
0, /* E " " none */
|
||||
0, /* F " " none */
|
||||
E | F, /* G " " E and F */
|
||||
}
|
||||
#pragma unused A, B
|
||||
|
||||
print "The departure point: "
|
||||
new start = clamp( .value = toupper(getchar()) - 'A',
|
||||
.min = 0,
|
||||
.max = sizeof nextstep - 1
|
||||
)
|
||||
|
||||
print "\nThe number of steps: "
|
||||
new steps = getvalue()
|
||||
|
||||
/* make the set */
|
||||
new result = findtargets(start, steps, nextstep)
|
||||
printf "The points in range of %c in %d steps: ", start + 'A', steps
|
||||
for (new i = 0; i < sizeof nextstep; i++)
|
||||
if (result & 1 << i)
|
||||
printf "%c ", i + 'A'
|
||||
}
|
||||
|
||||
findtargets(start, steps, nextstep[], numpoints = sizeof nextstep)
|
||||
{
|
||||
new result = 0
|
||||
new addedpoints = nextstep[start]
|
||||
while (steps-- > 0 && result != addedpoints)
|
||||
{
|
||||
result = addedpoints
|
||||
for (new i = 0; i < numpoints; i++)
|
||||
if (result & 1 << i)
|
||||
addedpoints |= nextstep[i]
|
||||
}
|
||||
return result
|
||||
}
|
||||
/* Set operations, using bit arithmetic */
|
||||
|
||||
main()
|
||||
{
|
||||
enum (<<= 1) { A = 1, B, C, D, E, F, G }
|
||||
new nextstep[] =
|
||||
{ C | E, /* A can reach C and E */
|
||||
D | E, /* B " " D and E */
|
||||
G, /* C " " G */
|
||||
C | F, /* D " " C and F */
|
||||
0, /* E " " none */
|
||||
0, /* F " " none */
|
||||
E | F, /* G " " E and F */
|
||||
}
|
||||
#pragma unused A, B
|
||||
|
||||
print "The departure point: "
|
||||
new start = clamp( .value = toupper(getchar()) - 'A',
|
||||
.min = 0,
|
||||
.max = sizeof nextstep - 1
|
||||
)
|
||||
|
||||
print "\nThe number of steps: "
|
||||
new steps = getvalue()
|
||||
|
||||
/* make the set */
|
||||
new result = findtargets(start, steps, nextstep)
|
||||
printf "The points in range of %c in %d steps: ", start + 'A', steps
|
||||
for (new i = 0; i < sizeof nextstep; i++)
|
||||
if (result & 1 << i)
|
||||
printf "%c ", i + 'A'
|
||||
}
|
||||
|
||||
findtargets(start, steps, nextstep[], numpoints = sizeof nextstep)
|
||||
{
|
||||
new result = 0
|
||||
new addedpoints = nextstep[start]
|
||||
while (steps-- > 0 && result != addedpoints)
|
||||
{
|
||||
result = addedpoints
|
||||
for (new i = 0; i < numpoints; i++)
|
||||
if (result & 1 << i)
|
||||
addedpoints |= nextstep[i]
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
/* Print all primes below 100, using the "Sieve of Eratosthenes" */
|
||||
|
||||
main()
|
||||
{
|
||||
const max_primes = 100
|
||||
new series[max_primes] = { true, ... }
|
||||
|
||||
for (new i = 2; i < max_primes; ++i)
|
||||
if (series[i])
|
||||
{
|
||||
printf "%d ", i
|
||||
/* filter all multiples of this "prime" from the list */
|
||||
for (new j = 2 * i; j < max_primes; j += i)
|
||||
series[j] = false
|
||||
}
|
||||
}
|
||||
/* Print all primes below 100, using the "Sieve of Eratosthenes" */
|
||||
|
||||
main()
|
||||
{
|
||||
const max_primes = 100
|
||||
new series[max_primes] = { true, ... }
|
||||
|
||||
for (new i = 2; i < max_primes; ++i)
|
||||
if (series[i])
|
||||
{
|
||||
printf "%d ", i
|
||||
/* filter all multiples of this "prime" from the list */
|
||||
for (new j = 2 * i; j < max_primes; j += i)
|
||||
series[j] = false
|
||||
}
|
||||
}
|
||||
|
@ -1,26 +1,26 @@
|
||||
/* stack functions, part of the RPN calculator */
|
||||
#include <rational>
|
||||
|
||||
static Rational: stack[50]
|
||||
static stackidx = 0
|
||||
|
||||
push(Rational: value)
|
||||
{
|
||||
assert stackidx < sizeof stack
|
||||
stack[stackidx++] = value
|
||||
}
|
||||
|
||||
Rational: pop()
|
||||
{
|
||||
assert stackidx > 0
|
||||
return stack[--stackidx]
|
||||
}
|
||||
|
||||
clearstack()
|
||||
{
|
||||
assert stackidx >= 0
|
||||
if (stackidx == 0)
|
||||
return false
|
||||
stackidx = 0
|
||||
return true
|
||||
}
|
||||
/* stack functions, part of the RPN calculator */
|
||||
#include <rational>
|
||||
|
||||
static Rational: stack[50]
|
||||
static stackidx = 0
|
||||
|
||||
push(Rational: value)
|
||||
{
|
||||
assert stackidx < sizeof stack
|
||||
stack[stackidx++] = value
|
||||
}
|
||||
|
||||
Rational: pop()
|
||||
{
|
||||
assert stackidx > 0
|
||||
return stack[--stackidx]
|
||||
}
|
||||
|
||||
clearstack()
|
||||
{
|
||||
assert stackidx >= 0
|
||||
if (stackidx == 0)
|
||||
return false
|
||||
stackidx = 0
|
||||
return true
|
||||
}
|
||||
|
@ -1,25 +1,25 @@
|
||||
/* extract words from a string (words are separated by white space) */
|
||||
#include <string>
|
||||
|
||||
strtok(const string[], &index)
|
||||
{
|
||||
new length = strlen(string)
|
||||
|
||||
/* skip leading white space */
|
||||
while (index < length && string[index] <= ' ')
|
||||
index++
|
||||
|
||||
/* store the word letter for letter */
|
||||
new offset = index /* save start position of token */
|
||||
new result[20] /* string to store the word in */
|
||||
while (index < length
|
||||
&& string[index] > ' '
|
||||
&& index - offset < sizeof result - 1)
|
||||
{
|
||||
result[index - offset] = string[index]
|
||||
index++
|
||||
}
|
||||
result[index - offset] = EOS /* zero-terminate the string */
|
||||
|
||||
return result
|
||||
}
|
||||
/* extract words from a string (words are separated by white space) */
|
||||
#include <string>
|
||||
|
||||
strtok(const string[], &index)
|
||||
{
|
||||
new length = strlen(string)
|
||||
|
||||
/* skip leading white space */
|
||||
while (index < length && string[index] <= ' ')
|
||||
index++
|
||||
|
||||
/* store the word letter for letter */
|
||||
new offset = index /* save start position of token */
|
||||
new result[20] /* string to store the word in */
|
||||
while (index < length
|
||||
&& string[index] > ' '
|
||||
&& index - offset < sizeof result - 1)
|
||||
{
|
||||
result[index - offset] = string[index]
|
||||
index++
|
||||
}
|
||||
result[index - offset] = EOS /* zero-terminate the string */
|
||||
|
||||
return result
|
||||
}
|
||||
|
@ -1,35 +1,35 @@
|
||||
/* traffic light synchronizer, using states in an event-driven model */
|
||||
#include <time>
|
||||
|
||||
main() state green_wait
|
||||
|
||||
@keypressed(key) <green_wait> state yellow_wait
|
||||
@keypressed(key) <red_walk, red_wait> state red_walk
|
||||
@keypressed(key) <> {} /* fallback */
|
||||
|
||||
@timer() <yellow_wait> state red_walk
|
||||
@timer() <red_walk> state red_wait
|
||||
@timer() <red_wait> state green_wait
|
||||
@timer() <> {} /* fallback */
|
||||
|
||||
|
||||
entry() <green_wait>
|
||||
print "Green / Don't walk\n"
|
||||
|
||||
entry() <yellow_wait>
|
||||
{
|
||||
print "Yellow / Don't walk\n"
|
||||
settimer 2000
|
||||
}
|
||||
|
||||
entry() <red_walk>
|
||||
{
|
||||
print "Red / Walk\n"
|
||||
settimer 5000
|
||||
}
|
||||
|
||||
entry() <red_wait>
|
||||
{
|
||||
print "Red / Don't walk\n"
|
||||
settimer 2000
|
||||
}
|
||||
/* traffic light synchronizer, using states in an event-driven model */
|
||||
#include <time>
|
||||
|
||||
main() state green_wait
|
||||
|
||||
@keypressed(key) <green_wait> state yellow_wait
|
||||
@keypressed(key) <red_walk, red_wait> state red_walk
|
||||
@keypressed(key) <> {} /* fallback */
|
||||
|
||||
@timer() <yellow_wait> state red_walk
|
||||
@timer() <red_walk> state red_wait
|
||||
@timer() <red_wait> state green_wait
|
||||
@timer() <> {} /* fallback */
|
||||
|
||||
|
||||
entry() <green_wait>
|
||||
print "Green / Don't walk\n"
|
||||
|
||||
entry() <yellow_wait>
|
||||
{
|
||||
print "Yellow / Don't walk\n"
|
||||
settimer 2000
|
||||
}
|
||||
|
||||
entry() <red_walk>
|
||||
{
|
||||
print "Red / Walk\n"
|
||||
settimer 5000
|
||||
}
|
||||
|
||||
entry() <red_wait>
|
||||
{
|
||||
print "Red / Don't walk\n"
|
||||
settimer 2000
|
||||
}
|
||||
|
@ -1,83 +1,83 @@
|
||||
/* a more realistic traffic light synchronizer, including an
|
||||
* "override" for emergency vehicles
|
||||
*/
|
||||
#include <time>
|
||||
|
||||
main()
|
||||
state green_wait_interim
|
||||
|
||||
new bool: button_memo <red_wait, green_wait_interim, yellow_wait>
|
||||
|
||||
@keypressed(key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case ' ': button_press
|
||||
case '*': mirt_detect
|
||||
}
|
||||
}
|
||||
|
||||
button_press() <green_wait>
|
||||
state yellow_wait
|
||||
|
||||
button_press() <red_wait, green_wait_interim>
|
||||
button_memo = true
|
||||
|
||||
button_press() <> /* fallback */
|
||||
{}
|
||||
|
||||
mirt_detect()
|
||||
state mirt_override
|
||||
|
||||
@timer() <yellow_wait>
|
||||
state red_walk
|
||||
|
||||
@timer() <red_walk>
|
||||
state red_wait
|
||||
|
||||
@timer() <red_wait>
|
||||
state green_wait_interim
|
||||
|
||||
@timer() <green_wait_interim>
|
||||
{
|
||||
state (!button_memo) green_wait
|
||||
state (button_memo) yellow_wait
|
||||
}
|
||||
|
||||
@timer() <mirt_override>
|
||||
state green_wait
|
||||
|
||||
@timer() <> /* fallback */
|
||||
{}
|
||||
|
||||
|
||||
entry() <green_wait_interim>
|
||||
{
|
||||
print "Green / Don't walk\n"
|
||||
settimer 5000
|
||||
}
|
||||
|
||||
entry() <yellow_wait>
|
||||
{
|
||||
print "Yellow / Don't walk\n"
|
||||
button_memo = false
|
||||
settimer 2000
|
||||
}
|
||||
|
||||
entry() <red_walk>
|
||||
{
|
||||
print "Red / Walk\n"
|
||||
settimer 5000
|
||||
}
|
||||
|
||||
entry() <red_wait>
|
||||
{
|
||||
print "Red / Don't walk\n"
|
||||
settimer 2000
|
||||
}
|
||||
|
||||
entry() <mirt_override>
|
||||
{
|
||||
print "Green / Don't walk\n"
|
||||
settimer 5000
|
||||
}
|
||||
/* a more realistic traffic light synchronizer, including an
|
||||
* "override" for emergency vehicles
|
||||
*/
|
||||
#include <time>
|
||||
|
||||
main()
|
||||
state green_wait_interim
|
||||
|
||||
new bool: button_memo <red_wait, green_wait_interim, yellow_wait>
|
||||
|
||||
@keypressed(key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case ' ': button_press
|
||||
case '*': mirt_detect
|
||||
}
|
||||
}
|
||||
|
||||
button_press() <green_wait>
|
||||
state yellow_wait
|
||||
|
||||
button_press() <red_wait, green_wait_interim>
|
||||
button_memo = true
|
||||
|
||||
button_press() <> /* fallback */
|
||||
{}
|
||||
|
||||
mirt_detect()
|
||||
state mirt_override
|
||||
|
||||
@timer() <yellow_wait>
|
||||
state red_walk
|
||||
|
||||
@timer() <red_walk>
|
||||
state red_wait
|
||||
|
||||
@timer() <red_wait>
|
||||
state green_wait_interim
|
||||
|
||||
@timer() <green_wait_interim>
|
||||
{
|
||||
state (!button_memo) green_wait
|
||||
state (button_memo) yellow_wait
|
||||
}
|
||||
|
||||
@timer() <mirt_override>
|
||||
state green_wait
|
||||
|
||||
@timer() <> /* fallback */
|
||||
{}
|
||||
|
||||
|
||||
entry() <green_wait_interim>
|
||||
{
|
||||
print "Green / Don't walk\n"
|
||||
settimer 5000
|
||||
}
|
||||
|
||||
entry() <yellow_wait>
|
||||
{
|
||||
print "Yellow / Don't walk\n"
|
||||
button_memo = false
|
||||
settimer 2000
|
||||
}
|
||||
|
||||
entry() <red_walk>
|
||||
{
|
||||
print "Red / Walk\n"
|
||||
settimer 5000
|
||||
}
|
||||
|
||||
entry() <red_wait>
|
||||
{
|
||||
print "Red / Don't walk\n"
|
||||
settimer 2000
|
||||
}
|
||||
|
||||
entry() <mirt_override>
|
||||
{
|
||||
print "Green / Don't walk\n"
|
||||
settimer 5000
|
||||
}
|
||||
|
@ -1,26 +1,26 @@
|
||||
@keypressed(key)
|
||||
{
|
||||
/* get current position */
|
||||
new x, y
|
||||
wherexy x, y
|
||||
|
||||
/* determine how the update the current position */
|
||||
switch (key)
|
||||
{
|
||||
case 'u': y-- /* up */
|
||||
case 'd': y++ /* down */
|
||||
case 'l': x-- /* left */
|
||||
case 'r': x++ /* right */
|
||||
case '\e': exit /* Escape = exit */
|
||||
}
|
||||
|
||||
/* adjust the cursor position and draw something */
|
||||
moveturtle x, y
|
||||
}
|
||||
|
||||
moveturtle(x, y)
|
||||
{
|
||||
gotoxy x, y
|
||||
print '*'
|
||||
gotoxy x, y
|
||||
}
|
||||
@keypressed(key)
|
||||
{
|
||||
/* get current position */
|
||||
new x, y
|
||||
wherexy x, y
|
||||
|
||||
/* determine how the update the current position */
|
||||
switch (key)
|
||||
{
|
||||
case 'u': y-- /* up */
|
||||
case 'd': y++ /* down */
|
||||
case 'l': x-- /* left */
|
||||
case 'r': x++ /* right */
|
||||
case '\e': exit /* Escape = exit */
|
||||
}
|
||||
|
||||
/* adjust the cursor position and draw something */
|
||||
moveturtle x, y
|
||||
}
|
||||
|
||||
moveturtle(x, y)
|
||||
{
|
||||
gotoxy x, y
|
||||
print '*'
|
||||
gotoxy x, y
|
||||
}
|
||||
|
@ -1,46 +1,46 @@
|
||||
/* word count: count words on a string that the user types */
|
||||
|
||||
main()
|
||||
{
|
||||
print "Please type a string: "
|
||||
new string[100]
|
||||
getstring string, sizeof string
|
||||
|
||||
new count = 0
|
||||
|
||||
new word[20]
|
||||
new index
|
||||
for ( ;; )
|
||||
{
|
||||
word = strtok(string, index)
|
||||
if (strlen(word) == 0)
|
||||
break
|
||||
count++
|
||||
printf "Word %d: '%s'\n", count, word
|
||||
}
|
||||
|
||||
printf "\nNumber of words: %d\n", count
|
||||
}
|
||||
|
||||
strtok(const string[], &index)
|
||||
{
|
||||
new length = strlen(string)
|
||||
|
||||
/* skip leading white space */
|
||||
while (index < length && string[index] <= ' ')
|
||||
index++
|
||||
|
||||
/* store the word letter for letter */
|
||||
new offset = index /* save start position of token */
|
||||
new result[20] /* string to store the word in */
|
||||
while (index < length
|
||||
&& string[index] > ' '
|
||||
&& index - offset < sizeof result - 1)
|
||||
{
|
||||
result[index - offset] = string[index]
|
||||
index++
|
||||
}
|
||||
result[index - offset] = EOS /* zero-terminate the string */
|
||||
|
||||
return result
|
||||
}
|
||||
/* word count: count words on a string that the user types */
|
||||
|
||||
main()
|
||||
{
|
||||
print "Please type a string: "
|
||||
new string[100]
|
||||
getstring string, sizeof string
|
||||
|
||||
new count = 0
|
||||
|
||||
new word[20]
|
||||
new index
|
||||
for ( ;; )
|
||||
{
|
||||
word = strtok(string, index)
|
||||
if (strlen(word) == 0)
|
||||
break
|
||||
count++
|
||||
printf "Word %d: '%s'\n", count, word
|
||||
}
|
||||
|
||||
printf "\nNumber of words: %d\n", count
|
||||
}
|
||||
|
||||
strtok(const string[], &index)
|
||||
{
|
||||
new length = strlen(string)
|
||||
|
||||
/* skip leading white space */
|
||||
while (index < length && string[index] <= ' ')
|
||||
index++
|
||||
|
||||
/* store the word letter for letter */
|
||||
new offset = index /* save start position of token */
|
||||
new result[20] /* string to store the word in */
|
||||
while (index < length
|
||||
&& string[index] > ' '
|
||||
&& index - offset < sizeof result - 1)
|
||||
{
|
||||
result[index - offset] = string[index]
|
||||
index++
|
||||
}
|
||||
result[index - offset] = EOS /* zero-terminate the string */
|
||||
|
||||
return result
|
||||
}
|
||||
|
@ -1,164 +1,164 @@
|
||||
/**
|
||||
* This program illustrates Zeller's congruence algorithm to calculate
|
||||
* the day of the week given a date.
|
||||
*/
|
||||
|
||||
/**
|
||||
* <summary>
|
||||
* The main program: asks the user to input a date and prints on
|
||||
* what day of the week that date falls.
|
||||
* </summary>
|
||||
*/
|
||||
main()
|
||||
{
|
||||
new day, month, year
|
||||
if (readdate(day, month, year))
|
||||
{
|
||||
new wkday = weekday(day, month, year)
|
||||
printf "The date %d-%d-%d falls on a ", day, month, year
|
||||
switch (wkday)
|
||||
{
|
||||
case 0:
|
||||
print "Saturday"
|
||||
case 1:
|
||||
print "Sunday"
|
||||
case 2:
|
||||
print "Monday"
|
||||
case 3:
|
||||
print "Tuesday"
|
||||
case 4:
|
||||
print "Wednesday"
|
||||
case 5:
|
||||
print "Thursday"
|
||||
case 6:
|
||||
print "Friday"
|
||||
}
|
||||
}
|
||||
else
|
||||
print "Invalid date"
|
||||
|
||||
print "\n"
|
||||
}
|
||||
|
||||
/**
|
||||
* <summary>
|
||||
* The core function of Zeller's congruence algorithm. The function
|
||||
* works for the Gregorian calender.
|
||||
* </summary>
|
||||
*
|
||||
* <param name="day">
|
||||
* The day in the month, a value between 1 and 31.
|
||||
* </param>
|
||||
* <param name="month">
|
||||
* The month: a value between 1 and 12.
|
||||
* </param>
|
||||
* <param name="year">
|
||||
* The year in four digits.
|
||||
* </param>
|
||||
*
|
||||
* <returns>
|
||||
* The day of the week, where 0 is Saturday and 6 is Friday.
|
||||
* </returns>
|
||||
*
|
||||
* <remarks>
|
||||
* This function does not check the validity of the date; when the
|
||||
* date in the parameters is invalid, the returned "day of the week"
|
||||
* will hold an incorrect value.
|
||||
* <p/>
|
||||
* This equation fails in many programming languages, notably most
|
||||
* implementations of C, C++ and Pascal, because these languages have
|
||||
* a loosely defined "remainder" operator. Pawn, on the other hand,
|
||||
* provides the true modulus operator, as defined in mathematical
|
||||
* theory and as was intended by Zeller.
|
||||
* </remarks>
|
||||
*/
|
||||
weekday(day, month, year)
|
||||
{
|
||||
/**
|
||||
* <remarks>
|
||||
* For Zeller's congruence algorithm, the months January and
|
||||
* February are the 13th and 14th month of the <em>preceding</em>
|
||||
* year. The idea is that the "difficult month" February (which
|
||||
* has either 28 or 29 days) is moved to the end of the year.
|
||||
* </remarks>
|
||||
*/
|
||||
if (month <= 2)
|
||||
month += 12, --year
|
||||
|
||||
new j = year % 100
|
||||
new e = year / 100
|
||||
return (day + (month+1)*26/10 + j + j/4 + e/4 - 2*e) % 7
|
||||
}
|
||||
|
||||
/**
|
||||
* <summary>
|
||||
* Reads a date and stores it in three separate fields. tata
|
||||
* </summary>
|
||||
*
|
||||
* <param name="day">
|
||||
* Will hold the day number upon return.
|
||||
* </param>
|
||||
* <param name="month">
|
||||
* Will hold the month number upon return.
|
||||
* </param>
|
||||
* <param name="year">
|
||||
* Will hold the year number upon return.
|
||||
* </param>
|
||||
*
|
||||
* <returns>
|
||||
* <em>true</em> if the date is valid, <em>false</em> otherwise;
|
||||
* if the function returns <em>false</em>, the values of
|
||||
* <paramref name="day"/>, <paramref name="month"/> and
|
||||
* <paramref name="year"/> cannot be relied upon.
|
||||
* </returns>
|
||||
*/
|
||||
bool: readdate(&day, &month, &year)
|
||||
{
|
||||
print "Give a date (dd-mm-yyyy): "
|
||||
day = getvalue(_,'-','/')
|
||||
month = getvalue(_,'-','/')
|
||||
year = getvalue()
|
||||
return 1 <= month <= 12 && 1 <= day <= daysinmonth(month,year)
|
||||
}
|
||||
|
||||
/**
|
||||
* <summary>
|
||||
* Returns whether a year is a leap year.
|
||||
* </summary>
|
||||
*
|
||||
* <param name="year">
|
||||
* The year in 4 digits.
|
||||
* </param>
|
||||
*
|
||||
* <remarks>
|
||||
* A year is a leap year:
|
||||
* <ul>
|
||||
* <li> if it is divisable by 4, </li>
|
||||
* <li> but <strong>not</strong> if it is divisable by 100, </li>
|
||||
* <li> but it <strong>is</strong> it is divisable by 400. </li>
|
||||
* </ul>
|
||||
* </remarks>
|
||||
*/
|
||||
bool: isleapyear(year)
|
||||
return year % 400 == 0 || year % 100 != 0 && year % 4 == 0
|
||||
|
||||
/**
|
||||
* <summary>
|
||||
* Returns the number of days in a month (the month is an integer
|
||||
* in the range 1 .. 12). One needs to pass in the year as well,
|
||||
* because the function takes leap years into account.
|
||||
* </summary>
|
||||
*
|
||||
* <param name="month">
|
||||
* The month number, a value between 1 and 12.
|
||||
* </param>
|
||||
* <param name="year">
|
||||
* The year in 4 digits.
|
||||
* </param>
|
||||
*/
|
||||
daysinmonth(month, year)
|
||||
{
|
||||
static daylist[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
|
||||
assert 1 <= month <= 12
|
||||
return daylist[month-1] + _:(month == 2 && isleapyear(year))
|
||||
}
|
||||
/**
|
||||
* This program illustrates Zeller's congruence algorithm to calculate
|
||||
* the day of the week given a date.
|
||||
*/
|
||||
|
||||
/**
|
||||
* <summary>
|
||||
* The main program: asks the user to input a date and prints on
|
||||
* what day of the week that date falls.
|
||||
* </summary>
|
||||
*/
|
||||
main()
|
||||
{
|
||||
new day, month, year
|
||||
if (readdate(day, month, year))
|
||||
{
|
||||
new wkday = weekday(day, month, year)
|
||||
printf "The date %d-%d-%d falls on a ", day, month, year
|
||||
switch (wkday)
|
||||
{
|
||||
case 0:
|
||||
print "Saturday"
|
||||
case 1:
|
||||
print "Sunday"
|
||||
case 2:
|
||||
print "Monday"
|
||||
case 3:
|
||||
print "Tuesday"
|
||||
case 4:
|
||||
print "Wednesday"
|
||||
case 5:
|
||||
print "Thursday"
|
||||
case 6:
|
||||
print "Friday"
|
||||
}
|
||||
}
|
||||
else
|
||||
print "Invalid date"
|
||||
|
||||
print "\n"
|
||||
}
|
||||
|
||||
/**
|
||||
* <summary>
|
||||
* The core function of Zeller's congruence algorithm. The function
|
||||
* works for the Gregorian calender.
|
||||
* </summary>
|
||||
*
|
||||
* <param name="day">
|
||||
* The day in the month, a value between 1 and 31.
|
||||
* </param>
|
||||
* <param name="month">
|
||||
* The month: a value between 1 and 12.
|
||||
* </param>
|
||||
* <param name="year">
|
||||
* The year in four digits.
|
||||
* </param>
|
||||
*
|
||||
* <returns>
|
||||
* The day of the week, where 0 is Saturday and 6 is Friday.
|
||||
* </returns>
|
||||
*
|
||||
* <remarks>
|
||||
* This function does not check the validity of the date; when the
|
||||
* date in the parameters is invalid, the returned "day of the week"
|
||||
* will hold an incorrect value.
|
||||
* <p/>
|
||||
* This equation fails in many programming languages, notably most
|
||||
* implementations of C, C++ and Pascal, because these languages have
|
||||
* a loosely defined "remainder" operator. Pawn, on the other hand,
|
||||
* provides the true modulus operator, as defined in mathematical
|
||||
* theory and as was intended by Zeller.
|
||||
* </remarks>
|
||||
*/
|
||||
weekday(day, month, year)
|
||||
{
|
||||
/**
|
||||
* <remarks>
|
||||
* For Zeller's congruence algorithm, the months January and
|
||||
* February are the 13th and 14th month of the <em>preceding</em>
|
||||
* year. The idea is that the "difficult month" February (which
|
||||
* has either 28 or 29 days) is moved to the end of the year.
|
||||
* </remarks>
|
||||
*/
|
||||
if (month <= 2)
|
||||
month += 12, --year
|
||||
|
||||
new j = year % 100
|
||||
new e = year / 100
|
||||
return (day + (month+1)*26/10 + j + j/4 + e/4 - 2*e) % 7
|
||||
}
|
||||
|
||||
/**
|
||||
* <summary>
|
||||
* Reads a date and stores it in three separate fields. tata
|
||||
* </summary>
|
||||
*
|
||||
* <param name="day">
|
||||
* Will hold the day number upon return.
|
||||
* </param>
|
||||
* <param name="month">
|
||||
* Will hold the month number upon return.
|
||||
* </param>
|
||||
* <param name="year">
|
||||
* Will hold the year number upon return.
|
||||
* </param>
|
||||
*
|
||||
* <returns>
|
||||
* <em>true</em> if the date is valid, <em>false</em> otherwise;
|
||||
* if the function returns <em>false</em>, the values of
|
||||
* <paramref name="day"/>, <paramref name="month"/> and
|
||||
* <paramref name="year"/> cannot be relied upon.
|
||||
* </returns>
|
||||
*/
|
||||
bool: readdate(&day, &month, &year)
|
||||
{
|
||||
print "Give a date (dd-mm-yyyy): "
|
||||
day = getvalue(_,'-','/')
|
||||
month = getvalue(_,'-','/')
|
||||
year = getvalue()
|
||||
return 1 <= month <= 12 && 1 <= day <= daysinmonth(month,year)
|
||||
}
|
||||
|
||||
/**
|
||||
* <summary>
|
||||
* Returns whether a year is a leap year.
|
||||
* </summary>
|
||||
*
|
||||
* <param name="year">
|
||||
* The year in 4 digits.
|
||||
* </param>
|
||||
*
|
||||
* <remarks>
|
||||
* A year is a leap year:
|
||||
* <ul>
|
||||
* <li> if it is divisable by 4, </li>
|
||||
* <li> but <strong>not</strong> if it is divisable by 100, </li>
|
||||
* <li> but it <strong>is</strong> it is divisable by 400. </li>
|
||||
* </ul>
|
||||
* </remarks>
|
||||
*/
|
||||
bool: isleapyear(year)
|
||||
return year % 400 == 0 || year % 100 != 0 && year % 4 == 0
|
||||
|
||||
/**
|
||||
* <summary>
|
||||
* Returns the number of days in a month (the month is an integer
|
||||
* in the range 1 .. 12). One needs to pass in the year as well,
|
||||
* because the function takes leap years into account.
|
||||
* </summary>
|
||||
*
|
||||
* <param name="month">
|
||||
* The month number, a value between 1 and 12.
|
||||
* </param>
|
||||
* <param name="year">
|
||||
* The year in 4 digits.
|
||||
* </param>
|
||||
*/
|
||||
daysinmonth(month, year)
|
||||
{
|
||||
static daylist[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
|
||||
assert 1 <= month <= 12
|
||||
return daylist[month-1] + _:(month == 2 && isleapyear(year))
|
||||
}
|
||||
|
@ -1,78 +1,78 @@
|
||||
/* An assortment of additional functions in the DLL version of the
|
||||
* Abstract Machine.
|
||||
*
|
||||
* (c) Copyright 2000-2005, ITB CompuPhase
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _amxdll_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _amxdll_included
|
||||
|
||||
enum
|
||||
{
|
||||
Ok,
|
||||
Okcancel,
|
||||
okCancel,
|
||||
Yesno,
|
||||
yesNo,
|
||||
Yesnocancel,
|
||||
yesNocancel,
|
||||
yesnoCancel,
|
||||
}
|
||||
enum
|
||||
{
|
||||
noicon,
|
||||
information,
|
||||
exclamation,
|
||||
question,
|
||||
stop
|
||||
}
|
||||
native messagebox(const message[], const caption[], buttons=Ok, icons=noicon, timeout=0);
|
||||
|
||||
/* Types:
|
||||
* i = integer (16/32 bit)
|
||||
* l = 32-bit integer
|
||||
* h = handle (16/32 bit)
|
||||
* p = packed string
|
||||
* s = (unpacked) string
|
||||
* w = 16-bit unsigned integer
|
||||
* lower case = by value, upper case = by reference
|
||||
*
|
||||
* The types noted as "16/32 bit" are converted to 16-bit in Win16 environments
|
||||
* prior to the call to the DLL.
|
||||
*
|
||||
* calldll() attaches "32" to the dll name if it cannot load the DLL as you
|
||||
* provide it. So it loads "user32" if you specify "user" and you are in Win32.
|
||||
* calldll() also appends a "A" to the function name if it cannot find the
|
||||
* function as specified. So it call "GetWindowTextA" if you ask for
|
||||
* "GetWindowText". By this means, the interface is more compatible between
|
||||
* 16-bit and 32-bit platforms.
|
||||
*/
|
||||
native calldll(const dllname[], const function[], const typestr[]="", ...);
|
||||
|
||||
native loaddll(const dllname[]);
|
||||
native freedll(const dllname[]);
|
||||
|
||||
native iswin32();
|
||||
|
||||
native balloon(&Balloon:handle, text[]="", x=0, y=0, timeout=-1);
|
||||
native balloonfont(&Balloon:handle, const font[]="", height=16, weight=400, italic=0);
|
||||
|
||||
stock wGetCursorPos(&x, &y)
|
||||
/* Get the current position of the mouse cursor relative to the upper
|
||||
* left corner of the screen
|
||||
*/
|
||||
{
|
||||
new point[2]
|
||||
calldll(!"user","GetCursorPos","I",point)
|
||||
if (!iswin32())
|
||||
{
|
||||
point[1] = point[0] >> 16
|
||||
point[0] &= 0xffff
|
||||
}
|
||||
x = point[0]
|
||||
y = point[1]
|
||||
}
|
||||
|
||||
|
||||
/* An assortment of additional functions in the DLL version of the
|
||||
* Abstract Machine.
|
||||
*
|
||||
* (c) Copyright 2000-2005, ITB CompuPhase
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _amxdll_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _amxdll_included
|
||||
|
||||
enum
|
||||
{
|
||||
Ok,
|
||||
Okcancel,
|
||||
okCancel,
|
||||
Yesno,
|
||||
yesNo,
|
||||
Yesnocancel,
|
||||
yesNocancel,
|
||||
yesnoCancel,
|
||||
}
|
||||
enum
|
||||
{
|
||||
noicon,
|
||||
information,
|
||||
exclamation,
|
||||
question,
|
||||
stop
|
||||
}
|
||||
native messagebox(const message[], const caption[], buttons=Ok, icons=noicon, timeout=0);
|
||||
|
||||
/* Types:
|
||||
* i = integer (16/32 bit)
|
||||
* l = 32-bit integer
|
||||
* h = handle (16/32 bit)
|
||||
* p = packed string
|
||||
* s = (unpacked) string
|
||||
* w = 16-bit unsigned integer
|
||||
* lower case = by value, upper case = by reference
|
||||
*
|
||||
* The types noted as "16/32 bit" are converted to 16-bit in Win16 environments
|
||||
* prior to the call to the DLL.
|
||||
*
|
||||
* calldll() attaches "32" to the dll name if it cannot load the DLL as you
|
||||
* provide it. So it loads "user32" if you specify "user" and you are in Win32.
|
||||
* calldll() also appends a "A" to the function name if it cannot find the
|
||||
* function as specified. So it call "GetWindowTextA" if you ask for
|
||||
* "GetWindowText". By this means, the interface is more compatible between
|
||||
* 16-bit and 32-bit platforms.
|
||||
*/
|
||||
native calldll(const dllname[], const function[], const typestr[]="", ...);
|
||||
|
||||
native loaddll(const dllname[]);
|
||||
native freedll(const dllname[]);
|
||||
|
||||
native iswin32();
|
||||
|
||||
native balloon(&Balloon:handle, text[]="", x=0, y=0, timeout=-1);
|
||||
native balloonfont(&Balloon:handle, const font[]="", height=16, weight=400, italic=0);
|
||||
|
||||
stock wGetCursorPos(&x, &y)
|
||||
/* Get the current position of the mouse cursor relative to the upper
|
||||
* left corner of the screen
|
||||
*/
|
||||
{
|
||||
new point[2]
|
||||
calldll(!"user","GetCursorPos","I",point)
|
||||
if (!iswin32())
|
||||
{
|
||||
point[1] = point[0] >> 16
|
||||
point[0] &= 0xffff
|
||||
}
|
||||
x = point[0]
|
||||
y = point[1]
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
/* Script Arguments support functions
|
||||
*
|
||||
* (c) Copyright 2005, ITB CompuPhase
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _args_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _args_included
|
||||
#pragma library Args
|
||||
|
||||
native argcount();
|
||||
native bool: argindex(index, value[], maxlength = sizeof value, bool: pack = false);
|
||||
native bool: argstr(index = 0, const option[] = "", value[] = "", maxlength = sizeof value, bool: pack = false);
|
||||
native bool: argvalue(index = 0, const option[] = "", &value = cellmin);
|
||||
/* Script Arguments support functions
|
||||
*
|
||||
* (c) Copyright 2005, ITB CompuPhase
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _args_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _args_included
|
||||
#pragma library Args
|
||||
|
||||
native argcount();
|
||||
native bool: argindex(index, value[], maxlength = sizeof value, bool: pack = false);
|
||||
native bool: argstr(index = 0, const option[] = "", value[] = "", maxlength = sizeof value, bool: pack = false);
|
||||
native bool: argvalue(index = 0, const option[] = "", &value = cellmin);
|
||||
|
@ -1,37 +1,37 @@
|
||||
/* Console input/output functions
|
||||
*
|
||||
* (c) Copyright 1998-2005, ITB CompuPhase
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _console_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _console_included
|
||||
#pragma library Console
|
||||
|
||||
enum
|
||||
{
|
||||
black, /* colours as per the ANSI Escape sequences, ISO 6429 */
|
||||
red,
|
||||
green,
|
||||
yellow,
|
||||
blue,
|
||||
magenta,
|
||||
cyan,
|
||||
white,
|
||||
}
|
||||
|
||||
native getchar(echo=true);
|
||||
native getstring(string[], maxlength=sizeof string, bool:pack=false);
|
||||
native getvalue(base=10, term=0x0d, ...); /* 0x0d == '\r' */
|
||||
native print(const string[], foreground=-1, background=-1, highlight=-1);
|
||||
native printf(const format[], {Float,Fixed,_}:...);
|
||||
|
||||
native console(columns, lines);
|
||||
native clrscr(); /* also resets the cursor to (1,1) */
|
||||
native clreol();
|
||||
native gotoxy(x=1, y=1);
|
||||
native wherexy(&x, &y);
|
||||
native setattr(foreground=-1, background=-1, highlight=-1);
|
||||
|
||||
forward @keypressed(key);
|
||||
/* Console input/output functions
|
||||
*
|
||||
* (c) Copyright 1998-2005, ITB CompuPhase
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _console_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _console_included
|
||||
#pragma library Console
|
||||
|
||||
enum
|
||||
{
|
||||
black, /* colours as per the ANSI Escape sequences, ISO 6429 */
|
||||
red,
|
||||
green,
|
||||
yellow,
|
||||
blue,
|
||||
magenta,
|
||||
cyan,
|
||||
white,
|
||||
}
|
||||
|
||||
native getchar(echo=true);
|
||||
native getstring(string[], maxlength=sizeof string, bool:pack=false);
|
||||
native getvalue(base=10, term=0x0d, ...); /* 0x0d == '\r' */
|
||||
native print(const string[], foreground=-1, background=-1, highlight=-1);
|
||||
native printf(const format[], {Float,Fixed,_}:...);
|
||||
|
||||
native console(columns, lines);
|
||||
native clrscr(); /* also resets the cursor to (1,1) */
|
||||
native clreol();
|
||||
native gotoxy(x=1, y=1);
|
||||
native wherexy(&x, &y);
|
||||
native setattr(foreground=-1, background=-1, highlight=-1);
|
||||
|
||||
forward @keypressed(key);
|
||||
|
@ -1,34 +1,34 @@
|
||||
/* Core functions
|
||||
*
|
||||
* (c) Copyright 1998-2005, ITB CompuPhase
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _core_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _core_included
|
||||
#pragma library Core
|
||||
|
||||
native heapspace();
|
||||
|
||||
native funcidx(const name[]);
|
||||
|
||||
native numargs();
|
||||
native getarg(arg, index=0);
|
||||
native setarg(arg, index=0, value);
|
||||
|
||||
native tolower(c);
|
||||
native toupper(c);
|
||||
native swapchars(c);
|
||||
|
||||
native random(max);
|
||||
|
||||
native min(value1, value2);
|
||||
native max(value1, value2);
|
||||
native clamp(value, min=cellmin, max=cellmax);
|
||||
|
||||
native getproperty(id=0, const name[]="", value=cellmin, string[]="");
|
||||
native setproperty(id=0, const name[]="", value=cellmin, const string[]="");
|
||||
native deleteproperty(id=0, const name[]="", value=cellmin);
|
||||
native existproperty(id=0, const name[]="", value=cellmin);
|
||||
|
||||
/* Core functions
|
||||
*
|
||||
* (c) Copyright 1998-2005, ITB CompuPhase
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _core_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _core_included
|
||||
#pragma library Core
|
||||
|
||||
native heapspace();
|
||||
|
||||
native funcidx(const name[]);
|
||||
|
||||
native numargs();
|
||||
native getarg(arg, index=0);
|
||||
native setarg(arg, index=0, value);
|
||||
|
||||
native tolower(c);
|
||||
native toupper(c);
|
||||
native swapchars(c);
|
||||
|
||||
native random(max);
|
||||
|
||||
native min(value1, value2);
|
||||
native max(value1, value2);
|
||||
native clamp(value, min=cellmin, max=cellmax);
|
||||
|
||||
native getproperty(id=0, const name[]="", value=cellmin, string[]="");
|
||||
native setproperty(id=0, const name[]="", value=cellmin, const string[]="");
|
||||
native deleteproperty(id=0, const name[]="", value=cellmin);
|
||||
native existproperty(id=0, const name[]="", value=cellmin);
|
||||
|
||||
|
@ -1,18 +1,18 @@
|
||||
/* Datagram sending/receiving
|
||||
*
|
||||
* (c) Copyright 2005, ITB CompuPhase
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _datagram_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _datagram_included
|
||||
#pragma library DGram
|
||||
|
||||
native sendstring(const message[], const destination[]="");
|
||||
native sendpacket(const packet[], size, const destination[]="");
|
||||
|
||||
native listenport(port);
|
||||
|
||||
forward @receivestring(const message[], const source[]);
|
||||
forward @receivepacket(const packet[], size, const source[]);
|
||||
/* Datagram sending/receiving
|
||||
*
|
||||
* (c) Copyright 2005, ITB CompuPhase
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _datagram_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _datagram_included
|
||||
#pragma library DGram
|
||||
|
||||
native sendstring(const message[], const destination[]="");
|
||||
native sendpacket(const packet[], size, const destination[]="");
|
||||
|
||||
native listenport(port);
|
||||
|
||||
forward @receivestring(const message[], const source[]);
|
||||
forward @receivepacket(const packet[], size, const source[]);
|
||||
|
@ -1,2 +1,2 @@
|
||||
#include <core>
|
||||
#include <console>
|
||||
#include <core>
|
||||
#include <console>
|
||||
|
@ -1,44 +1,44 @@
|
||||
/* File input/output functions
|
||||
*
|
||||
* (c) Copyright 2004-2005, ITB CompuPhase
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _file_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _file_included
|
||||
#pragma library File
|
||||
|
||||
enum filemode
|
||||
{
|
||||
io_read, /* file must exist */
|
||||
io_write, /* creates a new file */
|
||||
io_readwrite, /* opens an existing file, or creates a new file */
|
||||
io_append, /* appends to file (write-only) */
|
||||
}
|
||||
|
||||
enum seek_whence
|
||||
{
|
||||
seek_start,
|
||||
seek_current,
|
||||
seek_end,
|
||||
}
|
||||
|
||||
const EOF = -1;
|
||||
|
||||
native File: fopen(const name[], filemode: mode = io_readwrite);
|
||||
native bool: fclose(File: handle);
|
||||
native File: ftemp();
|
||||
native bool: fremove(const name[]);
|
||||
|
||||
native fwrite(File: handle, const string[]);
|
||||
native fread(File: handle, string[], size = sizeof string, bool: pack = false);
|
||||
native bool: fputchar(File: handle, value, bool: utf8 = true);
|
||||
native fgetchar(File: handle, bool: utf8 = true);
|
||||
native fblockwrite(File: handle, const buffer[], size = sizeof buffer);
|
||||
native fblockread(File: handle, buffer[], size = sizeof buffer);
|
||||
|
||||
native fseek(File: handle, position = 0, seek_whence: whence = seek_start);
|
||||
native flength(File: handle);
|
||||
native fexist(const pattern[]);
|
||||
native bool: fmatch(name[], const pattern[], index = 0, size = sizeof name);
|
||||
/* File input/output functions
|
||||
*
|
||||
* (c) Copyright 2004-2005, ITB CompuPhase
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _file_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _file_included
|
||||
#pragma library File
|
||||
|
||||
enum filemode
|
||||
{
|
||||
io_read, /* file must exist */
|
||||
io_write, /* creates a new file */
|
||||
io_readwrite, /* opens an existing file, or creates a new file */
|
||||
io_append, /* appends to file (write-only) */
|
||||
}
|
||||
|
||||
enum seek_whence
|
||||
{
|
||||
seek_start,
|
||||
seek_current,
|
||||
seek_end,
|
||||
}
|
||||
|
||||
const EOF = -1;
|
||||
|
||||
native File: fopen(const name[], filemode: mode = io_readwrite);
|
||||
native bool: fclose(File: handle);
|
||||
native File: ftemp();
|
||||
native bool: fremove(const name[]);
|
||||
|
||||
native fwrite(File: handle, const string[]);
|
||||
native fread(File: handle, string[], size = sizeof string, bool: pack = false);
|
||||
native bool: fputchar(File: handle, value, bool: utf8 = true);
|
||||
native fgetchar(File: handle, bool: utf8 = true);
|
||||
native fblockwrite(File: handle, const buffer[], size = sizeof buffer);
|
||||
native fblockread(File: handle, buffer[], size = sizeof buffer);
|
||||
|
||||
native fseek(File: handle, position = 0, seek_whence: whence = seek_start);
|
||||
native flength(File: handle);
|
||||
native fexist(const pattern[]);
|
||||
native bool: fmatch(name[], const pattern[], index = 0, size = sizeof name);
|
||||
|
@ -1,95 +1,95 @@
|
||||
/* Fixed point arithmetic
|
||||
*
|
||||
* (c) Copyright 1998-2005, ITB CompuPhase
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _Fixed_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _Fixed_included
|
||||
#pragma library Fixed
|
||||
|
||||
enum fround_method {
|
||||
fround_round,
|
||||
fround_floor,
|
||||
fround_ceil,
|
||||
fround_tozero,
|
||||
fround_unbiased
|
||||
}
|
||||
|
||||
native Fixed:fixed(value);
|
||||
native Fixed:strfixed(const string[]);
|
||||
native Fixed:fmul(Fixed:oper1, Fixed:oper2);
|
||||
native Fixed:fdiv(Fixed:dividend, Fixed:divisor);
|
||||
native Fixed:ffract(Fixed:value);
|
||||
native fround(Fixed:value, fround_method:method=fround_round);
|
||||
native Fixed:fpower(Fixed:value, exponent);
|
||||
native Fixed:fsqroot(Fixed:value);
|
||||
native Fixed:fabs(Fixed:value);
|
||||
|
||||
#pragma rational Fixed(3)
|
||||
|
||||
/* user defined operators */
|
||||
native Fixed:operator*(Fixed:oper1, Fixed:oper2) = fmul;
|
||||
native Fixed:operator/(Fixed:oper1, Fixed:oper2) = fdiv;
|
||||
native Fixed:operator=(oper) = fixed;
|
||||
|
||||
stock Fixed:operator++(Fixed:oper)
|
||||
return oper + fixed(1);
|
||||
|
||||
stock Fixed:operator--(Fixed:oper)
|
||||
return oper - fixed(1);
|
||||
|
||||
stock Fixed:operator*(Fixed:oper1, oper2)
|
||||
return Fixed: (_:oper1 * oper2); /* "*" is commutative */
|
||||
|
||||
stock Fixed:operator/(Fixed:oper1, oper2)
|
||||
return oper1 / fixed(oper2);
|
||||
|
||||
stock Fixed:operator/(oper1, Fixed:oper2)
|
||||
return fdiv(fixed(oper1), oper2);
|
||||
|
||||
stock Fixed:operator+(Fixed:oper1, oper2)
|
||||
return oper1 + fixed(oper2); /* "+" is commutative */
|
||||
|
||||
stock Fixed:operator-(Fixed:oper1, oper2)
|
||||
return oper1 - fixed(oper2);
|
||||
|
||||
stock Fixed:operator-(oper1, Fixed:oper2)
|
||||
return fixed(oper1) - oper2;
|
||||
|
||||
stock bool:operator>(Fixed:oper1, oper2)
|
||||
return oper1 > fixed(oper2);
|
||||
|
||||
stock bool:operator>(oper1, Fixed:oper2)
|
||||
return fixed(oper1) > oper2;
|
||||
|
||||
stock bool:operator>=(Fixed:oper1, oper2)
|
||||
return oper1 >= fixed(oper2);
|
||||
|
||||
stock bool:operator>=(oper1, Fixed:oper2)
|
||||
return fixed(oper1) >= oper2;
|
||||
|
||||
stock bool:operator<(Fixed:oper1, oper2)
|
||||
return oper1 < fixed(oper2);
|
||||
|
||||
stock bool:operator<(oper1, Fixed:oper2)
|
||||
return fixed(oper1) < oper2;
|
||||
|
||||
stock bool:operator<=(Fixed:oper1, oper2)
|
||||
return oper1 <= fixed(oper2);
|
||||
|
||||
stock bool:operator<=(oper1, Fixed:oper2)
|
||||
return fixed(oper1) <= oper2;
|
||||
|
||||
stock bool:operator==(Fixed:oper1, oper2) /* "==" is commutative */
|
||||
return oper1 == fixed(oper2);
|
||||
|
||||
stock bool:operator!=(Fixed:oper1, oper2) /* "!=" is commutative */
|
||||
return oper1 != fixed(oper2);
|
||||
|
||||
/* forbidden operations */
|
||||
forward operator%(Fixed:oper1, Fixed:oper2);
|
||||
forward operator%(Fixed:oper1, oper2);
|
||||
forward operator%(oper1, Fixed:oper2);
|
||||
|
||||
/* Fixed point arithmetic
|
||||
*
|
||||
* (c) Copyright 1998-2005, ITB CompuPhase
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _Fixed_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _Fixed_included
|
||||
#pragma library Fixed
|
||||
|
||||
enum fround_method {
|
||||
fround_round,
|
||||
fround_floor,
|
||||
fround_ceil,
|
||||
fround_tozero,
|
||||
fround_unbiased
|
||||
}
|
||||
|
||||
native Fixed:fixed(value);
|
||||
native Fixed:strfixed(const string[]);
|
||||
native Fixed:fmul(Fixed:oper1, Fixed:oper2);
|
||||
native Fixed:fdiv(Fixed:dividend, Fixed:divisor);
|
||||
native Fixed:ffract(Fixed:value);
|
||||
native fround(Fixed:value, fround_method:method=fround_round);
|
||||
native Fixed:fpower(Fixed:value, exponent);
|
||||
native Fixed:fsqroot(Fixed:value);
|
||||
native Fixed:fabs(Fixed:value);
|
||||
|
||||
#pragma rational Fixed(3)
|
||||
|
||||
/* user defined operators */
|
||||
native Fixed:operator*(Fixed:oper1, Fixed:oper2) = fmul;
|
||||
native Fixed:operator/(Fixed:oper1, Fixed:oper2) = fdiv;
|
||||
native Fixed:operator=(oper) = fixed;
|
||||
|
||||
stock Fixed:operator++(Fixed:oper)
|
||||
return oper + fixed(1);
|
||||
|
||||
stock Fixed:operator--(Fixed:oper)
|
||||
return oper - fixed(1);
|
||||
|
||||
stock Fixed:operator*(Fixed:oper1, oper2)
|
||||
return Fixed: (_:oper1 * oper2); /* "*" is commutative */
|
||||
|
||||
stock Fixed:operator/(Fixed:oper1, oper2)
|
||||
return oper1 / fixed(oper2);
|
||||
|
||||
stock Fixed:operator/(oper1, Fixed:oper2)
|
||||
return fdiv(fixed(oper1), oper2);
|
||||
|
||||
stock Fixed:operator+(Fixed:oper1, oper2)
|
||||
return oper1 + fixed(oper2); /* "+" is commutative */
|
||||
|
||||
stock Fixed:operator-(Fixed:oper1, oper2)
|
||||
return oper1 - fixed(oper2);
|
||||
|
||||
stock Fixed:operator-(oper1, Fixed:oper2)
|
||||
return fixed(oper1) - oper2;
|
||||
|
||||
stock bool:operator>(Fixed:oper1, oper2)
|
||||
return oper1 > fixed(oper2);
|
||||
|
||||
stock bool:operator>(oper1, Fixed:oper2)
|
||||
return fixed(oper1) > oper2;
|
||||
|
||||
stock bool:operator>=(Fixed:oper1, oper2)
|
||||
return oper1 >= fixed(oper2);
|
||||
|
||||
stock bool:operator>=(oper1, Fixed:oper2)
|
||||
return fixed(oper1) >= oper2;
|
||||
|
||||
stock bool:operator<(Fixed:oper1, oper2)
|
||||
return oper1 < fixed(oper2);
|
||||
|
||||
stock bool:operator<(oper1, Fixed:oper2)
|
||||
return fixed(oper1) < oper2;
|
||||
|
||||
stock bool:operator<=(Fixed:oper1, oper2)
|
||||
return oper1 <= fixed(oper2);
|
||||
|
||||
stock bool:operator<=(oper1, Fixed:oper2)
|
||||
return fixed(oper1) <= oper2;
|
||||
|
||||
stock bool:operator==(Fixed:oper1, oper2) /* "==" is commutative */
|
||||
return oper1 == fixed(oper2);
|
||||
|
||||
stock bool:operator!=(Fixed:oper1, oper2) /* "!=" is commutative */
|
||||
return oper1 != fixed(oper2);
|
||||
|
||||
/* forbidden operations */
|
||||
forward operator%(Fixed:oper1, Fixed:oper2);
|
||||
forward operator%(Fixed:oper1, oper2);
|
||||
forward operator%(oper1, Fixed:oper2);
|
||||
|
||||
|
@ -1,184 +1,184 @@
|
||||
/* Float arithmetic
|
||||
*
|
||||
* (c) Copyright 1999, Artran, Inc.
|
||||
* Written by Greg Garner (gmg@artran.com)
|
||||
* Modified in March 2001 to include user defined
|
||||
* operators for the floating point functions.
|
||||
*
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _Float_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _Float_included
|
||||
#pragma library Float
|
||||
|
||||
/* Different methods of rounding */
|
||||
enum floatround_method {
|
||||
floatround_round,
|
||||
floatround_floor,
|
||||
floatround_ceil,
|
||||
floatround_tozero,
|
||||
floatround_unbiased
|
||||
}
|
||||
enum anglemode {
|
||||
radian,
|
||||
degrees,
|
||||
grades
|
||||
}
|
||||
|
||||
/**************************************************/
|
||||
/* Convert an integer into a floating point value */
|
||||
native Float:float(value);
|
||||
|
||||
/**************************************************/
|
||||
/* Convert a string into a floating point value */
|
||||
native Float:strfloat(const string[]);
|
||||
|
||||
/**************************************************/
|
||||
/* Multiple two floats together */
|
||||
native Float:floatmul(Float:oper1, Float:oper2);
|
||||
|
||||
/**************************************************/
|
||||
/* Divide the dividend float by the divisor float */
|
||||
native Float:floatdiv(Float:dividend, Float:divisor);
|
||||
|
||||
/**************************************************/
|
||||
/* Add two floats together */
|
||||
native Float:floatadd(Float:oper1, Float:oper2);
|
||||
|
||||
/**************************************************/
|
||||
/* Subtract oper2 float from oper1 float */
|
||||
native Float:floatsub(Float:oper1, Float:oper2);
|
||||
|
||||
/**************************************************/
|
||||
/* Return the fractional part of a float */
|
||||
native Float:floatfract(Float:value);
|
||||
|
||||
/**************************************************/
|
||||
/* Round a float into a integer value */
|
||||
native floatround(Float:value, floatround_method:method=floatround_round);
|
||||
|
||||
/**************************************************/
|
||||
/* Compare two integers. If the two elements are equal, return 0.
|
||||
If the first argument is greater than the second argument, return 1,
|
||||
If the first argument is less than the second argument, return -1. */
|
||||
native floatcmp(Float:oper1, Float:oper2);
|
||||
|
||||
/**************************************************/
|
||||
/* Return the square root of the input value, same as floatpower(value, 0.5) */
|
||||
native Float:floatsqroot(Float:value);
|
||||
|
||||
/**************************************************/
|
||||
/* Return the value raised to the power of the exponent */
|
||||
native Float:floatpower(Float:value, Float:exponent);
|
||||
|
||||
/**************************************************/
|
||||
/* Return the logarithm */
|
||||
native Float:floatlog(Float:value, Float:base=10.0);
|
||||
|
||||
/**************************************************/
|
||||
/* Return the sine, cosine or tangent. The input angle may be in radian,
|
||||
degrees or grades. */
|
||||
native Float:floatsin(Float:value, anglemode:mode=radian);
|
||||
native Float:floatcos(Float:value, anglemode:mode=radian);
|
||||
native Float:floattan(Float:value, anglemode:mode=radian);
|
||||
|
||||
/**************************************************/
|
||||
/* Return the absolute value */
|
||||
native Float:floatabs(Float:value);
|
||||
|
||||
|
||||
/**************************************************/
|
||||
#pragma rational Float
|
||||
|
||||
/* user defined operators */
|
||||
native Float:operator*(Float:oper1, Float:oper2) = floatmul;
|
||||
native Float:operator/(Float:oper1, Float:oper2) = floatdiv;
|
||||
native Float:operator+(Float:oper1, Float:oper2) = floatadd;
|
||||
native Float:operator-(Float:oper1, Float:oper2) = floatsub;
|
||||
native Float:operator=(oper) = float;
|
||||
|
||||
stock Float:operator++(Float:oper)
|
||||
return oper+1.0;
|
||||
|
||||
stock Float:operator--(Float:oper)
|
||||
return oper-1.0;
|
||||
|
||||
stock Float:operator-(Float:oper)
|
||||
return oper^Float:cellmin; /* IEEE values are sign/magnitude */
|
||||
|
||||
stock Float:operator*(Float:oper1, oper2)
|
||||
return floatmul(oper1, float(oper2)); /* "*" is commutative */
|
||||
|
||||
stock Float:operator/(Float:oper1, oper2)
|
||||
return floatdiv(oper1, float(oper2));
|
||||
|
||||
stock Float:operator/(oper1, Float:oper2)
|
||||
return floatdiv(float(oper1), oper2);
|
||||
|
||||
stock Float:operator+(Float:oper1, oper2)
|
||||
return floatadd(oper1, float(oper2)); /* "+" is commutative */
|
||||
|
||||
stock Float:operator-(Float:oper1, oper2)
|
||||
return floatsub(oper1, float(oper2));
|
||||
|
||||
stock Float:operator-(oper1, Float:oper2)
|
||||
return floatsub(float(oper1), oper2);
|
||||
|
||||
stock bool:operator==(Float:oper1, Float:oper2)
|
||||
return floatcmp(oper1, oper2) == 0;
|
||||
|
||||
stock bool:operator==(Float:oper1, oper2)
|
||||
return floatcmp(oper1, float(oper2)) == 0; /* "==" is commutative */
|
||||
|
||||
stock bool:operator!=(Float:oper1, Float:oper2)
|
||||
return floatcmp(oper1, oper2) != 0;
|
||||
|
||||
stock bool:operator!=(Float:oper1, oper2)
|
||||
return floatcmp(oper1, float(oper2)) != 0; /* "!=" is commutative */
|
||||
|
||||
stock bool:operator>(Float:oper1, Float:oper2)
|
||||
return floatcmp(oper1, oper2) > 0;
|
||||
|
||||
stock bool:operator>(Float:oper1, oper2)
|
||||
return floatcmp(oper1, float(oper2)) > 0;
|
||||
|
||||
stock bool:operator>(oper1, Float:oper2)
|
||||
return floatcmp(float(oper1), oper2) > 0;
|
||||
|
||||
stock bool:operator>=(Float:oper1, Float:oper2)
|
||||
return floatcmp(oper1, oper2) >= 0;
|
||||
|
||||
stock bool:operator>=(Float:oper1, oper2)
|
||||
return floatcmp(oper1, float(oper2)) >= 0;
|
||||
|
||||
stock bool:operator>=(oper1, Float:oper2)
|
||||
return floatcmp(float(oper1), oper2) >= 0;
|
||||
|
||||
stock bool:operator<(Float:oper1, Float:oper2)
|
||||
return floatcmp(oper1, oper2) < 0;
|
||||
|
||||
stock bool:operator<(Float:oper1, oper2)
|
||||
return floatcmp(oper1, float(oper2)) < 0;
|
||||
|
||||
stock bool:operator<(oper1, Float:oper2)
|
||||
return floatcmp(float(oper1), oper2) < 0;
|
||||
|
||||
stock bool:operator<=(Float:oper1, Float:oper2)
|
||||
return floatcmp(oper1, oper2) <= 0;
|
||||
|
||||
stock bool:operator<=(Float:oper1, oper2)
|
||||
return floatcmp(oper1, float(oper2)) <= 0;
|
||||
|
||||
stock bool:operator<=(oper1, Float:oper2)
|
||||
return floatcmp(float(oper1), oper2) <= 0;
|
||||
|
||||
stock bool:operator!(Float:oper)
|
||||
return (_:oper & cellmax) == 0;
|
||||
|
||||
/* forbidden operations */
|
||||
forward operator%(Float:oper1, Float:oper2);
|
||||
forward operator%(Float:oper1, oper2);
|
||||
forward operator%(oper1, Float:oper2);
|
||||
|
||||
/* Float arithmetic
|
||||
*
|
||||
* (c) Copyright 1999, Artran, Inc.
|
||||
* Written by Greg Garner (gmg@artran.com)
|
||||
* Modified in March 2001 to include user defined
|
||||
* operators for the floating point functions.
|
||||
*
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _Float_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _Float_included
|
||||
#pragma library Float
|
||||
|
||||
/* Different methods of rounding */
|
||||
enum floatround_method {
|
||||
floatround_round,
|
||||
floatround_floor,
|
||||
floatround_ceil,
|
||||
floatround_tozero,
|
||||
floatround_unbiased
|
||||
}
|
||||
enum anglemode {
|
||||
radian,
|
||||
degrees,
|
||||
grades
|
||||
}
|
||||
|
||||
/**************************************************/
|
||||
/* Convert an integer into a floating point value */
|
||||
native Float:float(value);
|
||||
|
||||
/**************************************************/
|
||||
/* Convert a string into a floating point value */
|
||||
native Float:strfloat(const string[]);
|
||||
|
||||
/**************************************************/
|
||||
/* Multiple two floats together */
|
||||
native Float:floatmul(Float:oper1, Float:oper2);
|
||||
|
||||
/**************************************************/
|
||||
/* Divide the dividend float by the divisor float */
|
||||
native Float:floatdiv(Float:dividend, Float:divisor);
|
||||
|
||||
/**************************************************/
|
||||
/* Add two floats together */
|
||||
native Float:floatadd(Float:oper1, Float:oper2);
|
||||
|
||||
/**************************************************/
|
||||
/* Subtract oper2 float from oper1 float */
|
||||
native Float:floatsub(Float:oper1, Float:oper2);
|
||||
|
||||
/**************************************************/
|
||||
/* Return the fractional part of a float */
|
||||
native Float:floatfract(Float:value);
|
||||
|
||||
/**************************************************/
|
||||
/* Round a float into a integer value */
|
||||
native floatround(Float:value, floatround_method:method=floatround_round);
|
||||
|
||||
/**************************************************/
|
||||
/* Compare two integers. If the two elements are equal, return 0.
|
||||
If the first argument is greater than the second argument, return 1,
|
||||
If the first argument is less than the second argument, return -1. */
|
||||
native floatcmp(Float:oper1, Float:oper2);
|
||||
|
||||
/**************************************************/
|
||||
/* Return the square root of the input value, same as floatpower(value, 0.5) */
|
||||
native Float:floatsqroot(Float:value);
|
||||
|
||||
/**************************************************/
|
||||
/* Return the value raised to the power of the exponent */
|
||||
native Float:floatpower(Float:value, Float:exponent);
|
||||
|
||||
/**************************************************/
|
||||
/* Return the logarithm */
|
||||
native Float:floatlog(Float:value, Float:base=10.0);
|
||||
|
||||
/**************************************************/
|
||||
/* Return the sine, cosine or tangent. The input angle may be in radian,
|
||||
degrees or grades. */
|
||||
native Float:floatsin(Float:value, anglemode:mode=radian);
|
||||
native Float:floatcos(Float:value, anglemode:mode=radian);
|
||||
native Float:floattan(Float:value, anglemode:mode=radian);
|
||||
|
||||
/**************************************************/
|
||||
/* Return the absolute value */
|
||||
native Float:floatabs(Float:value);
|
||||
|
||||
|
||||
/**************************************************/
|
||||
#pragma rational Float
|
||||
|
||||
/* user defined operators */
|
||||
native Float:operator*(Float:oper1, Float:oper2) = floatmul;
|
||||
native Float:operator/(Float:oper1, Float:oper2) = floatdiv;
|
||||
native Float:operator+(Float:oper1, Float:oper2) = floatadd;
|
||||
native Float:operator-(Float:oper1, Float:oper2) = floatsub;
|
||||
native Float:operator=(oper) = float;
|
||||
|
||||
stock Float:operator++(Float:oper)
|
||||
return oper+1.0;
|
||||
|
||||
stock Float:operator--(Float:oper)
|
||||
return oper-1.0;
|
||||
|
||||
stock Float:operator-(Float:oper)
|
||||
return oper^Float:cellmin; /* IEEE values are sign/magnitude */
|
||||
|
||||
stock Float:operator*(Float:oper1, oper2)
|
||||
return floatmul(oper1, float(oper2)); /* "*" is commutative */
|
||||
|
||||
stock Float:operator/(Float:oper1, oper2)
|
||||
return floatdiv(oper1, float(oper2));
|
||||
|
||||
stock Float:operator/(oper1, Float:oper2)
|
||||
return floatdiv(float(oper1), oper2);
|
||||
|
||||
stock Float:operator+(Float:oper1, oper2)
|
||||
return floatadd(oper1, float(oper2)); /* "+" is commutative */
|
||||
|
||||
stock Float:operator-(Float:oper1, oper2)
|
||||
return floatsub(oper1, float(oper2));
|
||||
|
||||
stock Float:operator-(oper1, Float:oper2)
|
||||
return floatsub(float(oper1), oper2);
|
||||
|
||||
stock bool:operator==(Float:oper1, Float:oper2)
|
||||
return floatcmp(oper1, oper2) == 0;
|
||||
|
||||
stock bool:operator==(Float:oper1, oper2)
|
||||
return floatcmp(oper1, float(oper2)) == 0; /* "==" is commutative */
|
||||
|
||||
stock bool:operator!=(Float:oper1, Float:oper2)
|
||||
return floatcmp(oper1, oper2) != 0;
|
||||
|
||||
stock bool:operator!=(Float:oper1, oper2)
|
||||
return floatcmp(oper1, float(oper2)) != 0; /* "!=" is commutative */
|
||||
|
||||
stock bool:operator>(Float:oper1, Float:oper2)
|
||||
return floatcmp(oper1, oper2) > 0;
|
||||
|
||||
stock bool:operator>(Float:oper1, oper2)
|
||||
return floatcmp(oper1, float(oper2)) > 0;
|
||||
|
||||
stock bool:operator>(oper1, Float:oper2)
|
||||
return floatcmp(float(oper1), oper2) > 0;
|
||||
|
||||
stock bool:operator>=(Float:oper1, Float:oper2)
|
||||
return floatcmp(oper1, oper2) >= 0;
|
||||
|
||||
stock bool:operator>=(Float:oper1, oper2)
|
||||
return floatcmp(oper1, float(oper2)) >= 0;
|
||||
|
||||
stock bool:operator>=(oper1, Float:oper2)
|
||||
return floatcmp(float(oper1), oper2) >= 0;
|
||||
|
||||
stock bool:operator<(Float:oper1, Float:oper2)
|
||||
return floatcmp(oper1, oper2) < 0;
|
||||
|
||||
stock bool:operator<(Float:oper1, oper2)
|
||||
return floatcmp(oper1, float(oper2)) < 0;
|
||||
|
||||
stock bool:operator<(oper1, Float:oper2)
|
||||
return floatcmp(float(oper1), oper2) < 0;
|
||||
|
||||
stock bool:operator<=(Float:oper1, Float:oper2)
|
||||
return floatcmp(oper1, oper2) <= 0;
|
||||
|
||||
stock bool:operator<=(Float:oper1, oper2)
|
||||
return floatcmp(oper1, float(oper2)) <= 0;
|
||||
|
||||
stock bool:operator<=(oper1, Float:oper2)
|
||||
return floatcmp(float(oper1), oper2) <= 0;
|
||||
|
||||
stock bool:operator!(Float:oper)
|
||||
return (_:oper & cellmax) == 0;
|
||||
|
||||
/* forbidden operations */
|
||||
forward operator%(Float:oper1, Float:oper2);
|
||||
forward operator%(Float:oper1, oper2);
|
||||
forward operator%(oper1, Float:oper2);
|
||||
|
||||
|
@ -1,19 +1,19 @@
|
||||
/* Process control and Foreign Function Interface (calling functions
|
||||
* in DLLs or shared libraries)
|
||||
*
|
||||
* (c) Copyright 2006, ITB CompuPhase
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _process_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _process_included
|
||||
#pragma library Process
|
||||
|
||||
native libcall(const libname[], const funcname[], const typestring[], ...);
|
||||
native bool: libfree(const libname[]="");
|
||||
|
||||
native PID: procexec(const progname[]);
|
||||
native procwait(PID:pid);
|
||||
native bool: procwrite(const line[], bool:appendlf=false);
|
||||
native bool: procread(line[], size=sizeof line, bool:striplf=false, bool:packed=false);
|
||||
/* Process control and Foreign Function Interface (calling functions
|
||||
* in DLLs or shared libraries)
|
||||
*
|
||||
* (c) Copyright 2006, ITB CompuPhase
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _process_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _process_included
|
||||
#pragma library Process
|
||||
|
||||
native libcall(const libname[], const funcname[], const typestring[], ...);
|
||||
native bool: libfree(const libname[]="");
|
||||
|
||||
native PID: procexec(const progname[]);
|
||||
native procwait(PID:pid);
|
||||
native bool: procwrite(const line[], bool:appendlf=false);
|
||||
native bool: procread(line[], size=sizeof line, bool:striplf=false, bool:packed=false);
|
||||
|
@ -1,53 +1,53 @@
|
||||
/* Rational number support
|
||||
* Loads either Float.inc or Fixed.inc, depending on the configuration
|
||||
*
|
||||
* (c) Copyright 2004-2005, ITB CompuPhase
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _Rational_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _Rational_included
|
||||
|
||||
/* first try to include floating point support */
|
||||
#if !defined NOFLOAT
|
||||
#tryinclude <float>
|
||||
#endif
|
||||
#if defined _Float_included
|
||||
#define Rational: Float:
|
||||
#define rationalstr(%1) floatstr(%1)
|
||||
#define rround(%1, %2) floatround(%1, %2)
|
||||
#define rsqroot(%1) floatsqroot(%1)
|
||||
#define rpower(%1, %2) floatpower(%1, %2)
|
||||
#define rabs(%1) floatabs(%1)
|
||||
|
||||
#define rround_round floatround_round
|
||||
#define rround_floor floatround_floor
|
||||
#define rround_ceil floatround_ceil
|
||||
#define rround_tozero floatround_tozero
|
||||
#define rround_unbiased floatround_unbiased
|
||||
#endinput
|
||||
#endif
|
||||
|
||||
/* loading floating point support failed, try fixed point support */
|
||||
#if !defined NOFIXED
|
||||
#tryinclude <fixed>
|
||||
#endif
|
||||
#if defined _Fixed_included
|
||||
#define Rational: Fixed:
|
||||
#define rationalstr(%1) fixedstr(%1)
|
||||
#define rround(%1, %2) fround(%1, %2)
|
||||
#define rsqroot(%1) fsqroot(%1)
|
||||
#define rpower(%1, %2) fpower(%1, %2)
|
||||
#define rabs(%1) fabs(%1)
|
||||
|
||||
#define rround_round fround_round
|
||||
#define rround_floor fround_floor
|
||||
#define rround_ceil fround_ceil
|
||||
#define rround_tozero fround_tozero
|
||||
#define rround_unbiased fround_unbiased
|
||||
#endinput
|
||||
#endif
|
||||
|
||||
/* if arrived here, neither floating point, nor fixed point support is available */
|
||||
#error Rational number support is unavailable (disabled or not installed)
|
||||
/* Rational number support
|
||||
* Loads either Float.inc or Fixed.inc, depending on the configuration
|
||||
*
|
||||
* (c) Copyright 2004-2005, ITB CompuPhase
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _Rational_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _Rational_included
|
||||
|
||||
/* first try to include floating point support */
|
||||
#if !defined NOFLOAT
|
||||
#tryinclude <float>
|
||||
#endif
|
||||
#if defined _Float_included
|
||||
#define Rational: Float:
|
||||
#define rationalstr(%1) floatstr(%1)
|
||||
#define rround(%1, %2) floatround(%1, %2)
|
||||
#define rsqroot(%1) floatsqroot(%1)
|
||||
#define rpower(%1, %2) floatpower(%1, %2)
|
||||
#define rabs(%1) floatabs(%1)
|
||||
|
||||
#define rround_round floatround_round
|
||||
#define rround_floor floatround_floor
|
||||
#define rround_ceil floatround_ceil
|
||||
#define rround_tozero floatround_tozero
|
||||
#define rround_unbiased floatround_unbiased
|
||||
#endinput
|
||||
#endif
|
||||
|
||||
/* loading floating point support failed, try fixed point support */
|
||||
#if !defined NOFIXED
|
||||
#tryinclude <fixed>
|
||||
#endif
|
||||
#if defined _Fixed_included
|
||||
#define Rational: Fixed:
|
||||
#define rationalstr(%1) fixedstr(%1)
|
||||
#define rround(%1, %2) fround(%1, %2)
|
||||
#define rsqroot(%1) fsqroot(%1)
|
||||
#define rpower(%1, %2) fpower(%1, %2)
|
||||
#define rabs(%1) fabs(%1)
|
||||
|
||||
#define rround_round fround_round
|
||||
#define rround_floor fround_floor
|
||||
#define rround_ceil fround_ceil
|
||||
#define rround_tozero fround_tozero
|
||||
#define rround_unbiased fround_unbiased
|
||||
#endinput
|
||||
#endif
|
||||
|
||||
/* if arrived here, neither floating point, nor fixed point support is available */
|
||||
#error Rational number support is unavailable (disabled or not installed)
|
||||
|
@ -1,35 +1,35 @@
|
||||
/* String functions
|
||||
*
|
||||
* (c) Copyright 2005, ITB CompuPhase
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _string_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _string_included
|
||||
#pragma library String
|
||||
|
||||
native strlen(const string[]);
|
||||
native strpack(dest[], const source[], maxlength=sizeof dest);
|
||||
native strunpack(dest[], const source[], maxlength=sizeof dest);
|
||||
native strcat(dest[], const source[], maxlength=sizeof dest);
|
||||
|
||||
native strmid(dest[], const source[], start=0, end=cellmax, maxlength=sizeof dest);
|
||||
native bool: strins(string[], const substr[], index, maxlength=sizeof string);
|
||||
native bool: strdel(string[], start, end);
|
||||
|
||||
native strcmp(const string1[], const string2[], bool:ignorecase=false, length=cellmax);
|
||||
native strfind(const string[], const sub[], bool:ignorecase=false, index=0);
|
||||
|
||||
native strval(const string[], index=0);
|
||||
native valstr(dest[], value, bool:pack=false);
|
||||
native bool: ispacked(const string[]);
|
||||
|
||||
native strformat(dest[], size=sizeof dest, bool:pack=false, const format[], {Fixed,Float,_}:...);
|
||||
|
||||
native uudecode(dest[], const source[], maxlength=sizeof dest);
|
||||
native uuencode(dest[], const source[], numbytes, maxlength=sizeof dest);
|
||||
native memcpy(dest[], const source[], index=0, numbytes, maxlength=sizeof dest);
|
||||
|
||||
stock bool: strequal(const string1[], const string2[], bool:ignorecase=false, length=cellmax)
|
||||
return strcmp(string1, string2, ignorecase, length) == 0
|
||||
/* String functions
|
||||
*
|
||||
* (c) Copyright 2005, ITB CompuPhase
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _string_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _string_included
|
||||
#pragma library String
|
||||
|
||||
native strlen(const string[]);
|
||||
native strpack(dest[], const source[], maxlength=sizeof dest);
|
||||
native strunpack(dest[], const source[], maxlength=sizeof dest);
|
||||
native strcat(dest[], const source[], maxlength=sizeof dest);
|
||||
|
||||
native strmid(dest[], const source[], start=0, end=cellmax, maxlength=sizeof dest);
|
||||
native bool: strins(string[], const substr[], index, maxlength=sizeof string);
|
||||
native bool: strdel(string[], start, end);
|
||||
|
||||
native strcmp(const string1[], const string2[], bool:ignorecase=false, length=cellmax);
|
||||
native strfind(const string[], const sub[], bool:ignorecase=false, index=0);
|
||||
|
||||
native strval(const string[], index=0);
|
||||
native valstr(dest[], value, bool:pack=false);
|
||||
native bool: ispacked(const string[]);
|
||||
|
||||
native strformat(dest[], size=sizeof dest, bool:pack=false, const format[], {Fixed,Float,_}:...);
|
||||
|
||||
native uudecode(dest[], const source[], maxlength=sizeof dest);
|
||||
native uuencode(dest[], const source[], numbytes, maxlength=sizeof dest);
|
||||
native memcpy(dest[], const source[], index=0, numbytes, maxlength=sizeof dest);
|
||||
|
||||
stock bool: strequal(const string1[], const string2[], bool:ignorecase=false, length=cellmax)
|
||||
return strcmp(string1, string2, ignorecase, length) == 0
|
||||
|
@ -1,22 +1,22 @@
|
||||
/* Date/time functions
|
||||
*
|
||||
* (c) Copyright 2001-2005, ITB CompuPhase
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _time_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _time_included
|
||||
#pragma library Time
|
||||
|
||||
native gettime(&hour=0, &minute=0, &second=0);
|
||||
native settime(hour=cellmin, minute=cellmin, second=cellmin);
|
||||
native getdate(&year=0, &month=0, &day=0);
|
||||
native setdate(year=cellmin, month=cellmin, day=cellmin);
|
||||
native settimestamp(seconds1970);
|
||||
|
||||
native settimer(milliseconds, bool: singleshot=false);
|
||||
native tickcount(&granularity=0);
|
||||
native delay(milliseconds);
|
||||
|
||||
forward @timer();
|
||||
/* Date/time functions
|
||||
*
|
||||
* (c) Copyright 2001-2005, ITB CompuPhase
|
||||
* This file is provided as is (no warranties).
|
||||
*/
|
||||
#if defined _time_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _time_included
|
||||
#pragma library Time
|
||||
|
||||
native gettime(&hour=0, &minute=0, &second=0);
|
||||
native settime(hour=cellmin, minute=cellmin, second=cellmin);
|
||||
native getdate(&year=0, &month=0, &day=0);
|
||||
native setdate(year=cellmin, month=cellmin, day=cellmin);
|
||||
native settimestamp(seconds1970);
|
||||
|
||||
native settimer(milliseconds, bool: singleshot=false);
|
||||
native tickcount(&granularity=0);
|
||||
native delay(milliseconds);
|
||||
|
||||
forward @timer();
|
||||
|
@ -1,208 +1,208 @@
|
||||
#build file for CMake, see http://www.cmake.org/
|
||||
|
||||
PROJECT(pawnamx)
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||
|
||||
# check for optional include files
|
||||
INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
|
||||
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
|
||||
IF(HAVE_UNISTD_H)
|
||||
ADD_DEFINITIONS(-DHAVE_UNISTD_H)
|
||||
ENDIF(HAVE_UNISTD_H)
|
||||
CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H)
|
||||
IF(HAVE_INTTYPES_H)
|
||||
ADD_DEFINITIONS(-DHAVE_INTTYPES_H)
|
||||
ENDIF(HAVE_INTTYPES_H)
|
||||
CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
|
||||
IF(HAVE_STDINT_H)
|
||||
ADD_DEFINITIONS(-DHAVE_STDINT_H)
|
||||
ENDIF(HAVE_STDINT_H)
|
||||
CHECK_INCLUDE_FILE("alloca.h" HAVE_ALLOCA_H)
|
||||
IF(HAVE_ALLOCA_H)
|
||||
ADD_DEFINITIONS(-DHAVE_ALLOCA_H)
|
||||
ENDIF(HAVE_ALLOCA_H)
|
||||
|
||||
ADD_DEFINITIONS(-DFLOATPOINT -DFIXEDPOINT)
|
||||
IF (UNIX)
|
||||
ADD_DEFINITIONS(-DLINUX)
|
||||
CHECK_INCLUDE_FILE("ffi.h" HAVE_FFI_H)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../linux)
|
||||
ENDIF (UNIX)
|
||||
IF(WIN32)
|
||||
ADD_DEFINITIONS(-DAMXEXPORT=__stdcall -DAMX_NATIVE_CALL=__stdcall -DSTDECL)
|
||||
IF(NOT BORLAND)
|
||||
LINK_LIBRARIES(winmm)
|
||||
ENDIF(NOT BORLAND)
|
||||
ENDIF(WIN32)
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Extension modules
|
||||
|
||||
# amxArgs
|
||||
SET(ARGS_SRCS amxargs.c amx.c)
|
||||
ADD_LIBRARY(amxArgs SHARED ${ARGS_SRCS})
|
||||
SET_TARGET_PROPERTIES(amxArgs PROPERTIES PREFIX "")
|
||||
IF(WIN32)
|
||||
SET(ARGS_SRCS ${ARGS_SRCS} dllmain.c amxargs.rc)
|
||||
IF(BORLAND)
|
||||
# Borland linker uses a DEF file if one is in the output directory
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/amxargs.def ${CMAKE_BINARY_DIR}/amxargs.def COPY_ONLY)
|
||||
ELSE(BORLAND)
|
||||
# For Microsoft Visual C/C++ we can set explicit flags for exports
|
||||
SET_TARGET_PROPERTIES(amxArgs PROPERTIES LINK_FLAGS "/export:amx_ArgsInit /export:amx_ArgsCleanup /export:amx_ArgsSetCmdLine")
|
||||
ENDIF(BORLAND)
|
||||
ENDIF(WIN32)
|
||||
IF(UNIX)
|
||||
ADD_CUSTOM_COMMAND(TARGET amxArgs POST_BUILD COMMAND strip ARGS -K amx_ArgsInit -K amx_ArgsCleanup -K amx_ArgsSetCmdLine ${CMAKE_BINARY_DIR}/amxArgs.so)
|
||||
ENDIF(UNIX)
|
||||
|
||||
# amxDGram
|
||||
SET(DGRAM_SRCS amxdgram.c amx.c)
|
||||
ADD_LIBRARY(amxDGram SHARED ${DGRAM_SRCS})
|
||||
SET_TARGET_PROPERTIES(amxDGram PROPERTIES PREFIX "")
|
||||
IF(WIN32)
|
||||
SET(DGRAM_SRCS ${DGRAM_SRCS} dllmain.c amxargs.rc)
|
||||
IF(BORLAND)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/amxdgram.def ${CMAKE_BINARY_DIR}/amxdgram.def COPY_ONLY)
|
||||
ELSE(BORLAND)
|
||||
SET_TARGET_PROPERTIES(amxDGram PROPERTIES LINK_FLAGS "/export:amx_DGramInit /export:amx_DGramCleanup")
|
||||
ENDIF(BORLAND)
|
||||
ENDIF(WIN32)
|
||||
IF(UNIX)
|
||||
ADD_CUSTOM_COMMAND(TARGET amxDGram POST_BUILD COMMAND strip ARGS -K amx_DGramInit -K amx_DGramCleanup ${CMAKE_BINARY_DIR}/amxDGram.so)
|
||||
ENDIF(UNIX)
|
||||
|
||||
# amxFile
|
||||
SET(FILE_SRCS amxfile.c amx.c)
|
||||
ADD_LIBRARY(amxFile SHARED ${FILE_SRCS})
|
||||
SET_TARGET_PROPERTIES(amxFile PROPERTIES PREFIX "")
|
||||
IF(WIN32)
|
||||
SET(FILE_SRCS ${FILE_SRCS} dllmain.c amxfile.rc)
|
||||
IF(BORLAND)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/amxfile.def ${CMAKE_BINARY_DIR}/amxfile.def COPY_ONLY)
|
||||
ELSE(BORLAND)
|
||||
SET_TARGET_PROPERTIES(amxFile PROPERTIES LINK_FLAGS "/export:amx_FileInit /export:amx_FileCleanup")
|
||||
ENDIF(BORLAND)
|
||||
ENDIF(WIN32)
|
||||
IF(UNIX)
|
||||
ADD_CUSTOM_COMMAND(TARGET amxFile POST_BUILD COMMAND strip ARGS -K amx_FileInit -K amx_FileCleanup ${CMAKE_BINARY_DIR}/amxFile.so)
|
||||
ENDIF(UNIX)
|
||||
|
||||
# amxFixed
|
||||
SET(FIXED_SRCS fixed.c amx.c)
|
||||
ADD_LIBRARY(amxFixed SHARED ${FIXED_SRCS})
|
||||
SET_TARGET_PROPERTIES(amxFixed PROPERTIES PREFIX "")
|
||||
IF(WIN32)
|
||||
SET(FIXED_SRCS ${FIXED_SRCS} dllmain.c amxfixed.rc)
|
||||
IF(BORLAND)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/amxfixed.def ${CMAKE_BINARY_DIR}/amxfixed.def COPY_ONLY)
|
||||
ELSE(BORLAND)
|
||||
SET_TARGET_PROPERTIES(amxFixed PROPERTIES LINK_FLAGS "/export:amx_FixedInit /export:amx_FixedCleanup")
|
||||
ENDIF(BORLAND)
|
||||
ENDIF(WIN32)
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(amxFixed m)
|
||||
ADD_CUSTOM_COMMAND(TARGET amxFixed POST_BUILD COMMAND strip ARGS -K amx_FixedInit -K amx_FixedCleanup ${CMAKE_BINARY_DIR}/amxFixed.so)
|
||||
ENDIF(UNIX)
|
||||
|
||||
# amxFloat
|
||||
SET(FLOAT_SRCS float.c amx.c)
|
||||
ADD_LIBRARY(amxFloat SHARED ${FLOAT_SRCS})
|
||||
SET_TARGET_PROPERTIES(amxFloat PROPERTIES PREFIX "")
|
||||
IF(WIN32)
|
||||
SET(FLOAT_SRCS ${FLOAT_SRCS} dllmain.c amxfloat.rc)
|
||||
IF(BORLAND)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/amxfloat.def ${CMAKE_BINARY_DIR}/amxfloat.def COPY_ONLY)
|
||||
ELSE(BORLAND)
|
||||
SET_TARGET_PROPERTIES(amxFloat PROPERTIES LINK_FLAGS "/export:amx_FloatInit /export:amx_FloatCleanup")
|
||||
ENDIF(BORLAND)
|
||||
ENDIF(WIN32)
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(amxFloat m)
|
||||
ADD_CUSTOM_COMMAND(TARGET amxFloat POST_BUILD COMMAND strip ARGS -K amx_FloatInit -K amx_FloatInit ${CMAKE_BINARY_DIR}/amxFloat.so)
|
||||
ENDIF(UNIX)
|
||||
|
||||
# amxProcess
|
||||
SET(PROCESS_SRCS amxprocess.c amx.c)
|
||||
IF(WIN32)
|
||||
ADD_LIBRARY(amxProcess SHARED ${PROCESS_SRCS})
|
||||
ELSE(WIN32)
|
||||
IF(HAVE_FFI_H)
|
||||
ADD_LIBRARY(amxProcess SHARED ${PROCESS_SRCS})
|
||||
ELSE(HAVE_FFI_H)
|
||||
MESSAGE(SEND_ERROR "amxProcess requires libffi; see http://sources.redhat.com/libffi/")
|
||||
MESSAGE(SEND_ERROR "libffi is not available (foreign function interface)")
|
||||
ENDIF(HAVE_FFI_H)
|
||||
ENDIF(WIN32)
|
||||
SET_TARGET_PROPERTIES(amxProcess PROPERTIES PREFIX "")
|
||||
IF(WIN32)
|
||||
SET(PROCESS_SRCS ${PROCESS_SRCS} dllmain.c amxprocess.rc)
|
||||
IF(BORLAND)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/amxprocess.def ${CMAKE_BINARY_DIR}/amxprocess.def COPY_ONLY)
|
||||
ELSE(BORLAND)
|
||||
SET_TARGET_PROPERTIES(amxProcess PROPERTIES LINK_FLAGS "/export:amx_ProcessInit /export:amx_ProcessCleanup")
|
||||
ENDIF(BORLAND)
|
||||
ENDIF(WIN32)
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(amxProcess dl)
|
||||
ADD_CUSTOM_COMMAND(TARGET amxProcess POST_BUILD COMMAND strip ARGS -K amx_ProcessInit -K amx_ProcessCleanup ${CMAKE_BINARY_DIR}/amxProcess.so)
|
||||
ENDIF(UNIX)
|
||||
|
||||
# amxString
|
||||
SET(STRING_SRCS amxstring.c amx.c amxcons.c)
|
||||
ADD_LIBRARY(amxString SHARED ${STRING_SRCS})
|
||||
SET_TARGET_PROPERTIES(amxString PROPERTIES PREFIX "")
|
||||
IF(WIN32)
|
||||
SET(STRING_SRCS ${STRING_SRCS} dllmain.c amxstring.rc)
|
||||
IF(BORLAND)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/amxstring.def ${CMAKE_BINARY_DIR}/amxstring.def COPY_ONLY)
|
||||
ELSE(BORLAND)
|
||||
SET_TARGET_PROPERTIES(amxString PROPERTIES LINK_FLAGS "/export:amx_StringInit /export:amx_StringCleanup")
|
||||
ENDIF(BORLAND)
|
||||
ENDIF(WIN32)
|
||||
IF(UNIX)
|
||||
ADD_CUSTOM_COMMAND(TARGET amxString POST_BUILD COMMAND strip ARGS -K amx_StringInit -K amx_StringCleanup ${CMAKE_BINARY_DIR}/amxString.so)
|
||||
ENDIF(UNIX)
|
||||
|
||||
# amxTime
|
||||
SET(TIME_SRCS amxtime.c amx.c)
|
||||
ADD_LIBRARY(amxTime SHARED ${TIME_SRCS})
|
||||
SET_TARGET_PROPERTIES(amxTime PROPERTIES PREFIX "")
|
||||
IF(WIN32)
|
||||
SET(TIME_SRCS ${TIME_SRCS} dllmain.c amxtime.rc)
|
||||
IF(BORLAND)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/amxtime.def ${CMAKE_BINARY_DIR}/amxtime.def COPY_ONLY)
|
||||
ELSE(BORLAND)
|
||||
SET_TARGET_PROPERTIES(amxTime PROPERTIES LINK_FLAGS "/export:amx_TimeInit /export:amx_TimeCleanup")
|
||||
ENDIF(BORLAND)
|
||||
ENDIF(WIN32)
|
||||
IF(UNIX)
|
||||
ADD_CUSTOM_COMMAND(TARGET amxTime POST_BUILD COMMAND strip ARGS -K amx_TimeInit -K amx_TimeCleanup ${CMAKE_BINARY_DIR}/amxTime.so)
|
||||
ENDIF(UNIX)
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Simple run-time (example program)
|
||||
|
||||
SET(PAWNRUN_SRCS pawnrun.c amx.c amxcore.c amxcons.c amxdbg.c)
|
||||
IF (UNIX)
|
||||
SET(PAWNRUN_SRCS ${PAWNRUN_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/../linux/getch.c ${CMAKE_CURRENT_SOURCE_DIR}/../linux/binreloc.c)
|
||||
ENDIF (UNIX)
|
||||
ADD_EXECUTABLE(pawnrun ${PAWNRUN_SRCS})
|
||||
SET_TARGET_PROPERTIES(pawnrun PROPERTIES COMPILE_FLAGS -DAMXDBG COMPILE_FLAGS -DENABLE_BINRELOC)
|
||||
IF (UNIX)
|
||||
TARGET_LINK_LIBRARIES(pawnrun dl)
|
||||
ENDIF (UNIX)
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Simple console debugger
|
||||
|
||||
SET(PAWNDBG_SRCS pawndbg.c amx.c amxcore.c amxcons.c amxdbg.c)
|
||||
IF (UNIX)
|
||||
SET(PAWNDBG_SRCS ${PAWNDBG_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/../linux/getch.c ${CMAKE_CURRENT_SOURCE_DIR}/../linux/binreloc.c)
|
||||
ENDIF (UNIX)
|
||||
ADD_EXECUTABLE(pawndbg ${PAWNDBG_SRCS})
|
||||
SET_TARGET_PROPERTIES(pawndbg PROPERTIES COMPILE_FLAGS -DENABLE_BINRELOC)
|
||||
IF (UNIX)
|
||||
TARGET_LINK_LIBRARIES(pawndbg dl)
|
||||
ENDIF (UNIX)
|
||||
#build file for CMake, see http://www.cmake.org/
|
||||
|
||||
PROJECT(pawnamx)
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||
|
||||
# check for optional include files
|
||||
INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
|
||||
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
|
||||
IF(HAVE_UNISTD_H)
|
||||
ADD_DEFINITIONS(-DHAVE_UNISTD_H)
|
||||
ENDIF(HAVE_UNISTD_H)
|
||||
CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H)
|
||||
IF(HAVE_INTTYPES_H)
|
||||
ADD_DEFINITIONS(-DHAVE_INTTYPES_H)
|
||||
ENDIF(HAVE_INTTYPES_H)
|
||||
CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
|
||||
IF(HAVE_STDINT_H)
|
||||
ADD_DEFINITIONS(-DHAVE_STDINT_H)
|
||||
ENDIF(HAVE_STDINT_H)
|
||||
CHECK_INCLUDE_FILE("alloca.h" HAVE_ALLOCA_H)
|
||||
IF(HAVE_ALLOCA_H)
|
||||
ADD_DEFINITIONS(-DHAVE_ALLOCA_H)
|
||||
ENDIF(HAVE_ALLOCA_H)
|
||||
|
||||
ADD_DEFINITIONS(-DFLOATPOINT -DFIXEDPOINT)
|
||||
IF (UNIX)
|
||||
ADD_DEFINITIONS(-DLINUX)
|
||||
CHECK_INCLUDE_FILE("ffi.h" HAVE_FFI_H)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../linux)
|
||||
ENDIF (UNIX)
|
||||
IF(WIN32)
|
||||
ADD_DEFINITIONS(-DAMXEXPORT=__stdcall -DAMX_NATIVE_CALL=__stdcall -DSTDECL)
|
||||
IF(NOT BORLAND)
|
||||
LINK_LIBRARIES(winmm)
|
||||
ENDIF(NOT BORLAND)
|
||||
ENDIF(WIN32)
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Extension modules
|
||||
|
||||
# amxArgs
|
||||
SET(ARGS_SRCS amxargs.c amx.c)
|
||||
ADD_LIBRARY(amxArgs SHARED ${ARGS_SRCS})
|
||||
SET_TARGET_PROPERTIES(amxArgs PROPERTIES PREFIX "")
|
||||
IF(WIN32)
|
||||
SET(ARGS_SRCS ${ARGS_SRCS} dllmain.c amxargs.rc)
|
||||
IF(BORLAND)
|
||||
# Borland linker uses a DEF file if one is in the output directory
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/amxargs.def ${CMAKE_BINARY_DIR}/amxargs.def COPY_ONLY)
|
||||
ELSE(BORLAND)
|
||||
# For Microsoft Visual C/C++ we can set explicit flags for exports
|
||||
SET_TARGET_PROPERTIES(amxArgs PROPERTIES LINK_FLAGS "/export:amx_ArgsInit /export:amx_ArgsCleanup /export:amx_ArgsSetCmdLine")
|
||||
ENDIF(BORLAND)
|
||||
ENDIF(WIN32)
|
||||
IF(UNIX)
|
||||
ADD_CUSTOM_COMMAND(TARGET amxArgs POST_BUILD COMMAND strip ARGS -K amx_ArgsInit -K amx_ArgsCleanup -K amx_ArgsSetCmdLine ${CMAKE_BINARY_DIR}/amxArgs.so)
|
||||
ENDIF(UNIX)
|
||||
|
||||
# amxDGram
|
||||
SET(DGRAM_SRCS amxdgram.c amx.c)
|
||||
ADD_LIBRARY(amxDGram SHARED ${DGRAM_SRCS})
|
||||
SET_TARGET_PROPERTIES(amxDGram PROPERTIES PREFIX "")
|
||||
IF(WIN32)
|
||||
SET(DGRAM_SRCS ${DGRAM_SRCS} dllmain.c amxargs.rc)
|
||||
IF(BORLAND)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/amxdgram.def ${CMAKE_BINARY_DIR}/amxdgram.def COPY_ONLY)
|
||||
ELSE(BORLAND)
|
||||
SET_TARGET_PROPERTIES(amxDGram PROPERTIES LINK_FLAGS "/export:amx_DGramInit /export:amx_DGramCleanup")
|
||||
ENDIF(BORLAND)
|
||||
ENDIF(WIN32)
|
||||
IF(UNIX)
|
||||
ADD_CUSTOM_COMMAND(TARGET amxDGram POST_BUILD COMMAND strip ARGS -K amx_DGramInit -K amx_DGramCleanup ${CMAKE_BINARY_DIR}/amxDGram.so)
|
||||
ENDIF(UNIX)
|
||||
|
||||
# amxFile
|
||||
SET(FILE_SRCS amxfile.c amx.c)
|
||||
ADD_LIBRARY(amxFile SHARED ${FILE_SRCS})
|
||||
SET_TARGET_PROPERTIES(amxFile PROPERTIES PREFIX "")
|
||||
IF(WIN32)
|
||||
SET(FILE_SRCS ${FILE_SRCS} dllmain.c amxfile.rc)
|
||||
IF(BORLAND)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/amxfile.def ${CMAKE_BINARY_DIR}/amxfile.def COPY_ONLY)
|
||||
ELSE(BORLAND)
|
||||
SET_TARGET_PROPERTIES(amxFile PROPERTIES LINK_FLAGS "/export:amx_FileInit /export:amx_FileCleanup")
|
||||
ENDIF(BORLAND)
|
||||
ENDIF(WIN32)
|
||||
IF(UNIX)
|
||||
ADD_CUSTOM_COMMAND(TARGET amxFile POST_BUILD COMMAND strip ARGS -K amx_FileInit -K amx_FileCleanup ${CMAKE_BINARY_DIR}/amxFile.so)
|
||||
ENDIF(UNIX)
|
||||
|
||||
# amxFixed
|
||||
SET(FIXED_SRCS fixed.c amx.c)
|
||||
ADD_LIBRARY(amxFixed SHARED ${FIXED_SRCS})
|
||||
SET_TARGET_PROPERTIES(amxFixed PROPERTIES PREFIX "")
|
||||
IF(WIN32)
|
||||
SET(FIXED_SRCS ${FIXED_SRCS} dllmain.c amxfixed.rc)
|
||||
IF(BORLAND)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/amxfixed.def ${CMAKE_BINARY_DIR}/amxfixed.def COPY_ONLY)
|
||||
ELSE(BORLAND)
|
||||
SET_TARGET_PROPERTIES(amxFixed PROPERTIES LINK_FLAGS "/export:amx_FixedInit /export:amx_FixedCleanup")
|
||||
ENDIF(BORLAND)
|
||||
ENDIF(WIN32)
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(amxFixed m)
|
||||
ADD_CUSTOM_COMMAND(TARGET amxFixed POST_BUILD COMMAND strip ARGS -K amx_FixedInit -K amx_FixedCleanup ${CMAKE_BINARY_DIR}/amxFixed.so)
|
||||
ENDIF(UNIX)
|
||||
|
||||
# amxFloat
|
||||
SET(FLOAT_SRCS float.c amx.c)
|
||||
ADD_LIBRARY(amxFloat SHARED ${FLOAT_SRCS})
|
||||
SET_TARGET_PROPERTIES(amxFloat PROPERTIES PREFIX "")
|
||||
IF(WIN32)
|
||||
SET(FLOAT_SRCS ${FLOAT_SRCS} dllmain.c amxfloat.rc)
|
||||
IF(BORLAND)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/amxfloat.def ${CMAKE_BINARY_DIR}/amxfloat.def COPY_ONLY)
|
||||
ELSE(BORLAND)
|
||||
SET_TARGET_PROPERTIES(amxFloat PROPERTIES LINK_FLAGS "/export:amx_FloatInit /export:amx_FloatCleanup")
|
||||
ENDIF(BORLAND)
|
||||
ENDIF(WIN32)
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(amxFloat m)
|
||||
ADD_CUSTOM_COMMAND(TARGET amxFloat POST_BUILD COMMAND strip ARGS -K amx_FloatInit -K amx_FloatInit ${CMAKE_BINARY_DIR}/amxFloat.so)
|
||||
ENDIF(UNIX)
|
||||
|
||||
# amxProcess
|
||||
SET(PROCESS_SRCS amxprocess.c amx.c)
|
||||
IF(WIN32)
|
||||
ADD_LIBRARY(amxProcess SHARED ${PROCESS_SRCS})
|
||||
ELSE(WIN32)
|
||||
IF(HAVE_FFI_H)
|
||||
ADD_LIBRARY(amxProcess SHARED ${PROCESS_SRCS})
|
||||
ELSE(HAVE_FFI_H)
|
||||
MESSAGE(SEND_ERROR "amxProcess requires libffi; see http://sources.redhat.com/libffi/")
|
||||
MESSAGE(SEND_ERROR "libffi is not available (foreign function interface)")
|
||||
ENDIF(HAVE_FFI_H)
|
||||
ENDIF(WIN32)
|
||||
SET_TARGET_PROPERTIES(amxProcess PROPERTIES PREFIX "")
|
||||
IF(WIN32)
|
||||
SET(PROCESS_SRCS ${PROCESS_SRCS} dllmain.c amxprocess.rc)
|
||||
IF(BORLAND)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/amxprocess.def ${CMAKE_BINARY_DIR}/amxprocess.def COPY_ONLY)
|
||||
ELSE(BORLAND)
|
||||
SET_TARGET_PROPERTIES(amxProcess PROPERTIES LINK_FLAGS "/export:amx_ProcessInit /export:amx_ProcessCleanup")
|
||||
ENDIF(BORLAND)
|
||||
ENDIF(WIN32)
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(amxProcess dl)
|
||||
ADD_CUSTOM_COMMAND(TARGET amxProcess POST_BUILD COMMAND strip ARGS -K amx_ProcessInit -K amx_ProcessCleanup ${CMAKE_BINARY_DIR}/amxProcess.so)
|
||||
ENDIF(UNIX)
|
||||
|
||||
# amxString
|
||||
SET(STRING_SRCS amxstring.c amx.c amxcons.c)
|
||||
ADD_LIBRARY(amxString SHARED ${STRING_SRCS})
|
||||
SET_TARGET_PROPERTIES(amxString PROPERTIES PREFIX "")
|
||||
IF(WIN32)
|
||||
SET(STRING_SRCS ${STRING_SRCS} dllmain.c amxstring.rc)
|
||||
IF(BORLAND)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/amxstring.def ${CMAKE_BINARY_DIR}/amxstring.def COPY_ONLY)
|
||||
ELSE(BORLAND)
|
||||
SET_TARGET_PROPERTIES(amxString PROPERTIES LINK_FLAGS "/export:amx_StringInit /export:amx_StringCleanup")
|
||||
ENDIF(BORLAND)
|
||||
ENDIF(WIN32)
|
||||
IF(UNIX)
|
||||
ADD_CUSTOM_COMMAND(TARGET amxString POST_BUILD COMMAND strip ARGS -K amx_StringInit -K amx_StringCleanup ${CMAKE_BINARY_DIR}/amxString.so)
|
||||
ENDIF(UNIX)
|
||||
|
||||
# amxTime
|
||||
SET(TIME_SRCS amxtime.c amx.c)
|
||||
ADD_LIBRARY(amxTime SHARED ${TIME_SRCS})
|
||||
SET_TARGET_PROPERTIES(amxTime PROPERTIES PREFIX "")
|
||||
IF(WIN32)
|
||||
SET(TIME_SRCS ${TIME_SRCS} dllmain.c amxtime.rc)
|
||||
IF(BORLAND)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/amxtime.def ${CMAKE_BINARY_DIR}/amxtime.def COPY_ONLY)
|
||||
ELSE(BORLAND)
|
||||
SET_TARGET_PROPERTIES(amxTime PROPERTIES LINK_FLAGS "/export:amx_TimeInit /export:amx_TimeCleanup")
|
||||
ENDIF(BORLAND)
|
||||
ENDIF(WIN32)
|
||||
IF(UNIX)
|
||||
ADD_CUSTOM_COMMAND(TARGET amxTime POST_BUILD COMMAND strip ARGS -K amx_TimeInit -K amx_TimeCleanup ${CMAKE_BINARY_DIR}/amxTime.so)
|
||||
ENDIF(UNIX)
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Simple run-time (example program)
|
||||
|
||||
SET(PAWNRUN_SRCS pawnrun.c amx.c amxcore.c amxcons.c amxdbg.c)
|
||||
IF (UNIX)
|
||||
SET(PAWNRUN_SRCS ${PAWNRUN_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/../linux/getch.c ${CMAKE_CURRENT_SOURCE_DIR}/../linux/binreloc.c)
|
||||
ENDIF (UNIX)
|
||||
ADD_EXECUTABLE(pawnrun ${PAWNRUN_SRCS})
|
||||
SET_TARGET_PROPERTIES(pawnrun PROPERTIES COMPILE_FLAGS -DAMXDBG COMPILE_FLAGS -DENABLE_BINRELOC)
|
||||
IF (UNIX)
|
||||
TARGET_LINK_LIBRARIES(pawnrun dl)
|
||||
ENDIF (UNIX)
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Simple console debugger
|
||||
|
||||
SET(PAWNDBG_SRCS pawndbg.c amx.c amxcore.c amxcons.c amxdbg.c)
|
||||
IF (UNIX)
|
||||
SET(PAWNDBG_SRCS ${PAWNDBG_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/../linux/getch.c ${CMAKE_CURRENT_SOURCE_DIR}/../linux/binreloc.c)
|
||||
ENDIF (UNIX)
|
||||
ADD_EXECUTABLE(pawndbg ${PAWNDBG_SRCS})
|
||||
SET_TARGET_PROPERTIES(pawndbg PROPERTIES COMPILE_FLAGS -DENABLE_BINRELOC)
|
||||
IF (UNIX)
|
||||
TARGET_LINK_LIBRARIES(pawndbg dl)
|
||||
ENDIF (UNIX)
|
||||
|
@ -1,6 +1,6 @@
|
||||
NAME amxDGram
|
||||
DESCRIPTION 'Pawn AMX: network datagram'
|
||||
|
||||
EXPORTS
|
||||
amx_DGramInit
|
||||
amx_DGramCleanup
|
||||
NAME amxDGram
|
||||
DESCRIPTION 'Pawn AMX: network datagram'
|
||||
|
||||
EXPORTS
|
||||
amx_DGramInit
|
||||
amx_DGramCleanup
|
||||
|
@ -1,54 +1,54 @@
|
||||
#include <windows.h>
|
||||
#if defined WIN32 || defined _WIN32 || defined __WIN32__
|
||||
# include <winver.h>
|
||||
#else
|
||||
# include <ver.h>
|
||||
#endif
|
||||
|
||||
/* Version information
|
||||
*
|
||||
* All strings MUST have an explicit \0. See the Windows SDK documentation
|
||||
* for details on version information and the VERSIONINFO structure.
|
||||
*/
|
||||
#define VERSION 1
|
||||
#define REVISION 0
|
||||
#define BUILD 0
|
||||
#define VERSIONSTR "1.0.0\0"
|
||||
#define VERSIONNAME "amxDGram.dll\0"
|
||||
#define VERSIONDESCRIPTION "Pawn AMX: network datagram\0"
|
||||
#define VERSIONCOMPANYNAME "ITB CompuPhase\0"
|
||||
#define VERSIONPRODUCTNAME "amxDGram\0"
|
||||
#define VERSIONCOPYRIGHT "Copyright \251 2006 ITB CompuPhase\0"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VERSION, REVISION, BUILD, 0
|
||||
PRODUCTVERSION VERSION, REVISION, BUILD, 0
|
||||
FILEFLAGSMASK 0x0000003FL
|
||||
FILEFLAGS 0
|
||||
#if defined(WIN32)
|
||||
FILEOS VOS__WINDOWS32
|
||||
#else
|
||||
FILEOS VOS__WINDOWS16
|
||||
#endif
|
||||
FILETYPE VFT_DLL
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", VERSIONCOMPANYNAME
|
||||
VALUE "FileDescription", VERSIONDESCRIPTION
|
||||
VALUE "FileVersion", VERSIONSTR
|
||||
VALUE "InternalName", VERSIONNAME
|
||||
VALUE "LegalCopyright", VERSIONCOPYRIGHT
|
||||
VALUE "OriginalFilename", VERSIONNAME
|
||||
VALUE "ProductName", VERSIONPRODUCTNAME
|
||||
VALUE "ProductVersion", VERSIONSTR
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
#include <windows.h>
|
||||
#if defined WIN32 || defined _WIN32 || defined __WIN32__
|
||||
# include <winver.h>
|
||||
#else
|
||||
# include <ver.h>
|
||||
#endif
|
||||
|
||||
/* Version information
|
||||
*
|
||||
* All strings MUST have an explicit \0. See the Windows SDK documentation
|
||||
* for details on version information and the VERSIONINFO structure.
|
||||
*/
|
||||
#define VERSION 1
|
||||
#define REVISION 0
|
||||
#define BUILD 0
|
||||
#define VERSIONSTR "1.0.0\0"
|
||||
#define VERSIONNAME "amxDGram.dll\0"
|
||||
#define VERSIONDESCRIPTION "Pawn AMX: network datagram\0"
|
||||
#define VERSIONCOMPANYNAME "ITB CompuPhase\0"
|
||||
#define VERSIONPRODUCTNAME "amxDGram\0"
|
||||
#define VERSIONCOPYRIGHT "Copyright \251 2006 ITB CompuPhase\0"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VERSION, REVISION, BUILD, 0
|
||||
PRODUCTVERSION VERSION, REVISION, BUILD, 0
|
||||
FILEFLAGSMASK 0x0000003FL
|
||||
FILEFLAGS 0
|
||||
#if defined(WIN32)
|
||||
FILEOS VOS__WINDOWS32
|
||||
#else
|
||||
FILEOS VOS__WINDOWS16
|
||||
#endif
|
||||
FILETYPE VFT_DLL
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", VERSIONCOMPANYNAME
|
||||
VALUE "FileDescription", VERSIONDESCRIPTION
|
||||
VALUE "FileVersion", VERSIONSTR
|
||||
VALUE "InternalName", VERSIONNAME
|
||||
VALUE "LegalCopyright", VERSIONCOPYRIGHT
|
||||
VALUE "OriginalFilename", VERSIONNAME
|
||||
VALUE "ProductName", VERSIONPRODUCTNAME
|
||||
VALUE "ProductVersion", VERSIONSTR
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
|
@ -1,54 +1,54 @@
|
||||
#include <windows.h>
|
||||
#if defined WIN32 || defined _WIN32 || defined __WIN32__
|
||||
# include <winver.h>
|
||||
#else
|
||||
# include <ver.h>
|
||||
#endif
|
||||
|
||||
/* Version information
|
||||
*
|
||||
* All strings MUST have an explicit \0. See the Windows SDK documentation
|
||||
* for details on version information and the VERSIONINFO structure.
|
||||
*/
|
||||
#define VERSION 1
|
||||
#define REVISION 1
|
||||
#define BUILD 0
|
||||
#define VERSIONSTR "1.1.0\0"
|
||||
#define VERSIONNAME "amxFile.dll\0"
|
||||
#define VERSIONDESCRIPTION "Pawn AMX: File I/O support\0"
|
||||
#define VERSIONCOMPANYNAME "ITB CompuPhase\0"
|
||||
#define VERSIONPRODUCTNAME "amxFile\0"
|
||||
#define VERSIONCOPYRIGHT "Copyright \251 2004-2006 ITB CompuPhase\0"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VERSION, REVISION, BUILD, 0
|
||||
PRODUCTVERSION VERSION, REVISION, BUILD, 0
|
||||
FILEFLAGSMASK 0x0000003FL
|
||||
FILEFLAGS 0
|
||||
#if defined(WIN32)
|
||||
FILEOS VOS__WINDOWS32
|
||||
#else
|
||||
FILEOS VOS__WINDOWS16
|
||||
#endif
|
||||
FILETYPE VFT_DLL
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", VERSIONCOMPANYNAME
|
||||
VALUE "FileDescription", VERSIONDESCRIPTION
|
||||
VALUE "FileVersion", VERSIONSTR
|
||||
VALUE "InternalName", VERSIONNAME
|
||||
VALUE "LegalCopyright", VERSIONCOPYRIGHT
|
||||
VALUE "OriginalFilename", VERSIONNAME
|
||||
VALUE "ProductName", VERSIONPRODUCTNAME
|
||||
VALUE "ProductVersion", VERSIONSTR
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
#include <windows.h>
|
||||
#if defined WIN32 || defined _WIN32 || defined __WIN32__
|
||||
# include <winver.h>
|
||||
#else
|
||||
# include <ver.h>
|
||||
#endif
|
||||
|
||||
/* Version information
|
||||
*
|
||||
* All strings MUST have an explicit \0. See the Windows SDK documentation
|
||||
* for details on version information and the VERSIONINFO structure.
|
||||
*/
|
||||
#define VERSION 1
|
||||
#define REVISION 1
|
||||
#define BUILD 0
|
||||
#define VERSIONSTR "1.1.0\0"
|
||||
#define VERSIONNAME "amxFile.dll\0"
|
||||
#define VERSIONDESCRIPTION "Pawn AMX: File I/O support\0"
|
||||
#define VERSIONCOMPANYNAME "ITB CompuPhase\0"
|
||||
#define VERSIONPRODUCTNAME "amxFile\0"
|
||||
#define VERSIONCOPYRIGHT "Copyright \251 2004-2006 ITB CompuPhase\0"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VERSION, REVISION, BUILD, 0
|
||||
PRODUCTVERSION VERSION, REVISION, BUILD, 0
|
||||
FILEFLAGSMASK 0x0000003FL
|
||||
FILEFLAGS 0
|
||||
#if defined(WIN32)
|
||||
FILEOS VOS__WINDOWS32
|
||||
#else
|
||||
FILEOS VOS__WINDOWS16
|
||||
#endif
|
||||
FILETYPE VFT_DLL
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", VERSIONCOMPANYNAME
|
||||
VALUE "FileDescription", VERSIONDESCRIPTION
|
||||
VALUE "FileVersion", VERSIONSTR
|
||||
VALUE "InternalName", VERSIONNAME
|
||||
VALUE "LegalCopyright", VERSIONCOPYRIGHT
|
||||
VALUE "OriginalFilename", VERSIONNAME
|
||||
VALUE "ProductName", VERSIONPRODUCTNAME
|
||||
VALUE "ProductVersion", VERSIONSTR
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
|
@ -1,6 +1,6 @@
|
||||
NAME amxFixed
|
||||
DESCRIPTION 'Pawn AMX: fixed-point arithmetic'
|
||||
|
||||
EXPORTS
|
||||
amx_FixedInit
|
||||
amx_FixedCleanup
|
||||
NAME amxFixed
|
||||
DESCRIPTION 'Pawn AMX: fixed-point arithmetic'
|
||||
|
||||
EXPORTS
|
||||
amx_FixedInit
|
||||
amx_FixedCleanup
|
||||
|
@ -1,54 +1,54 @@
|
||||
#include <windows.h>
|
||||
#if defined WIN32 || defined _WIN32 || defined __WIN32__
|
||||
# include <winver.h>
|
||||
#else
|
||||
# include <ver.h>
|
||||
#endif
|
||||
|
||||
/* Version information
|
||||
*
|
||||
* All strings MUST have an explicit \0. See the Windows SDK documentation
|
||||
* for details on version information and the VERSIONINFO structure.
|
||||
*/
|
||||
#define VERSION 1
|
||||
#define REVISION 0
|
||||
#define BUILD 0
|
||||
#define VERSIONSTR "1.0.0\0"
|
||||
#define VERSIONNAME "amxFixed.dll\0"
|
||||
#define VERSIONDESCRIPTION "Pawn AMX: Fixed Point support\0"
|
||||
#define VERSIONCOMPANYNAME "ITB CompuPhase\0"
|
||||
#define VERSIONPRODUCTNAME "amxFixed\0"
|
||||
#define VERSIONCOPYRIGHT "Copyright \251 2003-2006 ITB CompuPhase\0"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VERSION, REVISION, BUILD, 0
|
||||
PRODUCTVERSION VERSION, REVISION, BUILD, 0
|
||||
FILEFLAGSMASK 0x0000003FL
|
||||
FILEFLAGS 0
|
||||
#if defined(WIN32)
|
||||
FILEOS VOS__WINDOWS32
|
||||
#else
|
||||
FILEOS VOS__WINDOWS16
|
||||
#endif
|
||||
FILETYPE VFT_DLL
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", VERSIONCOMPANYNAME
|
||||
VALUE "FileDescription", VERSIONDESCRIPTION
|
||||
VALUE "FileVersion", VERSIONSTR
|
||||
VALUE "InternalName", VERSIONNAME
|
||||
VALUE "LegalCopyright", VERSIONCOPYRIGHT
|
||||
VALUE "OriginalFilename", VERSIONNAME
|
||||
VALUE "ProductName", VERSIONPRODUCTNAME
|
||||
VALUE "ProductVersion", VERSIONSTR
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
#include <windows.h>
|
||||
#if defined WIN32 || defined _WIN32 || defined __WIN32__
|
||||
# include <winver.h>
|
||||
#else
|
||||
# include <ver.h>
|
||||
#endif
|
||||
|
||||
/* Version information
|
||||
*
|
||||
* All strings MUST have an explicit \0. See the Windows SDK documentation
|
||||
* for details on version information and the VERSIONINFO structure.
|
||||
*/
|
||||
#define VERSION 1
|
||||
#define REVISION 0
|
||||
#define BUILD 0
|
||||
#define VERSIONSTR "1.0.0\0"
|
||||
#define VERSIONNAME "amxFixed.dll\0"
|
||||
#define VERSIONDESCRIPTION "Pawn AMX: Fixed Point support\0"
|
||||
#define VERSIONCOMPANYNAME "ITB CompuPhase\0"
|
||||
#define VERSIONPRODUCTNAME "amxFixed\0"
|
||||
#define VERSIONCOPYRIGHT "Copyright \251 2003-2006 ITB CompuPhase\0"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VERSION, REVISION, BUILD, 0
|
||||
PRODUCTVERSION VERSION, REVISION, BUILD, 0
|
||||
FILEFLAGSMASK 0x0000003FL
|
||||
FILEFLAGS 0
|
||||
#if defined(WIN32)
|
||||
FILEOS VOS__WINDOWS32
|
||||
#else
|
||||
FILEOS VOS__WINDOWS16
|
||||
#endif
|
||||
FILETYPE VFT_DLL
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", VERSIONCOMPANYNAME
|
||||
VALUE "FileDescription", VERSIONDESCRIPTION
|
||||
VALUE "FileVersion", VERSIONSTR
|
||||
VALUE "InternalName", VERSIONNAME
|
||||
VALUE "LegalCopyright", VERSIONCOPYRIGHT
|
||||
VALUE "OriginalFilename", VERSIONNAME
|
||||
VALUE "ProductName", VERSIONPRODUCTNAME
|
||||
VALUE "ProductVersion", VERSIONSTR
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
|
@ -1,6 +1,6 @@
|
||||
NAME amxFloat
|
||||
DESCRIPTION 'Pawn AMX: floating-point arithmetic'
|
||||
|
||||
EXPORTS
|
||||
amx_FloatInit
|
||||
amx_FloatCleanup
|
||||
NAME amxFloat
|
||||
DESCRIPTION 'Pawn AMX: floating-point arithmetic'
|
||||
|
||||
EXPORTS
|
||||
amx_FloatInit
|
||||
amx_FloatCleanup
|
||||
|
@ -1,54 +1,54 @@
|
||||
#include <windows.h>
|
||||
#if defined WIN32 || defined _WIN32 || defined __WIN32__
|
||||
# include <winver.h>
|
||||
#else
|
||||
# include <ver.h>
|
||||
#endif
|
||||
|
||||
/* Version information
|
||||
*
|
||||
* All strings MUST have an explicit \0. See the Windows SDK documentation
|
||||
* for details on version information and the VERSIONINFO structure.
|
||||
*/
|
||||
#define VERSION 1
|
||||
#define REVISION 0
|
||||
#define BUILD 0
|
||||
#define VERSIONSTR "1.0.0\0"
|
||||
#define VERSIONNAME "amxFloat.dll\0"
|
||||
#define VERSIONDESCRIPTION "Pawn AMX: Floating Point support\0"
|
||||
#define VERSIONCOMPANYNAME "ITB CompuPhase\0"
|
||||
#define VERSIONPRODUCTNAME "amxFloat\0"
|
||||
#define VERSIONCOPYRIGHT "Copyright \251 2003-2006 ITB CompuPhase\0"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VERSION, REVISION, BUILD, 0
|
||||
PRODUCTVERSION VERSION, REVISION, BUILD, 0
|
||||
FILEFLAGSMASK 0x0000003FL
|
||||
FILEFLAGS 0
|
||||
#if defined(WIN32)
|
||||
FILEOS VOS__WINDOWS32
|
||||
#else
|
||||
FILEOS VOS__WINDOWS16
|
||||
#endif
|
||||
FILETYPE VFT_DLL
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", VERSIONCOMPANYNAME
|
||||
VALUE "FileDescription", VERSIONDESCRIPTION
|
||||
VALUE "FileVersion", VERSIONSTR
|
||||
VALUE "InternalName", VERSIONNAME
|
||||
VALUE "LegalCopyright", VERSIONCOPYRIGHT
|
||||
VALUE "OriginalFilename", VERSIONNAME
|
||||
VALUE "ProductName", VERSIONPRODUCTNAME
|
||||
VALUE "ProductVersion", VERSIONSTR
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
#include <windows.h>
|
||||
#if defined WIN32 || defined _WIN32 || defined __WIN32__
|
||||
# include <winver.h>
|
||||
#else
|
||||
# include <ver.h>
|
||||
#endif
|
||||
|
||||
/* Version information
|
||||
*
|
||||
* All strings MUST have an explicit \0. See the Windows SDK documentation
|
||||
* for details on version information and the VERSIONINFO structure.
|
||||
*/
|
||||
#define VERSION 1
|
||||
#define REVISION 0
|
||||
#define BUILD 0
|
||||
#define VERSIONSTR "1.0.0\0"
|
||||
#define VERSIONNAME "amxFloat.dll\0"
|
||||
#define VERSIONDESCRIPTION "Pawn AMX: Floating Point support\0"
|
||||
#define VERSIONCOMPANYNAME "ITB CompuPhase\0"
|
||||
#define VERSIONPRODUCTNAME "amxFloat\0"
|
||||
#define VERSIONCOPYRIGHT "Copyright \251 2003-2006 ITB CompuPhase\0"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VERSION, REVISION, BUILD, 0
|
||||
PRODUCTVERSION VERSION, REVISION, BUILD, 0
|
||||
FILEFLAGSMASK 0x0000003FL
|
||||
FILEFLAGS 0
|
||||
#if defined(WIN32)
|
||||
FILEOS VOS__WINDOWS32
|
||||
#else
|
||||
FILEOS VOS__WINDOWS16
|
||||
#endif
|
||||
FILETYPE VFT_DLL
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", VERSIONCOMPANYNAME
|
||||
VALUE "FileDescription", VERSIONDESCRIPTION
|
||||
VALUE "FileVersion", VERSIONSTR
|
||||
VALUE "InternalName", VERSIONNAME
|
||||
VALUE "LegalCopyright", VERSIONCOPYRIGHT
|
||||
VALUE "OriginalFilename", VERSIONNAME
|
||||
VALUE "ProductName", VERSIONPRODUCTNAME
|
||||
VALUE "ProductVersion", VERSIONSTR
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
|
@ -1,6 +1,6 @@
|
||||
NAME amxProcess
|
||||
DESCRIPTION 'Pawn AMX: process control and foreign function interface'
|
||||
|
||||
EXPORTS
|
||||
amx_ProcessInit
|
||||
amx_ProcessCleanup
|
||||
NAME amxProcess
|
||||
DESCRIPTION 'Pawn AMX: process control and foreign function interface'
|
||||
|
||||
EXPORTS
|
||||
amx_ProcessInit
|
||||
amx_ProcessCleanup
|
||||
|
@ -1,54 +1,54 @@
|
||||
#include <windows.h>
|
||||
#if defined WIN32 || defined _WIN32 || defined __WIN32__
|
||||
# include <winver.h>
|
||||
#else
|
||||
# include <ver.h>
|
||||
#endif
|
||||
|
||||
/* Version information
|
||||
*
|
||||
* All strings MUST have an explicit \0. See the Windows SDK documentation
|
||||
* for details on version information and the VERSIONINFO structure.
|
||||
*/
|
||||
#define VERSION 1
|
||||
#define REVISION 0
|
||||
#define BUILD 0
|
||||
#define VERSIONSTR "1.0.0\0"
|
||||
#define VERSIONNAME "amxProcess.dll\0"
|
||||
#define VERSIONDESCRIPTION "Pawn AMX: process control and foreign function interface\0"
|
||||
#define VERSIONCOMPANYNAME "ITB CompuPhase\0"
|
||||
#define VERSIONPRODUCTNAME "amxProcess\0"
|
||||
#define VERSIONCOPYRIGHT "Copyright \251 2005-2006 ITB CompuPhase\0"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VERSION, REVISION, BUILD, 0
|
||||
PRODUCTVERSION VERSION, REVISION, BUILD, 0
|
||||
FILEFLAGSMASK 0x0000003FL
|
||||
FILEFLAGS 0
|
||||
#if defined(WIN32)
|
||||
FILEOS VOS__WINDOWS32
|
||||
#else
|
||||
FILEOS VOS__WINDOWS16
|
||||
#endif
|
||||
FILETYPE VFT_DLL
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", VERSIONCOMPANYNAME
|
||||
VALUE "FileDescription", VERSIONDESCRIPTION
|
||||
VALUE "FileVersion", VERSIONSTR
|
||||
VALUE "InternalName", VERSIONNAME
|
||||
VALUE "LegalCopyright", VERSIONCOPYRIGHT
|
||||
VALUE "OriginalFilename", VERSIONNAME
|
||||
VALUE "ProductName", VERSIONPRODUCTNAME
|
||||
VALUE "ProductVersion", VERSIONSTR
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
#include <windows.h>
|
||||
#if defined WIN32 || defined _WIN32 || defined __WIN32__
|
||||
# include <winver.h>
|
||||
#else
|
||||
# include <ver.h>
|
||||
#endif
|
||||
|
||||
/* Version information
|
||||
*
|
||||
* All strings MUST have an explicit \0. See the Windows SDK documentation
|
||||
* for details on version information and the VERSIONINFO structure.
|
||||
*/
|
||||
#define VERSION 1
|
||||
#define REVISION 0
|
||||
#define BUILD 0
|
||||
#define VERSIONSTR "1.0.0\0"
|
||||
#define VERSIONNAME "amxProcess.dll\0"
|
||||
#define VERSIONDESCRIPTION "Pawn AMX: process control and foreign function interface\0"
|
||||
#define VERSIONCOMPANYNAME "ITB CompuPhase\0"
|
||||
#define VERSIONPRODUCTNAME "amxProcess\0"
|
||||
#define VERSIONCOPYRIGHT "Copyright \251 2005-2006 ITB CompuPhase\0"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VERSION, REVISION, BUILD, 0
|
||||
PRODUCTVERSION VERSION, REVISION, BUILD, 0
|
||||
FILEFLAGSMASK 0x0000003FL
|
||||
FILEFLAGS 0
|
||||
#if defined(WIN32)
|
||||
FILEOS VOS__WINDOWS32
|
||||
#else
|
||||
FILEOS VOS__WINDOWS16
|
||||
#endif
|
||||
FILETYPE VFT_DLL
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", VERSIONCOMPANYNAME
|
||||
VALUE "FileDescription", VERSIONDESCRIPTION
|
||||
VALUE "FileVersion", VERSIONSTR
|
||||
VALUE "InternalName", VERSIONNAME
|
||||
VALUE "LegalCopyright", VERSIONCOPYRIGHT
|
||||
VALUE "OriginalFilename", VERSIONNAME
|
||||
VALUE "ProductName", VERSIONPRODUCTNAME
|
||||
VALUE "ProductVersion", VERSIONSTR
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
|
@ -1,54 +1,54 @@
|
||||
#include <windows.h>
|
||||
#if defined WIN32 || defined _WIN32 || defined __WIN32__
|
||||
# include <winver.h>
|
||||
#else
|
||||
# include <ver.h>
|
||||
#endif
|
||||
|
||||
/* Version information
|
||||
*
|
||||
* All strings MUST have an explicit \0. See the Windows SDK documentation
|
||||
* for details on version information and the VERSIONINFO structure.
|
||||
*/
|
||||
#define VERSION 1
|
||||
#define REVISION 0
|
||||
#define BUILD 0
|
||||
#define VERSIONSTR "1.0.0\0"
|
||||
#define VERSIONNAME "amxArgs.dll\0"
|
||||
#define VERSIONDESCRIPTION "Pawn AMX: Script Arguments support\0"
|
||||
#define VERSIONCOMPANYNAME "ITB CompuPhase\0"
|
||||
#define VERSIONPRODUCTNAME "amxArgs\0"
|
||||
#define VERSIONCOPYRIGHT "Copyright \251 2005-2006 ITB CompuPhase\0"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VERSION, REVISION, BUILD, 0
|
||||
PRODUCTVERSION VERSION, REVISION, BUILD, 0
|
||||
FILEFLAGSMASK 0x0000003FL
|
||||
FILEFLAGS 0
|
||||
#if defined(WIN32)
|
||||
FILEOS VOS__WINDOWS32
|
||||
#else
|
||||
FILEOS VOS__WINDOWS16
|
||||
#endif
|
||||
FILETYPE VFT_DLL
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", VERSIONCOMPANYNAME
|
||||
VALUE "FileDescription", VERSIONDESCRIPTION
|
||||
VALUE "FileVersion", VERSIONSTR
|
||||
VALUE "InternalName", VERSIONNAME
|
||||
VALUE "LegalCopyright", VERSIONCOPYRIGHT
|
||||
VALUE "OriginalFilename", VERSIONNAME
|
||||
VALUE "ProductName", VERSIONPRODUCTNAME
|
||||
VALUE "ProductVersion", VERSIONSTR
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
#include <windows.h>
|
||||
#if defined WIN32 || defined _WIN32 || defined __WIN32__
|
||||
# include <winver.h>
|
||||
#else
|
||||
# include <ver.h>
|
||||
#endif
|
||||
|
||||
/* Version information
|
||||
*
|
||||
* All strings MUST have an explicit \0. See the Windows SDK documentation
|
||||
* for details on version information and the VERSIONINFO structure.
|
||||
*/
|
||||
#define VERSION 1
|
||||
#define REVISION 0
|
||||
#define BUILD 0
|
||||
#define VERSIONSTR "1.0.0\0"
|
||||
#define VERSIONNAME "amxArgs.dll\0"
|
||||
#define VERSIONDESCRIPTION "Pawn AMX: Script Arguments support\0"
|
||||
#define VERSIONCOMPANYNAME "ITB CompuPhase\0"
|
||||
#define VERSIONPRODUCTNAME "amxArgs\0"
|
||||
#define VERSIONCOPYRIGHT "Copyright \251 2005-2006 ITB CompuPhase\0"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VERSION, REVISION, BUILD, 0
|
||||
PRODUCTVERSION VERSION, REVISION, BUILD, 0
|
||||
FILEFLAGSMASK 0x0000003FL
|
||||
FILEFLAGS 0
|
||||
#if defined(WIN32)
|
||||
FILEOS VOS__WINDOWS32
|
||||
#else
|
||||
FILEOS VOS__WINDOWS16
|
||||
#endif
|
||||
FILETYPE VFT_DLL
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", VERSIONCOMPANYNAME
|
||||
VALUE "FileDescription", VERSIONDESCRIPTION
|
||||
VALUE "FileVersion", VERSIONSTR
|
||||
VALUE "InternalName", VERSIONNAME
|
||||
VALUE "LegalCopyright", VERSIONCOPYRIGHT
|
||||
VALUE "OriginalFilename", VERSIONNAME
|
||||
VALUE "ProductName", VERSIONPRODUCTNAME
|
||||
VALUE "ProductVersion", VERSIONSTR
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
|
@ -1,86 +1,86 @@
|
||||
; Definition of the AMX structure for assembler syntax (MASM/TASM/WASM)
|
||||
|
||||
amx_s STRUC
|
||||
_base DD ?
|
||||
_dataseg DD ?
|
||||
_callback DD ?
|
||||
_debug DD ?
|
||||
_cip DD ?
|
||||
_frm DD ?
|
||||
_hea DD ?
|
||||
_hlw DD ?
|
||||
_stk DD ?
|
||||
_stp DD ?
|
||||
_flags DD ?
|
||||
_usertags DD 4 DUP (?) ; 4 = AMX_USERNUM (#define'd in amx.h)
|
||||
_userdata DD 4 DUP (?) ; 4 = AMX_USERNUM (#define'd in amx.h)
|
||||
_error DD ?
|
||||
_paramcount DD ?
|
||||
_pri DD ?
|
||||
_alt DD ?
|
||||
_reset_stk DD ?
|
||||
_reset_hea DD ?
|
||||
_syscall_d DD ?
|
||||
IFDEF JIT
|
||||
; the two fields below are for the JIT; they do not exist in
|
||||
; the non-JIT version of the abstract machine
|
||||
_reloc_size DD ? ; memory block for relocations
|
||||
_code_size DD ? ; memory size of the native code
|
||||
ENDIF
|
||||
amx_s ENDS
|
||||
|
||||
amxhead_s STRUC
|
||||
_size DD ? ; size of the "file"
|
||||
_magic DW ? ; signature
|
||||
_file_version DB ? ;file format version
|
||||
_amx_version DB ? ; required version of the AMX
|
||||
_h_flags DW ?
|
||||
_defsize DW ? ; size of one public/native function entry
|
||||
_cod DD ? ; initial value of COD - code block
|
||||
_dat DD ? ; initial value of DAT - data block
|
||||
_h_hea DD ? ; initial value of HEA - start of the heap
|
||||
_h_stp DD ? ; initial value of STP - stack top
|
||||
_h_cip DD ? ; initial value of CIP - the instruction pointer
|
||||
_publics DD ? ; offset to the "public functions" table
|
||||
_natives DD ? ; offset to the "native functions" table
|
||||
_libraries DD ? ; offset to the "library" table
|
||||
_pubvars DD ? ; offset to the "public variables" table
|
||||
_tags DD ? ; offset to the "public tagnames" table
|
||||
_nametable DD ? ; offset to the name table, file version 7 only
|
||||
amxhead_s ENDS
|
||||
|
||||
|
||||
AMX_ERR_NONE EQU 0
|
||||
AMX_ERR_EXIT EQU 1
|
||||
AMX_ERR_ASSERT EQU 2
|
||||
AMX_ERR_STACKERR EQU 3
|
||||
AMX_ERR_BOUNDS EQU 4
|
||||
AMX_ERR_MEMACCESS EQU 5
|
||||
AMX_ERR_INVINSTR EQU 6
|
||||
AMX_ERR_STACKLOW EQU 7
|
||||
AMX_ERR_HEAPLOW EQU 8
|
||||
AMX_ERR_CALLBACK EQU 9
|
||||
AMX_ERR_NATIVE EQU 10
|
||||
AMX_ERR_DIVIDE EQU 11 ; for catching divide errors
|
||||
AMX_ERR_SLEEP EQU 12
|
||||
|
||||
AMX_ERR_MEMORY EQU 16
|
||||
AMX_ERR_FORMAT EQU 17
|
||||
AMX_ERR_VERSION EQU 18
|
||||
AMX_ERR_NOTFOUND EQU 19
|
||||
AMX_ERR_INDEX EQU 20
|
||||
AMX_ERR_DEBUG EQU 21
|
||||
AMX_ERR_INIT EQU 22
|
||||
AMX_ERR_USERDATA EQU 23
|
||||
AMX_ERR_INIT_JIT EQU 24
|
||||
AMX_ERR_PARAMS EQU 25
|
||||
AMX_ERR_DOMAIN EQU 26
|
||||
AMX_ERR_GENERAL EQU 27
|
||||
|
||||
AMX_FLAG_DEBUG EQU 0002h ; symbolic info. available
|
||||
AMX_FLAG_COMPACT EQU 0004h
|
||||
AMX_FLAG_BYTEOPC EQU 0008h
|
||||
AMX_FLAG_NOCHECKS EQU 0010h
|
||||
AMX_FLAG_BROWSE EQU 4000h
|
||||
AMX_FLAG_RELOC EQU 8000h ; jump/call addresses relocated
|
||||
|
||||
; Definition of the AMX structure for assembler syntax (MASM/TASM/WASM)
|
||||
|
||||
amx_s STRUC
|
||||
_base DD ?
|
||||
_dataseg DD ?
|
||||
_callback DD ?
|
||||
_debug DD ?
|
||||
_cip DD ?
|
||||
_frm DD ?
|
||||
_hea DD ?
|
||||
_hlw DD ?
|
||||
_stk DD ?
|
||||
_stp DD ?
|
||||
_flags DD ?
|
||||
_usertags DD 4 DUP (?) ; 4 = AMX_USERNUM (#define'd in amx.h)
|
||||
_userdata DD 4 DUP (?) ; 4 = AMX_USERNUM (#define'd in amx.h)
|
||||
_error DD ?
|
||||
_paramcount DD ?
|
||||
_pri DD ?
|
||||
_alt DD ?
|
||||
_reset_stk DD ?
|
||||
_reset_hea DD ?
|
||||
_syscall_d DD ?
|
||||
IFDEF JIT
|
||||
; the two fields below are for the JIT; they do not exist in
|
||||
; the non-JIT version of the abstract machine
|
||||
_reloc_size DD ? ; memory block for relocations
|
||||
_code_size DD ? ; memory size of the native code
|
||||
ENDIF
|
||||
amx_s ENDS
|
||||
|
||||
amxhead_s STRUC
|
||||
_size DD ? ; size of the "file"
|
||||
_magic DW ? ; signature
|
||||
_file_version DB ? ;file format version
|
||||
_amx_version DB ? ; required version of the AMX
|
||||
_h_flags DW ?
|
||||
_defsize DW ? ; size of one public/native function entry
|
||||
_cod DD ? ; initial value of COD - code block
|
||||
_dat DD ? ; initial value of DAT - data block
|
||||
_h_hea DD ? ; initial value of HEA - start of the heap
|
||||
_h_stp DD ? ; initial value of STP - stack top
|
||||
_h_cip DD ? ; initial value of CIP - the instruction pointer
|
||||
_publics DD ? ; offset to the "public functions" table
|
||||
_natives DD ? ; offset to the "native functions" table
|
||||
_libraries DD ? ; offset to the "library" table
|
||||
_pubvars DD ? ; offset to the "public variables" table
|
||||
_tags DD ? ; offset to the "public tagnames" table
|
||||
_nametable DD ? ; offset to the name table, file version 7 only
|
||||
amxhead_s ENDS
|
||||
|
||||
|
||||
AMX_ERR_NONE EQU 0
|
||||
AMX_ERR_EXIT EQU 1
|
||||
AMX_ERR_ASSERT EQU 2
|
||||
AMX_ERR_STACKERR EQU 3
|
||||
AMX_ERR_BOUNDS EQU 4
|
||||
AMX_ERR_MEMACCESS EQU 5
|
||||
AMX_ERR_INVINSTR EQU 6
|
||||
AMX_ERR_STACKLOW EQU 7
|
||||
AMX_ERR_HEAPLOW EQU 8
|
||||
AMX_ERR_CALLBACK EQU 9
|
||||
AMX_ERR_NATIVE EQU 10
|
||||
AMX_ERR_DIVIDE EQU 11 ; for catching divide errors
|
||||
AMX_ERR_SLEEP EQU 12
|
||||
|
||||
AMX_ERR_MEMORY EQU 16
|
||||
AMX_ERR_FORMAT EQU 17
|
||||
AMX_ERR_VERSION EQU 18
|
||||
AMX_ERR_NOTFOUND EQU 19
|
||||
AMX_ERR_INDEX EQU 20
|
||||
AMX_ERR_DEBUG EQU 21
|
||||
AMX_ERR_INIT EQU 22
|
||||
AMX_ERR_USERDATA EQU 23
|
||||
AMX_ERR_INIT_JIT EQU 24
|
||||
AMX_ERR_PARAMS EQU 25
|
||||
AMX_ERR_DOMAIN EQU 26
|
||||
AMX_ERR_GENERAL EQU 27
|
||||
|
||||
AMX_FLAG_DEBUG EQU 0002h ; symbolic info. available
|
||||
AMX_FLAG_COMPACT EQU 0004h
|
||||
AMX_FLAG_BYTEOPC EQU 0008h
|
||||
AMX_FLAG_NOCHECKS EQU 0010h
|
||||
AMX_FLAG_BROWSE EQU 4000h
|
||||
AMX_FLAG_RELOC EQU 8000h ; jump/call addresses relocated
|
||||
|
||||
|
@ -1,86 +1,86 @@
|
||||
; Definition of the AMX structure for assembler syntax (NASM)
|
||||
|
||||
struc amx_s
|
||||
_base: resd 1
|
||||
_dataseg: resd 1
|
||||
_callback: resd 1
|
||||
_debug: resd 1
|
||||
_cip: resd 1
|
||||
_frm: resd 1
|
||||
_hea: resd 1
|
||||
_hlw: resd 1
|
||||
_stk: resd 1
|
||||
_stp: resd 1
|
||||
_flags: resd 1
|
||||
_usertags: resd 4 ; 4 = AMX_USERNUM (#define'd in amx.h)
|
||||
_userdata: resd 4 ; 4 = AMX_USERNUM (#define'd in amx.h)
|
||||
_error: resd 1
|
||||
_paramcount: resd 1
|
||||
_pri: resd 1
|
||||
_alt: resd 1
|
||||
_reset_stk: resd 1
|
||||
_reset_hea: resd 1
|
||||
_syscall_d: resd 1
|
||||
%ifdef JIT
|
||||
; the two fields below are for the JIT; they do not exist in
|
||||
; the non-JIT version of the abstract machine
|
||||
_reloc_size: resd 1 ; memory block for relocations
|
||||
_code_size: resd 1 ; memory size of the native code
|
||||
%endif
|
||||
endstruc
|
||||
|
||||
struc amxhead_s
|
||||
_size: resd 1 ; size of the "file"
|
||||
_magic: resw 1 ; signature
|
||||
_file_version: resb 1; file format version
|
||||
_amx_version: resb 1 ; required version of the AMX
|
||||
_h_flags: resw 1
|
||||
_defsize: resw 1 ; size of one public/native function entry
|
||||
_cod: resd 1 ; initial value of COD - code block
|
||||
_dat: resd 1 ; initial value of DAT - data block
|
||||
_h_hea: resd 1 ; initial value of HEA - start of the heap
|
||||
_h_stp: resd 1 ; initial value of STP - stack top
|
||||
_h_cip: resd 1 ; initial value of CIP - the instruction pointer
|
||||
_publics: resd 1 ; offset to the "public functions" table
|
||||
_natives: resd 1 ; offset to the "native functions" table
|
||||
_libraries: resd 1 ; offset to the "library" table
|
||||
_pubvars: resd 1 ; offset to the "public variables" table
|
||||
_tags: resd 1 ; offset to the "public tagnames" table
|
||||
_nametable: resd 1 ; offset to the name table, file version 7 only
|
||||
endstruc
|
||||
|
||||
|
||||
AMX_ERR_NONE EQU 0
|
||||
AMX_ERR_EXIT EQU 1
|
||||
AMX_ERR_ASSERT EQU 2
|
||||
AMX_ERR_STACKERR EQU 3
|
||||
AMX_ERR_BOUNDS EQU 4
|
||||
AMX_ERR_MEMACCESS EQU 5
|
||||
AMX_ERR_INVINSTR EQU 6
|
||||
AMX_ERR_STACKLOW EQU 7
|
||||
AMX_ERR_HEAPLOW EQU 8
|
||||
AMX_ERR_CALLBACK EQU 9
|
||||
AMX_ERR_NATIVE EQU 10
|
||||
AMX_ERR_DIVIDE EQU 11 ; for catching divide errors
|
||||
AMX_ERR_SLEEP EQU 12
|
||||
|
||||
AMX_ERR_MEMORY EQU 16
|
||||
AMX_ERR_FORMAT EQU 17
|
||||
AMX_ERR_VERSION EQU 18
|
||||
AMX_ERR_NOTFOUND EQU 19
|
||||
AMX_ERR_INDEX EQU 20
|
||||
AMX_ERR_DEBUG EQU 21
|
||||
AMX_ERR_INIT EQU 22
|
||||
AMX_ERR_USERDATA EQU 23
|
||||
AMX_ERR_INIT_JIT EQU 24
|
||||
AMX_ERR_PARAMS EQU 25
|
||||
AMX_ERR_DOMAIN EQU 26
|
||||
AMX_ERR_GENERAL EQU 27
|
||||
|
||||
AMX_FLAG_DEBUG EQU 0002h ; symbolic info. available
|
||||
AMX_FLAG_COMPACT EQU 0004h
|
||||
AMX_FLAG_BYTEOPC EQU 0008h
|
||||
AMX_FLAG_NOCHECKS EQU 0010h
|
||||
AMX_FLAG_BROWSE EQU 4000h
|
||||
AMX_FLAG_RELOC EQU 8000h ; jump/call addresses relocated
|
||||
|
||||
; Definition of the AMX structure for assembler syntax (NASM)
|
||||
|
||||
struc amx_s
|
||||
_base: resd 1
|
||||
_dataseg: resd 1
|
||||
_callback: resd 1
|
||||
_debug: resd 1
|
||||
_cip: resd 1
|
||||
_frm: resd 1
|
||||
_hea: resd 1
|
||||
_hlw: resd 1
|
||||
_stk: resd 1
|
||||
_stp: resd 1
|
||||
_flags: resd 1
|
||||
_usertags: resd 4 ; 4 = AMX_USERNUM (#define'd in amx.h)
|
||||
_userdata: resd 4 ; 4 = AMX_USERNUM (#define'd in amx.h)
|
||||
_error: resd 1
|
||||
_paramcount: resd 1
|
||||
_pri: resd 1
|
||||
_alt: resd 1
|
||||
_reset_stk: resd 1
|
||||
_reset_hea: resd 1
|
||||
_syscall_d: resd 1
|
||||
%ifdef JIT
|
||||
; the two fields below are for the JIT; they do not exist in
|
||||
; the non-JIT version of the abstract machine
|
||||
_reloc_size: resd 1 ; memory block for relocations
|
||||
_code_size: resd 1 ; memory size of the native code
|
||||
%endif
|
||||
endstruc
|
||||
|
||||
struc amxhead_s
|
||||
_size: resd 1 ; size of the "file"
|
||||
_magic: resw 1 ; signature
|
||||
_file_version: resb 1; file format version
|
||||
_amx_version: resb 1 ; required version of the AMX
|
||||
_h_flags: resw 1
|
||||
_defsize: resw 1 ; size of one public/native function entry
|
||||
_cod: resd 1 ; initial value of COD - code block
|
||||
_dat: resd 1 ; initial value of DAT - data block
|
||||
_h_hea: resd 1 ; initial value of HEA - start of the heap
|
||||
_h_stp: resd 1 ; initial value of STP - stack top
|
||||
_h_cip: resd 1 ; initial value of CIP - the instruction pointer
|
||||
_publics: resd 1 ; offset to the "public functions" table
|
||||
_natives: resd 1 ; offset to the "native functions" table
|
||||
_libraries: resd 1 ; offset to the "library" table
|
||||
_pubvars: resd 1 ; offset to the "public variables" table
|
||||
_tags: resd 1 ; offset to the "public tagnames" table
|
||||
_nametable: resd 1 ; offset to the name table, file version 7 only
|
||||
endstruc
|
||||
|
||||
|
||||
AMX_ERR_NONE EQU 0
|
||||
AMX_ERR_EXIT EQU 1
|
||||
AMX_ERR_ASSERT EQU 2
|
||||
AMX_ERR_STACKERR EQU 3
|
||||
AMX_ERR_BOUNDS EQU 4
|
||||
AMX_ERR_MEMACCESS EQU 5
|
||||
AMX_ERR_INVINSTR EQU 6
|
||||
AMX_ERR_STACKLOW EQU 7
|
||||
AMX_ERR_HEAPLOW EQU 8
|
||||
AMX_ERR_CALLBACK EQU 9
|
||||
AMX_ERR_NATIVE EQU 10
|
||||
AMX_ERR_DIVIDE EQU 11 ; for catching divide errors
|
||||
AMX_ERR_SLEEP EQU 12
|
||||
|
||||
AMX_ERR_MEMORY EQU 16
|
||||
AMX_ERR_FORMAT EQU 17
|
||||
AMX_ERR_VERSION EQU 18
|
||||
AMX_ERR_NOTFOUND EQU 19
|
||||
AMX_ERR_INDEX EQU 20
|
||||
AMX_ERR_DEBUG EQU 21
|
||||
AMX_ERR_INIT EQU 22
|
||||
AMX_ERR_USERDATA EQU 23
|
||||
AMX_ERR_INIT_JIT EQU 24
|
||||
AMX_ERR_PARAMS EQU 25
|
||||
AMX_ERR_DOMAIN EQU 26
|
||||
AMX_ERR_GENERAL EQU 27
|
||||
|
||||
AMX_FLAG_DEBUG EQU 0002h ; symbolic info. available
|
||||
AMX_FLAG_COMPACT EQU 0004h
|
||||
AMX_FLAG_BYTEOPC EQU 0008h
|
||||
AMX_FLAG_NOCHECKS EQU 0010h
|
||||
AMX_FLAG_BROWSE EQU 4000h
|
||||
AMX_FLAG_RELOC EQU 8000h ; jump/call addresses relocated
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
NAME amxFile
|
||||
DESCRIPTION 'File I/O support library'
|
||||
|
||||
EXPORTS
|
||||
amx_FileInit
|
||||
amx_FileCleanup
|
||||
NAME amxFile
|
||||
DESCRIPTION 'File I/O support library'
|
||||
|
||||
EXPORTS
|
||||
amx_FileInit
|
||||
amx_FileCleanup
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
NAME amxString
|
||||
DESCRIPTION 'Pawn AMX: string manipulation routines'
|
||||
|
||||
EXPORTS
|
||||
amx_StringInit
|
||||
amx_StringCleanup
|
||||
NAME amxString
|
||||
DESCRIPTION 'Pawn AMX: string manipulation routines'
|
||||
|
||||
EXPORTS
|
||||
amx_StringInit
|
||||
amx_StringCleanup
|
||||
|
@ -1,54 +1,54 @@
|
||||
#include <windows.h>
|
||||
#if defined WIN32 || defined _WIN32 || defined __WIN32__
|
||||
# include <winver.h>
|
||||
#else
|
||||
# include <ver.h>
|
||||
#endif
|
||||
|
||||
/* Version information
|
||||
*
|
||||
* All strings MUST have an explicit \0. See the Windows SDK documentation
|
||||
* for details on version information and the VERSIONINFO structure.
|
||||
*/
|
||||
#define VERSION 1
|
||||
#define REVISION 1
|
||||
#define BUILD 0
|
||||
#define VERSIONSTR "1.1.0\0"
|
||||
#define VERSIONNAME "amxString.dll\0"
|
||||
#define VERSIONDESCRIPTION "Pawn AMX: String manipulation routines\0"
|
||||
#define VERSIONCOMPANYNAME "ITB CompuPhase\0"
|
||||
#define VERSIONPRODUCTNAME "amxString\0"
|
||||
#define VERSIONCOPYRIGHT "Copyright \251 2005-2006 ITB CompuPhase\0"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VERSION, REVISION, BUILD, 0
|
||||
PRODUCTVERSION VERSION, REVISION, BUILD, 0
|
||||
FILEFLAGSMASK 0x0000003FL
|
||||
FILEFLAGS 0
|
||||
#if defined(WIN32)
|
||||
FILEOS VOS__WINDOWS32
|
||||
#else
|
||||
FILEOS VOS__WINDOWS16
|
||||
#endif
|
||||
FILETYPE VFT_DLL
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", VERSIONCOMPANYNAME
|
||||
VALUE "FileDescription", VERSIONDESCRIPTION
|
||||
VALUE "FileVersion", VERSIONSTR
|
||||
VALUE "InternalName", VERSIONNAME
|
||||
VALUE "LegalCopyright", VERSIONCOPYRIGHT
|
||||
VALUE "OriginalFilename", VERSIONNAME
|
||||
VALUE "ProductName", VERSIONPRODUCTNAME
|
||||
VALUE "ProductVersion", VERSIONSTR
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
#include <windows.h>
|
||||
#if defined WIN32 || defined _WIN32 || defined __WIN32__
|
||||
# include <winver.h>
|
||||
#else
|
||||
# include <ver.h>
|
||||
#endif
|
||||
|
||||
/* Version information
|
||||
*
|
||||
* All strings MUST have an explicit \0. See the Windows SDK documentation
|
||||
* for details on version information and the VERSIONINFO structure.
|
||||
*/
|
||||
#define VERSION 1
|
||||
#define REVISION 1
|
||||
#define BUILD 0
|
||||
#define VERSIONSTR "1.1.0\0"
|
||||
#define VERSIONNAME "amxString.dll\0"
|
||||
#define VERSIONDESCRIPTION "Pawn AMX: String manipulation routines\0"
|
||||
#define VERSIONCOMPANYNAME "ITB CompuPhase\0"
|
||||
#define VERSIONPRODUCTNAME "amxString\0"
|
||||
#define VERSIONCOPYRIGHT "Copyright \251 2005-2006 ITB CompuPhase\0"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VERSION, REVISION, BUILD, 0
|
||||
PRODUCTVERSION VERSION, REVISION, BUILD, 0
|
||||
FILEFLAGSMASK 0x0000003FL
|
||||
FILEFLAGS 0
|
||||
#if defined(WIN32)
|
||||
FILEOS VOS__WINDOWS32
|
||||
#else
|
||||
FILEOS VOS__WINDOWS16
|
||||
#endif
|
||||
FILETYPE VFT_DLL
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", VERSIONCOMPANYNAME
|
||||
VALUE "FileDescription", VERSIONDESCRIPTION
|
||||
VALUE "FileVersion", VERSIONSTR
|
||||
VALUE "InternalName", VERSIONNAME
|
||||
VALUE "LegalCopyright", VERSIONCOPYRIGHT
|
||||
VALUE "OriginalFilename", VERSIONNAME
|
||||
VALUE "ProductName", VERSIONPRODUCTNAME
|
||||
VALUE "ProductVersion", VERSIONSTR
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
|
@ -1,6 +1,6 @@
|
||||
NAME amxTime
|
||||
DESCRIPTION 'Pawn AMX: time routines'
|
||||
|
||||
EXPORTS
|
||||
amx_TimeInit
|
||||
amx_TimeCleanup
|
||||
NAME amxTime
|
||||
DESCRIPTION 'Pawn AMX: time routines'
|
||||
|
||||
EXPORTS
|
||||
amx_TimeInit
|
||||
amx_TimeCleanup
|
||||
|
@ -1,54 +1,54 @@
|
||||
#include <windows.h>
|
||||
#if defined WIN32 || defined _WIN32 || defined __WIN32__
|
||||
# include <winver.h>
|
||||
#else
|
||||
# include <ver.h>
|
||||
#endif
|
||||
|
||||
/* Version information
|
||||
*
|
||||
* All strings MUST have an explicit \0. See the Windows SDK documentation
|
||||
* for details on version information and the VERSIONINFO structure.
|
||||
*/
|
||||
#define VERSION 1
|
||||
#define REVISION 1
|
||||
#define BUILD 0
|
||||
#define VERSIONSTR "1.2.0\0"
|
||||
#define VERSIONNAME "amxTime.dll\0"
|
||||
#define VERSIONDESCRIPTION "Pawn AMX: time routines\0"
|
||||
#define VERSIONCOMPANYNAME "ITB CompuPhase\0"
|
||||
#define VERSIONPRODUCTNAME "amxTime\0"
|
||||
#define VERSIONCOPYRIGHT "Copyright \251 2005-2006 ITB CompuPhase\0"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VERSION, REVISION, BUILD, 0
|
||||
PRODUCTVERSION VERSION, REVISION, BUILD, 0
|
||||
FILEFLAGSMASK 0x0000003FL
|
||||
FILEFLAGS 0
|
||||
#if defined(WIN32)
|
||||
FILEOS VOS__WINDOWS32
|
||||
#else
|
||||
FILEOS VOS__WINDOWS16
|
||||
#endif
|
||||
FILETYPE VFT_DLL
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", VERSIONCOMPANYNAME
|
||||
VALUE "FileDescription", VERSIONDESCRIPTION
|
||||
VALUE "FileVersion", VERSIONSTR
|
||||
VALUE "InternalName", VERSIONNAME
|
||||
VALUE "LegalCopyright", VERSIONCOPYRIGHT
|
||||
VALUE "OriginalFilename", VERSIONNAME
|
||||
VALUE "ProductName", VERSIONPRODUCTNAME
|
||||
VALUE "ProductVersion", VERSIONSTR
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
#include <windows.h>
|
||||
#if defined WIN32 || defined _WIN32 || defined __WIN32__
|
||||
# include <winver.h>
|
||||
#else
|
||||
# include <ver.h>
|
||||
#endif
|
||||
|
||||
/* Version information
|
||||
*
|
||||
* All strings MUST have an explicit \0. See the Windows SDK documentation
|
||||
* for details on version information and the VERSIONINFO structure.
|
||||
*/
|
||||
#define VERSION 1
|
||||
#define REVISION 1
|
||||
#define BUILD 0
|
||||
#define VERSIONSTR "1.2.0\0"
|
||||
#define VERSIONNAME "amxTime.dll\0"
|
||||
#define VERSIONDESCRIPTION "Pawn AMX: time routines\0"
|
||||
#define VERSIONCOMPANYNAME "ITB CompuPhase\0"
|
||||
#define VERSIONPRODUCTNAME "amxTime\0"
|
||||
#define VERSIONCOPYRIGHT "Copyright \251 2005-2006 ITB CompuPhase\0"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VERSION, REVISION, BUILD, 0
|
||||
PRODUCTVERSION VERSION, REVISION, BUILD, 0
|
||||
FILEFLAGSMASK 0x0000003FL
|
||||
FILEFLAGS 0
|
||||
#if defined(WIN32)
|
||||
FILEOS VOS__WINDOWS32
|
||||
#else
|
||||
FILEOS VOS__WINDOWS16
|
||||
#endif
|
||||
FILETYPE VFT_DLL
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", VERSIONCOMPANYNAME
|
||||
VALUE "FileDescription", VERSIONDESCRIPTION
|
||||
VALUE "FileVersion", VERSIONSTR
|
||||
VALUE "InternalName", VERSIONNAME
|
||||
VALUE "LegalCopyright", VERSIONCOPYRIGHT
|
||||
VALUE "OriginalFilename", VERSIONNAME
|
||||
VALUE "ProductName", VERSIONPRODUCTNAME
|
||||
VALUE "ProductVersion", VERSIONSTR
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
|
@ -1,71 +1,71 @@
|
||||
#include <stdio.h>
|
||||
#include <malloc>
|
||||
#include <map>
|
||||
#include "amx.h"
|
||||
|
||||
class LogFile;
|
||||
static std::map<AMX*, LogFile*> lookup;
|
||||
|
||||
class LogFile {
|
||||
public:
|
||||
LogFile()
|
||||
{
|
||||
f = tmpfile();
|
||||
}
|
||||
|
||||
~LogFile()
|
||||
{
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
private:
|
||||
write(AMX* amx, cell params[])
|
||||
{
|
||||
int r = 0;
|
||||
char *pstr;
|
||||
|
||||
amx_StrParam(amx, params[1], pstr);
|
||||
if (pstr != NULL)
|
||||
r = fprintf(f, "%s", pstr);
|
||||
return r;
|
||||
}
|
||||
|
||||
FILE *f;
|
||||
|
||||
public:
|
||||
static cell n_write(AMX* amx, cell params[])
|
||||
{
|
||||
std::map<AMX*, LogFile*>::iterator p = lookup.find(amx);
|
||||
if (p != lookup.end())
|
||||
return p->second->write(amx, params);
|
||||
return 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
extern "C"
|
||||
int amx_LogFileInit(AMX* amx)
|
||||
{
|
||||
LogFile* lf = new LogFile;
|
||||
if (lf) {
|
||||
lookup.insert(std::make_pair(amx, lf));
|
||||
|
||||
static AMX_NATIVE_INFO nativelist[] = {
|
||||
{ "write", LogFile::n_write },
|
||||
{ 0, 0 } /* terminator */
|
||||
};
|
||||
return amx_Register(amx, nativelist, -1);
|
||||
} /* if */
|
||||
return AMX_ERR_MEMORY;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
int amx_LogFileExit(AMX* amx)
|
||||
{
|
||||
std::map<AMX*, LogFile*>::iterator p = lookup.find(amx);
|
||||
if (p != lookup.end()) {
|
||||
delete p->second;
|
||||
lookup.erase(p);
|
||||
} /* if */
|
||||
return AMX_ERR_NONE;
|
||||
}
|
||||
#include <stdio.h>
|
||||
#include <malloc>
|
||||
#include <map>
|
||||
#include "amx.h"
|
||||
|
||||
class LogFile;
|
||||
static std::map<AMX*, LogFile*> lookup;
|
||||
|
||||
class LogFile {
|
||||
public:
|
||||
LogFile()
|
||||
{
|
||||
f = tmpfile();
|
||||
}
|
||||
|
||||
~LogFile()
|
||||
{
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
private:
|
||||
write(AMX* amx, cell params[])
|
||||
{
|
||||
int r = 0;
|
||||
char *pstr;
|
||||
|
||||
amx_StrParam(amx, params[1], pstr);
|
||||
if (pstr != NULL)
|
||||
r = fprintf(f, "%s", pstr);
|
||||
return r;
|
||||
}
|
||||
|
||||
FILE *f;
|
||||
|
||||
public:
|
||||
static cell n_write(AMX* amx, cell params[])
|
||||
{
|
||||
std::map<AMX*, LogFile*>::iterator p = lookup.find(amx);
|
||||
if (p != lookup.end())
|
||||
return p->second->write(amx, params);
|
||||
return 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
extern "C"
|
||||
int amx_LogFileInit(AMX* amx)
|
||||
{
|
||||
LogFile* lf = new LogFile;
|
||||
if (lf) {
|
||||
lookup.insert(std::make_pair(amx, lf));
|
||||
|
||||
static AMX_NATIVE_INFO nativelist[] = {
|
||||
{ "write", LogFile::n_write },
|
||||
{ 0, 0 } /* terminator */
|
||||
};
|
||||
return amx_Register(amx, nativelist, -1);
|
||||
} /* if */
|
||||
return AMX_ERR_MEMORY;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
int amx_LogFileExit(AMX* amx)
|
||||
{
|
||||
std::map<AMX*, LogFile*>::iterator p = lookup.find(amx);
|
||||
if (p != lookup.end()) {
|
||||
delete p->second;
|
||||
lookup.erase(p);
|
||||
} /* if */
|
||||
return AMX_ERR_NONE;
|
||||
}
|
||||
|
@ -1,72 +1,72 @@
|
||||
This is a collection of various complete implementations of a "pawnrun", a
|
||||
console mode interface to the abstract machine of Small. The Small manual
|
||||
develops these examples in several steps, but it does not contain listings
|
||||
of the complete and compilable programs.
|
||||
|
||||
Many examples for compiling the abstract machine, for various compilers and
|
||||
various options of the abstract machine, are given in the "Implementor's Guide"
|
||||
for the Small toolkit. Below is a brief subset of those examples, using only
|
||||
the ANSI core. If your compiler is not listed, please consult the
|
||||
above-mentioned Implementor's Guide. In each of these examples, "prun1.c" should
|
||||
be replaced by "prun2.c", "prun3.c" for the other examples.
|
||||
|
||||
Borland C++ version 3.1, 16-bit:
|
||||
bcc prun1.c amx.c amxcore.c amxcons.c
|
||||
|
||||
Microsoft Visual C/C++ version 5.0 or 6.0, 32-bit:
|
||||
cl prun1.c amx.c amxcons.c amxcore.c
|
||||
|
||||
(note: when running with warning level 4, option "-W4", Visual C/C++
|
||||
issues a few warnings for unused function arguments and changes of the
|
||||
default structure alignment)
|
||||
|
||||
OpenWatcom C/C++ version 1.3, 32-bit:
|
||||
wcl386 /l=nt prun1.c amx.c amxcore.c amxcons.c
|
||||
|
||||
|
||||
PRUN1.C
|
||||
The smallest and simplest example. This program uses the functions
|
||||
from the file AMXAUX.C (a collection of functions that are not part of
|
||||
the AMX core, but that are occasionally useful or convenient). The
|
||||
other examples are modifications and variations on this program.
|
||||
|
||||
PRUN2.C
|
||||
This example adds a debug hook and a Ctrl-Break signal function (all
|
||||
in ANSI C) to be able to abort a script with Ctrl-C or Ctrl-Break. The
|
||||
required modifications come from the manual. It is up to you to
|
||||
replace the ANSI C "signal" handler by some other means to abort a
|
||||
run-away script.
|
||||
|
||||
Note that the SIGINT signal is not very standardized, at least not
|
||||
on Win32 compilers.
|
||||
|
||||
PRUN3.C
|
||||
This example implements the virtual memory implementation, where a
|
||||
compiled script may take as much or as little memory that it requires.
|
||||
The technique by which it achieves this is OS-dependent; this example
|
||||
will only compile and run on any OS of the Win32 family.
|
||||
|
||||
PRUN4.C
|
||||
The examples do far have only executed function main() in the compiled
|
||||
script. This example is a modification of PRUN1.C that accepts two
|
||||
more parameters: a function name and a parameter. The parameter is
|
||||
passed as a string to the specified function.
|
||||
|
||||
This sample uses a modified "rot13" example script (one in which the
|
||||
"work horse" function is made public).
|
||||
|
||||
PRUN5.C
|
||||
Another variation on PRUN1.C that shows how to use the optional garbage
|
||||
collector. Please read the appendix on the garbage collector as well,
|
||||
because in the pursuit of creating a portable sample, I have "hooked"
|
||||
the garbage collector on the "debug hook" and this is actually a bad
|
||||
idea.
|
||||
This example also requires the "Better String library", and open source
|
||||
library for handling dynamic strings in a safe manner. The "Better
|
||||
String library" is made by Paul Hsieh, and it can be found, at the time
|
||||
of this writing, at http://bstring.sourceforge.net/.
|
||||
|
||||
PRUN_JIT.C
|
||||
A version of PRUN1.C that sets up the JIT compiler to run the modules.
|
||||
This example does not set up a debug hook, because the JIT compiler
|
||||
does not support any debug hook.
|
||||
This is a collection of various complete implementations of a "pawnrun", a
|
||||
console mode interface to the abstract machine of Small. The Small manual
|
||||
develops these examples in several steps, but it does not contain listings
|
||||
of the complete and compilable programs.
|
||||
|
||||
Many examples for compiling the abstract machine, for various compilers and
|
||||
various options of the abstract machine, are given in the "Implementor's Guide"
|
||||
for the Small toolkit. Below is a brief subset of those examples, using only
|
||||
the ANSI core. If your compiler is not listed, please consult the
|
||||
above-mentioned Implementor's Guide. In each of these examples, "prun1.c" should
|
||||
be replaced by "prun2.c", "prun3.c" for the other examples.
|
||||
|
||||
Borland C++ version 3.1, 16-bit:
|
||||
bcc prun1.c amx.c amxcore.c amxcons.c
|
||||
|
||||
Microsoft Visual C/C++ version 5.0 or 6.0, 32-bit:
|
||||
cl prun1.c amx.c amxcons.c amxcore.c
|
||||
|
||||
(note: when running with warning level 4, option "-W4", Visual C/C++
|
||||
issues a few warnings for unused function arguments and changes of the
|
||||
default structure alignment)
|
||||
|
||||
OpenWatcom C/C++ version 1.3, 32-bit:
|
||||
wcl386 /l=nt prun1.c amx.c amxcore.c amxcons.c
|
||||
|
||||
|
||||
PRUN1.C
|
||||
The smallest and simplest example. This program uses the functions
|
||||
from the file AMXAUX.C (a collection of functions that are not part of
|
||||
the AMX core, but that are occasionally useful or convenient). The
|
||||
other examples are modifications and variations on this program.
|
||||
|
||||
PRUN2.C
|
||||
This example adds a debug hook and a Ctrl-Break signal function (all
|
||||
in ANSI C) to be able to abort a script with Ctrl-C or Ctrl-Break. The
|
||||
required modifications come from the manual. It is up to you to
|
||||
replace the ANSI C "signal" handler by some other means to abort a
|
||||
run-away script.
|
||||
|
||||
Note that the SIGINT signal is not very standardized, at least not
|
||||
on Win32 compilers.
|
||||
|
||||
PRUN3.C
|
||||
This example implements the virtual memory implementation, where a
|
||||
compiled script may take as much or as little memory that it requires.
|
||||
The technique by which it achieves this is OS-dependent; this example
|
||||
will only compile and run on any OS of the Win32 family.
|
||||
|
||||
PRUN4.C
|
||||
The examples do far have only executed function main() in the compiled
|
||||
script. This example is a modification of PRUN1.C that accepts two
|
||||
more parameters: a function name and a parameter. The parameter is
|
||||
passed as a string to the specified function.
|
||||
|
||||
This sample uses a modified "rot13" example script (one in which the
|
||||
"work horse" function is made public).
|
||||
|
||||
PRUN5.C
|
||||
Another variation on PRUN1.C that shows how to use the optional garbage
|
||||
collector. Please read the appendix on the garbage collector as well,
|
||||
because in the pursuit of creating a portable sample, I have "hooked"
|
||||
the garbage collector on the "debug hook" and this is actually a bad
|
||||
idea.
|
||||
This example also requires the "Better String library", and open source
|
||||
library for handling dynamic strings in a safe manner. The "Better
|
||||
String library" is made by Paul Hsieh, and it can be found, at the time
|
||||
of this writing, at http://bstring.sourceforge.net/.
|
||||
|
||||
PRUN_JIT.C
|
||||
A version of PRUN1.C that sets up the JIT compiler to run the modules.
|
||||
This example does not set up a debug hook, because the JIT compiler
|
||||
does not support any debug hook.
|
||||
|
Loading…
x
Reference in New Issue
Block a user