Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions src/ewg/ewg.e
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ note
class EWG

inherit
EWG_KERNAL
EWG_KERNEL
redefine
make,
process_arguments
Expand Down Expand Up @@ -114,13 +114,14 @@ feature -- Basic Operations
-- Process arguments (using the obsolete syntax)
local
header_file_name: STRING
l_path: PATH
do
if match_long_option ("output-dir") then
if is_next_option_long_option and then has_next_option_value then
output_directory_name := next_option_value
consume_option
end
if
match_long_option ("output-dir") and then
is_next_option_long_option and then
has_next_option_value
then
output_directory_name := next_option_value
consume_option
end

if not match_long_option ("full-header") then
Expand Down Expand Up @@ -150,9 +151,7 @@ feature -- Basic Operations
consume_option
end

create l_path.make_from_string (header_file_name)
header_file_name := l_path.entry.out

header_file_name := (create {PATH}.make_from_string (header_file_name)).entry.out

if match_long_option ("config") then
if is_next_option_long_option and then has_next_option_value then
Expand Down
74 changes: 35 additions & 39 deletions src/ewg/ewg_command_line_parser.e
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,37 @@ feature -- Operations

feature -- Status report

has_long_option (an_option_name: STRING): BOOLEAN
-- Is there a long option on the command-line whose name is
-- `an_option_name' (note that `an_option_name' does not
-- contain the leading '--' characters)?
require
an_option_name_not_void: an_option_name /= Void
local
i: INTEGER
arg: STRING
nb: INTEGER
do
from
i := 1
until
(i > Arguments.argument_count) or Result
loop
arg := Arguments.argument (i)
nb := an_option_name.count + 2
if
arg.count >= nb and then
(arg.item (1) = '-' and
arg.item (2) = '-') and then
STRING_.same_string (arg.substring (3, nb), an_option_name)
then
Result := arg.count = nb or else arg.item (nb + 1) = '='
end

i := i + 1
end
end

has_next_option: BOOLEAN
-- Is there an unconsumed token left?
do
Expand Down Expand Up @@ -75,7 +106,7 @@ feature -- Status report
do
arg := next_option
i := arg.index_of ('=', 1)
Result := (i >= 1 and i < arg.count)
Result := i >= 1 and i < arg.count
end

feature -- Access
Expand All @@ -96,12 +127,10 @@ feature -- Access
next_option_is_long_option: is_next_option_long_option
has_next_option_value: has_next_option_value
local
i: INTEGER
arg: STRING
do
arg := next_option
i := arg.index_of ('=', 1)
Result := arg.substring (i + 1, arg.count)
Result := arg.substring (arg.index_of ('=', 1) + 1, arg.count)
ensure
next_option_value_not_void: Result /= Void
end
Expand All @@ -128,7 +157,7 @@ feature -- Matching
arg.item (2) = '-') and then
STRING_.same_string (arg.substring (3, nb), an_option_name)
then
Result := (arg.count = nb or else arg.item (nb + 1) = '=')
Result := arg.count = nb or else arg.item (nb + 1) = '='
end
end
end
Expand All @@ -141,40 +170,7 @@ feature {NONE} -- Implementation
is_valid_option_position (i: INTEGER): BOOLEAN
-- Is `i' a valid token position?
do
Result := (i >= 1 and i <= Arguments.argument_count)
end

feature -- Status report

has_long_option (an_option_name: STRING): BOOLEAN
-- Is there a long option on the command-line whose name is
-- `an_option_name' (note that `an_option_name' does not
-- contain the leading '--' characters)?
require
an_option_name_not_void: an_option_name /= Void
local
i: INTEGER
arg: STRING
nb: INTEGER
do
from
i := 1
until
(i > Arguments.argument_count) or Result
loop
arg := Arguments.argument (i)
nb := an_option_name.count + 2
if
arg.count >= nb and then
(arg.item (1) = '-' and
arg.item (2) = '-') and then
STRING_.same_string (arg.substring (3, nb), an_option_name)
then
Result := (arg.count = nb or else arg.item (nb + 1) = '=')
end

i := i + 1
end
Result := i >= 1 and i <= Arguments.argument_count
end

end
12 changes: 5 additions & 7 deletions src/ewg/ewg_kernal.e → src/ewg/ewg_kernel.e
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ note


deferred class
EWG_KERNAL
EWG_KERNEL

