Skip to content

Commit 7aefa7d

Browse files
authored
Merge pull request #31 from jvelilla/master
Merged with Larry Rix code
2 parents 4cd5c7c + c96545f commit 7aefa7d

File tree

7 files changed

+226
-100
lines changed

7 files changed

+226
-100
lines changed

src/ewg/ewg.e

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ note
1212
class EWG
1313

1414
inherit
15-
EWG_KERNAL
15+
EWG_KERNEL
1616
redefine
1717
make,
1818
process_arguments
@@ -114,13 +114,14 @@ feature -- Basic Operations
114114
-- Process arguments (using the obsolete syntax)
115115
local
116116
header_file_name: STRING
117-
l_path: PATH
118117
do
119-
if match_long_option ("output-dir") then
120-
if is_next_option_long_option and then has_next_option_value then
121-
output_directory_name := next_option_value
122-
consume_option
123-
end
118+
if
119+
match_long_option ("output-dir") and then
120+
is_next_option_long_option and then
121+
has_next_option_value
122+
then
123+
output_directory_name := next_option_value
124+
consume_option
124125
end
125126

126127
if not match_long_option ("full-header") then
@@ -150,9 +151,7 @@ feature -- Basic Operations
150151
consume_option
151152
end
152153

153-
create l_path.make_from_string (header_file_name)
154-
header_file_name := l_path.entry.out
155-
154+
header_file_name := (create {PATH}.make_from_string (header_file_name)).entry.out
156155

157156
if match_long_option ("config") then
158157
if is_next_option_long_option and then has_next_option_value then

src/ewg/ewg_command_line_parser.e

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,37 @@ feature -- Operations
4646

4747
feature -- Status report
4848

49+
has_long_option (an_option_name: STRING): BOOLEAN
50+
-- Is there a long option on the command-line whose name is
51+
-- `an_option_name' (note that `an_option_name' does not
52+
-- contain the leading '--' characters)?
53+
require
54+
an_option_name_not_void: an_option_name /= Void
55+
local
56+
i: INTEGER
57+
arg: STRING
58+
nb: INTEGER
59+
do
60+
from
61+
i := 1
62+
until
63+
(i > Arguments.argument_count) or Result
64+
loop
65+
arg := Arguments.argument (i)
66+
nb := an_option_name.count + 2
67+
if
68+
arg.count >= nb and then
69+
(arg.item (1) = '-' and
70+
arg.item (2) = '-') and then
71+
STRING_.same_string (arg.substring (3, nb), an_option_name)
72+
then
73+
Result := arg.count = nb or else arg.item (nb + 1) = '='
74+
end
75+
76+
i := i + 1
77+
end
78+
end
79+
4980
has_next_option: BOOLEAN
5081
-- Is there an unconsumed token left?
5182
do
@@ -75,7 +106,7 @@ feature -- Status report
75106
do
76107
arg := next_option
77108
i := arg.index_of ('=', 1)
78-
Result := (i >= 1 and i < arg.count)
109+
Result := i >= 1 and i < arg.count
79110
end
80111

81112
feature -- Access
@@ -96,12 +127,10 @@ feature -- Access
96127
next_option_is_long_option: is_next_option_long_option
97128
has_next_option_value: has_next_option_value
98129
local
99-
i: INTEGER
100130
arg: STRING
101131
do
102132
arg := next_option
103-
i := arg.index_of ('=', 1)
104-
Result := arg.substring (i + 1, arg.count)
133+
Result := arg.substring (arg.index_of ('=', 1) + 1, arg.count)
105134
ensure
106135
next_option_value_not_void: Result /= Void
107136
end
@@ -128,7 +157,7 @@ feature -- Matching
128157
arg.item (2) = '-') and then
129158
STRING_.same_string (arg.substring (3, nb), an_option_name)
130159
then
131-
Result := (arg.count = nb or else arg.item (nb + 1) = '=')
160+
Result := arg.count = nb or else arg.item (nb + 1) = '='
132161
end
133162
end
134163
end
@@ -141,40 +170,7 @@ feature {NONE} -- Implementation
141170
is_valid_option_position (i: INTEGER): BOOLEAN
142171
-- Is `i' a valid token position?
143172
do
144-
Result := (i >= 1 and i <= Arguments.argument_count)
145-
end
146-
147-
feature -- Status report
148-
149-
has_long_option (an_option_name: STRING): BOOLEAN
150-
-- Is there a long option on the command-line whose name is
151-
-- `an_option_name' (note that `an_option_name' does not
152-
-- contain the leading '--' characters)?
153-
require
154-
an_option_name_not_void: an_option_name /= Void
155-
local
156-
i: INTEGER
157-
arg: STRING
158-
nb: INTEGER
159-
do
160-
from
161-
i := 1
162-
until
163-
(i > Arguments.argument_count) or Result
164-
loop
165-
arg := Arguments.argument (i)
166-
nb := an_option_name.count + 2
167-
if
168-
arg.count >= nb and then
169-
(arg.item (1) = '-' and
170-
arg.item (2) = '-') and then
171-
STRING_.same_string (arg.substring (3, nb), an_option_name)
172-
then
173-
Result := (arg.count = nb or else arg.item (nb + 1) = '=')
174-
end
175-
176-
i := i + 1
177-
end
173+
Result := i >= 1 and i <= Arguments.argument_count
178174
end
179175

