Skip to content

Commit

Permalink
* merge
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnpringle committed Feb 7, 2015
2 parents 21a91e2 + 92f7bdc commit 91a599b
Show file tree
Hide file tree
Showing 49 changed files with 859 additions and 187 deletions.
99 changes: 92 additions & 7 deletions demo/dsearch.ex
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
--****
-- === win32/dsearch.exw
-- === dsearch.ex
--
-- search for a .DLL that contains a given routine
-- ==== Usage
-- {{{
-- eui dsearch [routine]
-- eui dsearch [options] [routine]
-- }}}
--
-- If you don't supply a string on the command line you will be prompted
-- //Options// are any combination of ##-h##, ##-a##. ##-q##. ##-l //library//##
-- ##--help##, ##--lib //library//##, ##--all##, and ##--quiet##.
--
-- |Long Option|Short Option|Meaning|
-- |--all |-a| don't stop at the first occurence of //routine//, find all occurences of //routine//. This implies the '--quiet' option.|
-- |--help |-h| show the user help|
-- |--lib //library// |-l //library//| search only //library// for the routine|
-- |--quiet |-q| don't print the library filenames that are searched|
--
-- If you don't supply a string on the command line, you will be prompted
-- for it.
--

Expand All @@ -21,6 +30,7 @@ include std/error.e
include std/sequence.e as stdseq
include std/io.e
include std/console.e
include std/search.e

constant TRUE = 1, FALSE = 0

Expand All @@ -38,6 +48,8 @@ integer scanned, no_open
scanned = 0
no_open = 0

boolean only_first = TRUE, found_at_least_one = FALSE, quiet = FALSE

ifdef WINDOWS then
c_routine FreeLibrary, GetProcAddress, OpenLibrary
end ifdef
Expand Down Expand Up @@ -117,7 +129,7 @@ end type

function dl_open(sequence name)
ifdef WINDOWS then
return eu:open_dll(name)
return open_dll(name)
elsifdef LINUX then
atom name_string_pointer = allocate_string(name, TRUE)
object pipe = pipeio:exec( "nm -D " & name, pipeio:create() )
Expand Down Expand Up @@ -204,7 +216,9 @@ function scan(sequence file_name)
puts(io:STDERR, file_name & ": Couldn't open.\n")
return 0
end if
printf(io:STDOUT, "%s: ", {file_name})
if not quiet then
printf(io:STDOUT, "%s: ", {file_name})
end if
scanned += 1
found_in_file = FALSE
if dl_sym(lib, routine_name) then
Expand Down Expand Up @@ -236,6 +250,7 @@ for i = 1 to length(file_list) by 2 do
end for
end for

<<<<<<< local
CSetup()

cmd = command_line() -- eui dsearch [string]
Expand Down Expand Up @@ -264,20 +279,90 @@ procedure locate(sequence name)
routine_name = name
puts(io:STDOUT, "Looking for " & routine_name & "\n ")
for i = 1 to length(dll_list) do
if scan(dll_list[i]) then
if scan(dll_list[i]) and only_first then
console:any_key("Press any key to exit..", io:STDOUT)
abort(1)
end if
end for
puts(1, '\n')
end procedure

CSetup()

cmd = command_line() -- eui dsearch [string]


orig_string = ""
integer cmd_i = 3
while cmd_i <= length(cmd) do
sequence arg = cmd[cmd_i]
if search:begins(arg, "--help") then
puts(io:STDOUT,
"""eui dsearch.ex [options] c_function_name
--all : find all such libraries with the named function (implies -quiet)
--help : display this help message
--lib : use the argument following lib as the sole library to search
--quiet : do not display searched libraries while running.
""" )
abort(0)
elsif search:begins(arg, "--lib") then
if cmd_i < length(cmd) then
dll_list = {cmd[cmd_i+1]}
cmd_i += 1
end if
elsif search:begins(arg, "--all") then
only_first = FALSE
quiet = TRUE
elsif search:begins(arg, "--quiet") then
quiet = TRUE
elsif length(arg) > 1 and arg[1] = '-' and arg[2] != '-' then
sequence new_arg = {}
for ai = 2 to length(arg) do
integer c = arg[ai]
switch c do
case 'h' then
new_arg = append(new_arg, "--help")
case 'a' then
new_arg = append(new_arg, "--all")
case 'q' then
new_arg = append(new_arg, "--quiet")
case 'l' then
new_arg = append(new_arg, "--lib")
if length(arg) > ai then
new_arg = append(new_arg, arg[ai+1..$])
exit
end if
case else
printf(io:STDERR, "Unknown option %s\n", {c})
abort(0)
end switch
end for
-- replace arguments and avoid cmd_i increment.
cmd = cmd[1..cmd_i-1] & new_arg & cmd[cmd_i+1..$]
continue
elsif length(arg) >= 1 and arg[1]= '-' then
printf(io:STDERR, "Unknown option %s\n", {arg})
abort(0)
else
orig_string = arg
end if
cmd_i += 1
end while

if equal(orig_string,"") then
orig_string = delete_trailing_white( console:prompt_string("C function name:") )
end if

routine_name = orig_string

if length(routine_name) = 0 then
abort(0)
end if

locate(orig_string)

puts(io:STDOUT, "\nCouldn't find " & orig_string & '\n')
if not found_at_least_one then
puts(io:STDOUT, "\nCouldn't find " & orig_string & '\n')
end if
console:any_key("Press any key to exit..", io:STDOUT)