inherit
ANY
Expand Down Expand Up @@ -67,7 +67,6 @@ feature -- Basic Ops: Primary
file: KL_TEXT_INPUT_FILE
rule: EWG_CONFIG_RULE
matching_clause: EWG_CONFIG_MATCHING_CLAUSE
wrapper_clause: EWG_CONFIG_DEFAULT_WRAPPER_CLAUSE
do
if config_file_name /= Void then
create parser.make (error_handler)
Expand All @@ -82,8 +81,7 @@ feature -- Basic Ops: Primary
end
else
create matching_clause.make
create wrapper_clause.make
create rule.make (matching_clause, wrapper_clause)
create rule.make (matching_clause, create {EWG_CONFIG_DEFAULT_WRAPPER_CLAUSE}.make)
config_system.append_rule (rule)
end
if error_handler.has_error then
Expand Down Expand Up @@ -310,7 +308,7 @@ feature -- Basic Ops: Sub-supporting
error_handler.report_info_message (l_cmd)
-- To be updated.
l_index := l_result.error_output.index_of ('.', 1) - 1
l_name := l_result.error_output.substring (1, l_index)
l_name := l_result.error_output.to_string_8.substring (1, l_index)
l_name.append_string ("_cpp.h")
cpp_header_file_name := l_name.twin
create l_file.make_create_read_write (l_name)
Expand Down Expand Up @@ -376,7 +374,7 @@ feature -- Execute Plugin scripts
report_info_message ("[Execute pre process script]")
else
-- Error
report_info_message (l_result.error_output)
report_info_message (l_result.error_output.to_string_8)
end
else
report_info_message ("Script not found " + l_script )
Expand All @@ -394,7 +392,7 @@ feature -- Execute Plugin scripts
report_info_message ("[Execute post process script]")
else
-- Error
report_info_message (l_result.error_output)
report_info_message (l_result.error_output.to_string_8)
end
else
report_info_message ("Script not found " + l_script )
Expand Down
144 changes: 141 additions & 3 deletions wrapcui/Readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,142 @@
WrapcUI
# WrapcUI

This code depends on URI launcher a library that you will need to download at https://svn.eiffel.com/eiffelstudio/trunk/Src
To use this tool set the environment variable %EIFFEL_SRC% to the directory where you checkout the code.
## Note
> This code depends on URI launcher, a library you will need to download at https://svn.eiffel.com/eiffelstudio/trunk/Src.
> To use this tool, ensure you have set the environment variable %EIFFEL_SRC% to the directory where you have checked out the code.

## Compiling

The WrapC UI project consists of two targets: `wrapcui` and `test`. The `wrapcui` is the production target, where you will finalize an executable. The `test` target is dedicated to writing and executing tests against the production target code. Presently, there is but one test, which was used to prove the code that parses the wrapcui configuration "Save" file, which is just XML.

To create a finalized executable, open the `wrapcui` target and compile (or clean compile if needed). With a successful compile, Ctrl-Shift-F7 or select `Finalize` from the `Project` menu option. The executable will be produced in the `F_code` folder under your EIFGENs folder in the project folder. Move the executable to a folder of your choice and ensure you have set a proper PATH to it for later.

### Execution in Workbench

If you run WrapCUI in EiffelStudio's Workbench mode, you may find that you encounter an error where the code is not creating the target output directory structure. This is a known limitation (bug perhaps). The code works in the finalized executable.

## Using

The UI code literally wraps the EWG code, which is the basis of the WrapC CLI project and executable. Therefore, the UI controls mimick the CLI options. When WrapCUI first opens, each of the text fields are blank (empty). From here, you have two choices.

* Manually set each option as needed by your project.
* Open options previously set and saved as an XML-based WrapCUI configuration file (named whatever you like, with whatever extension you like).

### Manual Option Setting

Before setting options for full-header and output-dir, you will need to:

* Download your target C project, which will have your target header (*.h) file.
* Create your target output directory.

#### Full Header Option

Manaully type the full or relative path (relative to your current directory) to your target header file.

Alternatively, use the `...` button to set the full path using the file-open dialog that appears.

#### Output Directory Option

Manually type the full or relative path to your target output directory.

Alternatively, use the `...` button to set the full path using the directory dialog that appears.

#### C-compiler Options

Manually enter any C compiler options as needed.

#### Pre-process Script

Manually enter the full or relative path to a pre-process script, as needed.

#### Post-process Script

Manually enter the full or relative path to a post-process script, as needed.

#### Config XML File

Manually type the full or relative path to a config.xml (or other name) file, as needed.

