Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
20090405 code: detect ability of lua library to propagate exceptions at
compile time. Lua.Config.
- Loading branch information
m0
committed
Apr 5, 2009
1 parent
212113e
commit b2ab654
Showing
23 changed files
with
199 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1 @@ | ||
Define: | ||
|
||
Lua.Can_Propagate_Exceptions : constant Boolean := True; | ||
|
||
Create above constant with compile-time check. Can exceptions | ||
be propagated through C library? | ||
|
||
Detect C types for lua_integer, lua_number, etc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ utest.ali | |
raiser.ali | ||
../lua.ali | ||
../lua-lib.ali | ||
../lua-config.ali | ||
../lua-ext.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
registered panic handler | ||
causing panic... | ||
inside raiser.raiser... | ||
caught raiser.raiser_error | ||
[0] pass: caught exception | ||
inside Raiser.Raiser... | ||
Caught Raiser.Raiser_Error | ||
[0] Pass: Caught exception |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
gcc-4.3 | ||
gcc43 | ||
|
||
The first line of this file is used as the path or location of the Ada compiler. | ||
This program is used to compile single source files into object files. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
gcc-4.3 | ||
gcc43 | ||
|
||
The first line of this file is used as the path or location of the C compiler. | ||
This program is used to compile single source files into object files. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
gcc-4.3 | ||
gcc43 | ||
|
||
The first line of this file is used as the path or location of the C linker. | ||
This program is used to combine object files and libraries into executables. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
lua-check_raise.o | ||
lua-config.o | ||
lua-ext.o | ||
lua-lib.o | ||
lua-user_data.o | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
lua_check_exception.ali | ||
lua-check_raise.ali | ||
lua-ext.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package body Lua.Check_Raise is | ||
|
||
function Check_Raise (State : Lua.State_t) return Lua.Integer_t is | ||
use type Lua.State_t; | ||
begin | ||
pragma Assert (State /= Lua.State_Error); | ||
raise Check_Raise_Error; | ||
return 0; | ||
end Check_Raise; | ||
|
||
end Lua.Check_Raise; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package Lua.Check_Raise is | ||
|
||
function Check_Raise (State : Lua.State_t) return Lua.Integer_t; | ||
pragma Convention (C, Check_Raise); | ||
|
||
Check_Raise_Error : exception; | ||
|
||
end Lua.Check_Raise; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Lua.Check_Raise lua-check_raise.ads lua-check_raise.adb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
lua-config.ads: lua-config.sh lua-check-exception | ||
./lua-config.sh > lua-config.ads.tmp && mv lua-config.ads.tmp lua-config.ads |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Lua.Config lua-config.ads |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/sh | ||
|
||
cleanup() | ||
{ | ||
|
||
} | ||
|
||
fatal() | ||
{ | ||
echo "fatal: $1" 1>&2 | ||
cleanup | ||
exit 1 | ||
} | ||
|
||
ret_text=`./lua-check-exception` | ||
ret_code=$? | ||
if [ $ret_code -eq 0 ] | ||
then | ||
can_catch="True" | ||
else | ||
can_catch="False" | ||
fi | ||
|
||
cat <<EOF | ||
package Lua.Config is | ||
Can_Propagate_Exceptions : constant Boolean := ${can_catch}; | ||
end Lua.Config; | ||
EOF | ||
|
||
cleanup | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
with Lua; | ||
with Lua.Check_Raise; | ||
|
||
procedure Lua_Check_Exception is | ||
State : Lua.State_t; | ||
Caught : Boolean := False; | ||
|
||
use type Lua.State_t; | ||
use type Lua.Number_t; | ||
begin | ||
State := Lua.Open; | ||
|
||
if State = Lua.State_Error then | ||
raise Program_Error; | ||
end if; | ||
|
||
Lua.At_Panic | ||
(State => State, | ||
Panic_Function => Lua.Check_Raise.Check_Raise'Access); | ||
|
||
begin | ||
Lua.Push_Number (State, -1.0); | ||
Lua.Call (State, 1, 1); | ||
exception | ||
when Lua.Check_Raise.Check_Raise_Error => Caught := True; | ||
end; | ||
|
||
if not Caught then | ||
raise Program_Error; | ||
end if; | ||
|
||
end Lua_Check_Exception; |