Moved gewf under draft/src/gewf

This commit is contained in:
2013-07-05 15:13:43 +02:00
parent f7012e5b85
commit 2676b16425
13 changed files with 0 additions and 0 deletions

3
draft/src/gewf/README.md Normal file
View File

@@ -0,0 +1,3 @@
The gewf tool, is an experimentation to generate EWF project from template.
status: experimental, POC, in-progress, draft

21
draft/src/gewf/gewf.ecf Normal file
View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-11-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-11-0 http://www.eiffel.com/developers/xml/configuration-1-11-0.xsd" name="gewf" uuid="2D4957D5-77D3-4EC7-BF80-E4E6AC7A3EF3">
<target name="gewf">
<description>Generator for EWF project </description>
<root class="GEWF" feature="make"/>
<file_rule>
<exclude>/.git$</exclude>
<exclude>/EIFGENs$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="transitional" syntax="standard">
</option>
<setting name="executable_name" value="gewf"/>
<setting name="concurrency" value="none"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="base_extension" location="$ISE_LIBRARY\library\base_extension\base_extension-safe.ecf"/>
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf"/>
<library name="uuid" location="$ISE_LIBRARY\library\uuid\uuid-safe.ecf"/>
<cluster name="src" location="src\" recursive="true"/>
</target>
</system>

View File

@@ -0,0 +1,10 @@
${NOTE_KEYWORD}
copyright: "2011-${YEAR}, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"

169
draft/src/gewf/src/gewf.e Normal file
View File