2 changes: 1 addition & 1 deletion docs/manual.af
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ ifdef HTML
../demo/color.ex
../demo/csort.ex
../demo/dep.exw
../demo/dsearch.ex
../demo/eprint.ex
../demo/eused.ex
../demo/guru.ex
Expand All @@ -120,7 +121,6 @@ ifdef HTML
../demo/tree.ex
../demo/where.ex
../demo/bench/sieve8k.ex
../demo/win32/dsearch.exw
../demo/win32/taskwire.exw
../demo/win32/window.exw
../demo/win32/winwire.exw
Expand Down
58 changes: 38 additions & 20 deletions docs/refman_2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,7 @@ There is also a special form of ##enum##, an //enum type//. This is a simple way
to write a user-defined type based on the set of values in a specific enum
group.
The type created this way can be used anywhere a normal user-defined type can be
use.
used.

For example,
<eucode>
Expand All @@ -1516,32 +1516,33 @@ end procedure
However there is one significant difference when it comes to enum types. For
normal types, when calling the type function, it returns either ##0## or ##1##.
The enum type function returns ##0## if the argument is not a member of the
enum set, and it
returns a positive integer when the argument is a member. The value returned is
the ordinal number of
the member in the enum's definition, regardless of what the member's value is.
As an exception to this, if two enums share the same value, then they will
share the same ordinal number. The ordinal numbers of enums surrounding these
will continue to increment as if every enum had a unique ordinal number,
causing some numbers to be skipped.
enum set, and it returns a non-zero atom when the argument is a member. The value returned might be ##1## or it might not be ##1##. Don't rely on the type returning one. In EUPHORIA any atom that is not ##0## is true. The non-zero value returned will defer between 4.0 and 4.1.

For example,
<eucode>
enum type color RED=4, GREEN=7, BLACK=1, BLUE=3 , PINK=10 end type

? color(RED) --> 1
? color(GREEN) --> 2
? color(BLACK) --> 3
? color(BLUE) --> 4
? color(PINK) --> 5
-- color(RED) --> TRUE but might not be 1.
if color(GREEN) then -- good.
-- do stuff
end if

constant color_names = {"rouge", "vert", "noir", "bleu", "rose"}
-- color(BLUE) --> also TRUE but might not be 1.
if color(BLUE) = 1 then -- BAD, very BAD.
-- BLUE is a color but this branch might not get executed.
-- do stuff
end if

puts(1, color_names[color(BLUE)]) --> bleu
-- As a matter of style you may compare to 0.
if color(BLACK) != 0 then -- good. Any non-zero is true in EUPHORIA
-- So, compare to 0 if you wish.
-- do stuff
end if

</eucode>

But with the exception,
But with the exception,

<eucode>
enum type color RED, GREEN=7, BLACK=1, BLUE=3 , PINK=10 end type
? color(RED) --> 1
Expand All @@ -1550,10 +1551,28 @@ enum type color RED, GREEN=7, BLACK=1, BLUE=3 , PINK=10 end type
? color(BLUE) --> 4
? color(PINK) --> 5
</eucode>

Note that none of the enums have an ordinal number with a value of 3. This is
simply skipped.

<eucode>
enum by DELTA member1, member2, ... ,memberN
</eucode>
where ##'DELTA'## is a literal number with an optional operation code
(##*, +, -, /##) preceding it.

Examples:
<eucode>
enum by 2 A,B,C=6,D --> values are 1,3,6,8
enum by -2 A=10,B,C,D --> values are 10,8,6,4
enum by * 2 A,B,C,D,E --> values are 1,2,4,8,16
enum by / 3 A=81,B,C,D,E --> values are 81,27,9,3,1
</eucode>

Also note that enum members do not have to be integers.
<eucode>
enum by / 2 A=5,B,C --> values are 5, 2.5, 1.25
</eucode>


=== Specifying the type of a variable

Expand Down Expand Up @@ -2798,8 +2817,7 @@ Euphoria predefines some words itself:

Euphoria is released with the common version scheme of Major, Minor and Release
version identifiers in the form of major.minor.release. When 4.1.1 is
released, ##EU4_1_1## will be defined and ##EU4_1## will still be defined, but ##EU4_1_0## will no longer be defined. When 4.2 is released, ##EU4_1## will no longer be defined, but ##EU4_2## will be defined. Finally, when 5.0 is released, ##EU4## will no longer be
defined, but ##EU5## will be defined.
released, ##EU4_1_1## will be defined and ##EU4_1## will still be defined, but ##EU4_1_0## will no longer be defined. When 4.2 is released, ##EU4_1## will no longer be defined, but ##EU4_2## will be defined. Finally, when 5.0 is released, ##EU4## will no longer be defined, but ##EU5## will be defined.

==== Platform Definitions

Expand Down
4 changes: 4 additions & 0 deletions docs/release/4.0.6.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

=== Bug Fixes

* [[ticket:893]] Backported map fixes to 4.0
* [[ticket:877]] Fixed the bug where some very large values or very small values might give silly results.
* [[ticket:901]] Made dsearch.exw into a portable demo, [[:dsearch.ex]], for both Windows and Linux
* [[ticket:881]] In frontend, update previous op cache when an assignment gets optimized out.
* [[ticket:872]] fix documentation error involving ##[[:or_all]]##
* [[ticket:880]] fix documentaiton error involving ##[[:poke2]]##
* [[ticket:708]] specified that color triples are specified between 0..255 in ##[[:read_bitmap]]## and ##[[:save_bitmap]]##.
Expand Down
Loading

0 comments on commit 91a599b

Please sign in to comment.