180176
end

src/ewg/ewg_kernal.e renamed to src/ewg/ewg_kernel.e

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ note
2222

2323

2424
deferred class
25-
EWG_KERNAL
25+
EWG_KERNEL
2626

2727
inherit
2828
ANY
@@ -67,7 +67,6 @@ feature -- Basic Ops: Primary
6767
file: KL_TEXT_INPUT_FILE
6868
rule: EWG_CONFIG_RULE
6969
matching_clause: EWG_CONFIG_MATCHING_CLAUSE
70-
wrapper_clause: EWG_CONFIG_DEFAULT_WRAPPER_CLAUSE
7170
do
7271
if config_file_name /= Void then
7372
create parser.make (error_handler)
@@ -82,8 +81,7 @@ feature -- Basic Ops: Primary
8281
end
8382
else
8483
create matching_clause.make
85-
create wrapper_clause.make
86-
create rule.make (matching_clause, wrapper_clause)
84+
create rule.make (matching_clause, create {EWG_CONFIG_DEFAULT_WRAPPER_CLAUSE}.make)
8785
config_system.append_rule (rule)
8886
end
8987
if error_handler.has_error then
@@ -310,7 +308,7 @@ feature -- Basic Ops: Sub-supporting
310308
error_handler.report_info_message (l_cmd)
311309
-- To be updated.
312310
l_index := l_result.error_output.index_of ('.', 1) - 1
313-
l_name := l_result.error_output.substring (1, l_index)
311+
l_name := l_result.error_output.to_string_8.substring (1, l_index)
314312
l_name.append_string ("_cpp.h")
315313
cpp_header_file_name := l_name.twin
316314
create l_file.make_create_read_write (l_name)
@@ -376,7 +374,7 @@ feature -- Execute Plugin scripts
376374
report_info_message ("[Execute pre process script]")
377375
else
378376
-- Error
379-
report_info_message (l_result.error_output)
377+
report_info_message (l_result.error_output.to_string_8)
380378
end
381379
else
382380
report_info_message ("Script not found " + l_script )
@@ -394,7 +392,7 @@ feature -- Execute Plugin scripts
394392
report_info_message ("[Execute post process script]")
395393
else
396394
-- Error
397-
report_info_message (l_result.error_output)
395+
report_info_message (l_result.error_output.to_string_8)
398396
end
399397
else
400398
report_info_message ("Script not found " + l_script )

wrapcui/Readme.md

Lines changed: 141 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,142 @@
1-
WrapcUI
1+
# WrapcUI
22