@@ -0,0 +1,169 @@
note
description : "Objects that ..."
author : "$Author$"
date : "$Date$"
revision : "$Revision$"
class
GEWF
create
make
feature {NONE} -- Initialization
make
-- Initialize `Current'.
local
args: ARGUMENTS_32
cfg: detachable READABLE_STRING_32
do
create args
if args.argument_count > 0 then
cfg := args.argument (1)
end
if cfg /= Void then
load_configuration (cfg)
end
execute
end
feature -- Status
feature -- Access
config (k: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
local
l_keys: LIST [READABLE_STRING_GENERAL]
do
if attached {JSON_STRING} json_item (json, k) as js then
Result := js.unescaped_string_32
end
end
json_item (j: detachable JSON_VALUE; k: READABLE_STRING_GENERAL): detachable JSON_VALUE
local
l_keys: LIST [READABLE_STRING_GENERAL]
v: detachable JSON_VALUE
s: STRING_32
js: JSON_STRING
do
if attached {JSON_OBJECT} j as jo then
l_keys := k.split ('.')
l_keys.start
create js.make_json_from_string_32 (l_keys.item.as_readable_string_32)
v := jo.item (js)
l_keys.remove
if l_keys.count > 0 then
if v /= Void then
create s.make (k.count)
across
l_keys as c
loop
s.append_string_general (c.item)
s.append_character ('.')
end
s.remove_tail (1)
Result := json_item (v, s)
end
else
Result := v
end
end
end
load_configuration (fn: READABLE_STRING_GENERAL)
local
p: JSON_PARSER
f: PLAIN_TEXT_FILE
s: STRING
do
create s.make (1_024)
create f.make_with_name (fn)
if f.exists and then f.is_access_readable then
f.open_read
from
until
f.exhausted
loop
f.read_stream_thread_aware (1_024)
s.append (f.last_string)
end
f.close
end
create p.make_parser (s)
json := p.parse
end
json: detachable JSON_VALUE
feature -- Execution
execute
local
tpl_name: READABLE_STRING_32
vals: STRING_TABLE [READABLE_STRING_8]
uuid_gen: UUID_GENERATOR
do
if attached config ("template") as s32 then
create vals.make (5)
tpl_name := s32
create uuid_gen
vals.force (uuid_gen.generate_uuid.out, "UUID")
if
attached config ("application.name") as appname
then
vals.force (appname.to_string_8, "APPNAME")
else
vals.force ("application", "APPNAME")
end
if
attached config ("application.root_class") as approot
then
vals.force (approot.to_string_8, "APP_ROOT")
else
vals.force ("APPLICATION", "APP_ROOT")
end
generate (tpl_name, vals)
else
io.error.put_string ("Error no template value! %N")
end
end
generate (tpl: READABLE_STRING_32; vals: STRING_TABLE [READABLE_STRING_8])
local
gen: GEWF_GENERATOR
p: PATH
appname: detachable READABLE_STRING_GENERAL
do
create p.make_from_string ("template")
p := p.extended (tpl)
appname := vals.item ("APPNAME")
if appname = Void then
appname := "_generated"
end
create gen.make (p, create {PATH}.make_from_string (appname))
gen.execute (vals)
end
feature {NONE} -- Implementation
invariant
-- invariant_clause: True
note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -0,0 +1,132 @@
note
description: "Summary description for {GEWF_GENERATOR}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
GEWF_GENERATOR
inherit
DIRECTORY_ITERATOR
redefine
process_directory,
process_file
end
create
make
feature {NONE} -- Initialization
make (tpl: PATH; tgt: PATH)
do
template_folder := tpl
target_folder := tgt
end
feature -- Execution
execute (vals: STRING_TABLE [READABLE_STRING_8])
do
values := vals
process_directory (template_folder)
values := Void
end
feature -- Operation
process_file (fn: PATH)
-- <Precursor>
local
s: STRING_32
line: STRING
src,tgt: RAW_FILE
do
create s.make_from_string (fn.name)
s := s.substring (template_folder.name.count + 2, s.count)
if attached fn.extension as ext and then ext.is_case_insensitive_equal ("tpl") then
s.remove_tail (4) -- ".tpl"
end
evaluate_string_32 (s)
s.to_lower
create src.make_with_path (fn)
create tgt.make_with_path (target_folder.extended (s))
tgt.create_read_write
src.open_read
from
until
src.exhausted
loop
src.read_line_thread_aware
line := src.last_string
evaluate_string_8 (line)
tgt.put_string (line)
tgt.put_new_line
end
src.close
tgt.close
-- Precursor (fn)
end
process_directory (dn: PATH)
-- <Precursor>
local
s: STRING_32
p: PATH
dir: DIRECTORY
do
create s.make_from_string (dn.name)
s := s.substring (template_folder.name.count + 1, s.count)
evaluate_string_32 (s)
p := target_folder.extended (s)
create dir.make_with_path (p)
dir.recursive_create_dir
Precursor (dn)
end
feature -- Access
values: detachable STRING_TABLE [READABLE_STRING_8]
template_folder: PATH
target_folder: PATH
feature -- Implementation
evaluate_string_8 (s: STRING_8)
do
if attached values as l_values then
across
l_values as c
loop
s.replace_substring_all ({STRING_8} "${" + c.key.as_string_8 + "}", c.item)
end
end
end
evaluate_string_32 (s: STRING_32)
do
if attached values as l_values then
across
l_values as c
loop
s.replace_substring_all ({STRING_32} "${" + c.key.as_string_32 + "}", c.item)
end
end
end
note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-10-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-10-0 http://www.eiffel.com/developers/xml/configuration-1-10-0.xsd" name="${APPNAME}" uuid="${UUID}" library_target="${APPNAME}">
<target name="common" abstract="true">
<file_rule>
<exclude>/EIFGENs$</exclude>
<exclude>/CVS$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
<option warning="true" is_attached_by_default="true" void_safety="all" syntax="transitional">
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-safe.ecf"/>
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
</target>
<target name="${APPNAME}_any" extends="common">
<root class="${APP_ROOT}" feature="make_and_launch"/>
<library name="cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\cgi-safe.ecf"/>
<library name="libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\libfcgi-safe.ecf"/>
<library name="nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\nino-safe.ecf"/>
<cluster name="launcher" location=".\launcher\any\" recursive="true"/>
<cluster name="src" location=".\src\" recursive="true"/>
</target>
<target name="${APPNAME}_nino" extends="common">
<root class="${APP_ROOT}" feature="make_and_launch"/>
<library name="default_nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\nino-safe.ecf"/>
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
<cluster name="src" location=".\src\" recursive="true"/>
</target>
<target name="${APPNAME}_cgi" extends="common">
<root class="${APP_ROOT}" feature="make_and_launch"/>
<library name="default_cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\cgi-safe.ecf"/>
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
<cluster name="src" location=".\src\" recursive="true"/>
</target>
<target name="${APPNAME}_libfcgi" extends="common">
<root class="${APP_ROOT}" feature="make_and_launch"/>
<library name="default_libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\libfcgi-safe.ecf"/>
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
<cluster name="src" location=".\src\" recursive="true"/>
</target>
<target name="${APPNAME}" extends="${APPNAME}_nino"/>
</system>

View File

@@ -0,0 +1,8 @@
<target name="${APPNAME}_any" extends="_common">
<root class="${APP_ROOT}" feature="make_and_launch"/>
<library name="cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\cgi-safe.ecf"/>
<library name="libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\libfcgi-safe.ecf"/>
<library name="nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\nino-safe.ecf"/>
<cluster name="launcher" location=".\launcher\any\" recursive="true"/>
<cluster name="src" location=".\src\" recursive="true"/>
</target>

View File

@@ -0,0 +1,6 @@
<target name="${APPNAME}_${EWF.connector}" extends="_common">
<root class="${APP_ROOT}" feature="make_and_launch"/>
<library name="default_${EWF.connector}" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\${EWF.connector}-safe.ecf"/>
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
<cluster name="src" location=".\src\" recursive="true"/>
</target>

View File

@@ -0,0 +1,85 @@
note
description: "Summary description for {APPLICATION_LAUNCHER}."
author: ""
date: "$Date: 2013-06-12 13:55:42 +0200 (mer., 12 juin 2013) $"
revision: "$Revision: 36 $"
deferred class
APPLICATION_LAUNCHER
feature {NONE} -- Initialization
launcher_nature: detachable READABLE_STRING_8
-- Initialize the launcher nature
-- either cgi, libfcgi, or nino.
--| We could extend with more connector if needed.
--| and we could use WSF_DEFAULT_SERVICE_LAUNCHER to configure this at compilation time.
local
p: PATH
l_entry_name: READABLE_STRING_32
ext: detachable READABLE_STRING_32
do
create p.make_from_string (execution_environment.arguments.command_name)
if attached p.entry as l_entry then
ext := l_entry.extension
end
if ext /= Void then
if ext.same_string (nature_nino) then
Result := nature_nino
end
if ext.same_string (nature_cgi) then
Result := nature_cgi
end
if ext.same_string (nature_libfcgi) or else ext.same_string ("fcgi") then
Result := nature_libfcgi
end
end
end
feature {NONE} -- nino
nature_nino: STRING = "nino"
launch_nino (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
do
create {WSF_NINO_SERVICE_LAUNCHER} launcher.make_and_launch (a_service, opts)
end
feature {NONE} -- cgi
nature_cgi: STRING = "cgi"
launch_cgi (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
do
create {WSF_CGI_SERVICE_LAUNCHER} launcher.make_and_launch (a_service, opts)
end
feature {NONE} -- libfcgi
nature_libfcgi: STRING = "libfcgi"
launch_libfcgi (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
do
create {WSF_LIBFCGI_SERVICE_LAUNCHER} launcher.make_and_launch (a_service, opts)
end
feature {NONE} -- Launcher
launch (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
local
nature: like launcher_nature
do
nature := launcher_nature
if nature = Void or else nature = nature_nino then
launch_nino (a_service, opts)
elseif nature = nature_cgi then
launch_cgi (a_service, opts)
elseif nature = nature_libfcgi then
launch_libfcgi (a_service, opts)
else
-- bye bye
(create {EXCEPTIONS}).die (-1)
end
end
end

View File

@@ -0,0 +1,19 @@
note
description: "Summary description for {APPLICATION}."
author: ""
date: "$Date: 2013-06-12 13:55:42 +0200 (mer., 12 juin 2013) $"
revision: "$Revision: 36 $"
deferred class
APPLICATION_LAUNCHER
feature {NONE} -- Launcher
launch (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
local
launcher: WSF_SERVICE_LAUNCHER
do
create {WSF_DEFAULT_SERVICE_LAUNCHER} launcher.make_and_launch (a_service, opts)
end
end

View File

@@ -0,0 +1,45 @@
note
description: "[
application service
]"
date: "$Date$"
revision: "$Revision$"
class
${APP_ROOT}
inherit
WSF_LAUNCHABLE_SERVICE
redefine
initialize
end
WSF_ROUTED_SERVICE
APPLICATION_LAUNCHER
create
make_and_launch
feature {NONE} -- Initialization
initialize
-- Initialize current service.
do
Precursor
set_service_option ("port", 9090)
initialize_router
end
setup_router
-- Setup `router'
local
fhdl: WSF_FILE_SYSTEM_HANDLER
do
router.handle_with_request_methods ("/doc", create {WSF_ROUTER_SELF_DOCUMENTATION_HANDLER}.make (router), router.methods_GET)
create fhdl.make_hidden (".")
fhdl.set_directory_index (<<"index.html">>)
router.handle_with_request_methods ("", fhdl, router.methods_GET)
end
end

View File

@@ -0,0 +1,9 @@
To generate "demo"
gewf demo.cfg
It will generate the project under demo\demo.ecf
note for now, the "template" folder should be in the current folder.

View File

@@ -0,0 +1,4 @@
{
"template": "basic",
"application": {"name" : "demo", "root_class": "EWF_DEMO" }
}