Alternatively, use the `...` button to set the full path to a config.xml file using the file-open dialog that appears.

## Next Steps

Once all of the options are set, you have several steps available to you.

* `Save` the configuration in an XML file. Do this if you desire to quickly and easily reload the configuration you've just created.
* `Clean` the output directory (delete all files and folders in it)
* `Run` WrapC with the configuration you have set up or loaded (`File->Open`)

#### Note on Cleaning

There is a bug in EWG we have not found yet where once you click `Run`, the code does not release its file handles. Attempting to run `Clean` after a `Run` will generate an error and the files and folders will not be deleted. In order to successfully `Clean`, you will need to ensure the configuration is `Save`d, close WrapCUI, re-open WrapCUI, `Open` the saved configuration, and then `Clean` it.
# WrapcUI

## Note
> This code depends on URI launcher, a library you will need to download at https://svn.eiffel.com/eiffelstudio/trunk/Src.
> To use this tool, ensure you have set the environment variable %EIFFEL_SRC% to the directory where you have checked out the code.

## Compiling

The WrapC UI project consists of two targets: `wrapcui` and `test`. The `wrapcui` is the production target, where you will finalize an executable. The `test` target is dedicated to writing and executing tests against the production target code. Presently, there is but one test, which was used to prove the code that parses the wrapcui configuration "Save" file, which is just XML.

To create a finalized executable, open the `wrapcui` target and compile (or clean compile if needed). With a successful compile, Ctrl-Shift-F7 or select `Finalize` from the `Project` menu option. The executable will be produced in the `F_code` folder under your EIFGENs folder in the project folder. Move the executable to a folder of your choice and ensure you have set a proper PATH to it for later.

### Execution in Workbench

If you run WrapCUI in EiffelStudio's Workbench mode, you may find that you encounter an error where the code is not creating the target output directory structure. This is a known limitation (bug perhaps). The code works in the finalized executable.

## Using

The UI code literally wraps the EWG code, which is the basis of the WrapC CLI project and executable. Therefore, the UI controls mimick the CLI options. When WrapCUI first opens, each of the text fields are blank (empty). From here, you have two choices.

* Manually set each option as needed by your project.
* Open options previously set and saved as an XML-based WrapCUI configuration file (named whatever you like, with whatever extension you like).

### Manual Option Setting

Before setting options for full-header and output-dir, you will need to:

* Download your target C project, which will have your target header (*.h) file.
* Create your target output directory.

#### Full Header Option

Manaully type the full or relative path (relative to your current directory) to your target header file.

Alternatively, use the `...` button to set the full path using the file-open dialog that appears.

#### Output Directory Option

Manually type the full or relative path to your target output directory.

Alternatively, use the `...` button to set the full path using the directory dialog that appears.

#### C-compiler Options

Manually enter any C compiler options as needed.

#### Pre-process Script

Manually enter the full or relative path to a pre-process script, as needed.

#### Post-process Script

Manually enter the full or relative path to a post-process script, as needed.

#### Config XML File

Manually type the full or relative path to a config.xml (or other name) file, as needed.

Alternatively, use the `...` button to set the full path to a config.xml file using the file-open dialog that appears.

## Next Steps

Once all of the options are set, you have several steps available to you.

* `Save` the configuration in an XML file. Do this if you desire to quickly and easily reload the configuration you've just created.
* `Clean` the output directory (delete all files and folders in it)
* `Run` WrapC with the configuration you have set up or loaded (`File->Open`)

#### Note on Cleaning

There is a bug in EWG we have not found yet where once you click `Run`, the code does not release its file handles. Attempting to run `Clean` after a `Run` will generate an error and the files and folders will not be deleted. In order to successfully `Clean`, you will need to ensure the configuration is `Save`d, close WrapCUI, re-open WrapCUI, `Open` the saved configuration, and then `Clean` it.
1 change: 1 addition & 0 deletions wrapcui/wrapcui.ecf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<library name="vision2" location="$ISE_LIBRARY\library\vision2\vision2.ecf"/>
<library name="vision2_extension" location="$ISE_LIBRARY\library\vision2_extension\vision2_extension.ecf"/>
<library name="xml_parser" location="$ISE_LIBRARY\library\text\parser\xml\parser\xml_parser.ecf"/>
<library name="uri_launcher" location="$EIFFEL_SRC\framework\uri_launcher\uri_launcher.ecf"/>
<cluster name="wrapcui" location=".\" recursive="true">
<file_rule>
<exclude>/.git$</exclude>
Expand Down
Loading