3-
This code depends on URI launcher a library that you will need to download at https://svn.eiffel.com/eiffelstudio/trunk/Src
4-
To use this tool set the environment variable %EIFFEL_SRC% to the directory where you checkout the code.
3+
## Note
4+
> This code depends on URI launcher, a library you will need to download at https://svn.eiffel.com/eiffelstudio/trunk/Src.
5+
> To use this tool, ensure you have set the environment variable %EIFFEL_SRC% to the directory where you have checked out the code.
6+
7+
## Compiling
8+
9+
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.
10+
11+
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.
12+
13+
### Execution in Workbench
14+
15+
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.
16+
17+
## Using
18+
19+
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.
20+
21+
* Manually set each option as needed by your project.
22+
* Open options previously set and saved as an XML-based WrapCUI configuration file (named whatever you like, with whatever extension you like).
23+
24+
### Manual Option Setting
25+
26+
Before setting options for full-header and output-dir, you will need to:
27+
28+
* Download your target C project, which will have your target header (*.h) file.
29+
* Create your target output directory.
30+
31+
#### Full Header Option
32+
33+
Manaully type the full or relative path (relative to your current directory) to your target header file.
34+
35+
Alternatively, use the `...` button to set the full path using the file-open dialog that appears.
36+
37+
#### Output Directory Option
38+
39+
Manually type the full or relative path to your target output directory.
40+
41+
Alternatively, use the `...` button to set the full path using the directory dialog that appears.
42+
43+
#### C-compiler Options
44+
45+
Manually enter any C compiler options as needed.
46+
47+
#### Pre-process Script
48+
49+
Manually enter the full or relative path to a pre-process script, as needed.
50+
51+
#### Post-process Script
52+
53+
Manually enter the full or relative path to a post-process script, as needed.
54+
55+
#### Config XML File
56+
57+
Manually type the full or relative path to a config.xml (or other name) file, as needed.
58+
59+
Alternatively, use the `...` button to set the full path to a config.xml file using the file-open dialog that appears.
60+
61+
## Next Steps
62+
63+
Once all of the options are set, you have several steps available to you.
64+
65+
* `Save` the configuration in an XML file. Do this if you desire to quickly and easily reload the configuration you've just created.
66+
* `Clean` the output directory (delete all files and folders in it)
67+
* `Run` WrapC with the configuration you have set up or loaded (`File->Open`)
68+
69+
#### Note on Cleaning
70+
71+
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.
72+
# WrapcUI
73+
74+
## Note
75+
> This code depends on URI launcher, a library you will need to download at https://svn.eiffel.com/eiffelstudio/trunk/Src.
76+
> To use this tool, ensure you have set the environment variable %EIFFEL_SRC% to the directory where you have checked out the code.
77+
78+
## Compiling
79+
80+
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.
81+
82+
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.
83+
84+
### Execution in Workbench
85+
86+
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.
87+
88+
## Using
89+
90+
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.
91+
92+
* Manually set each option as needed by your project.
93+
* Open options previously set and saved as an XML-based WrapCUI configuration file (named whatever you like, with whatever extension you like).
94+
95+
### Manual Option Setting
96+
97+
Before setting options for full-header and output-dir, you will need to:
98+
99+
* Download your target C project, which will have your target header (*.h) file.
100+
* Create your target output directory.
101+
102+
#### Full Header Option
103+
104+
Manaully type the full or relative path (relative to your current directory) to your target header file.
105+
106+
Alternatively, use the `...` button to set the full path using the file-open dialog that appears.
107+
108+
#### Output Directory Option
109+
110+
Manually type the full or relative path to your target output directory.
111+
112+
Alternatively, use the `...` button to set the full path using the directory dialog that appears.
113+
114+
#### C-compiler Options
115+
116+
Manually enter any C compiler options as needed.
117+
118+
#### Pre-process Script
119+
120+
Manually enter the full or relative path to a pre-process script, as needed.
121+
122+
#### Post-process Script
123+
124+
Manually enter the full or relative path to a post-process script, as needed.
125+
126+
#### Config XML File
127+
128+
Manually type the full or relative path to a config.xml (or other name) file, as needed.
129+
130+
Alternatively, use the `...` button to set the full path to a config.xml file using the file-open dialog that appears.
131+
132+
## Next Steps
133+
134+
Once all of the options are set, you have several steps available to you.
135+
136+
* `Save` the configuration in an XML file. Do this if you desire to quickly and easily reload the configuration you've just created.
137+
* `Clean` the output directory (delete all files and folders in it)
138+
* `Run` WrapC with the configuration you have set up or loaded (`File->Open`)
139+
140+
#### Note on Cleaning
141+
142+
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/wrapcui.ecf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<library name="vision2" location="$ISE_LIBRARY\library\vision2\vision2.ecf"/>
2424
<library name="vision2_extension" location="$ISE_LIBRARY\library\vision2_extension\vision2_extension.ecf"/>
2525
<library name="xml_parser" location="$ISE_LIBRARY\library\text\parser\xml\parser\xml_parser.ecf"/>
26+
<library name="uri_launcher" location="$EIFFEL_SRC\framework\uri_launcher\uri_launcher.ecf"/>
2627
<cluster name="wrapcui" location=".\" recursive="true">
2728
<file_rule>
2829
<exclude>/.git$</exclude>

0 commit comments

Comments
 (0)