Skip to content

Commit

Permalink
Various refactoring related to serialisation.
Browse files Browse the repository at this point in the history
  • Loading branch information
wolandscat committed Jul 19, 2024
1 parent 9a2615b commit 0037e5b
Show file tree
Hide file tree
Showing 16 changed files with 171 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ feature {NONE} -- Implementation
adl_text: STRING
do
if adl_text_cache.is_empty then
adl_text_cache.append (safe_source.select_native_serialised_archetype (differential_view, rm_flattening_on))
adl_text_cache.append (safe_source.serialised_native (differential_view, rm_flattening_on))
end
Result := adl_text_cache
end
Expand All @@ -236,7 +236,7 @@ feature {NONE} -- Implementation
json_text: STRING
do
if json_text_cache.is_empty then
json_text_cache.append (safe_source.serialise_object (not differential_view, type_marking_on, {ODIN_DEFINITIONS}.Syntax_type_json))
json_text_cache.append (safe_source.serialised_object (not differential_view, type_marking_on, {ODIN_DEFINITIONS}.Syntax_type_json))
end
Result := json_text_cache
end
Expand All @@ -252,7 +252,7 @@ feature {NONE} -- Implementation
ejson_text: STRING
do
if ejson_text_cache.is_empty then
ejson_text_cache.append (safe_source.serialise_object_ejson (not differential_view, type_marking_on, {ODIN_DEFINITIONS}.Syntax_type_json))
ejson_text_cache.append (safe_source.serialised_object_ejson (not differential_view, type_marking_on, {ODIN_DEFINITIONS}.Syntax_type_json))
end
Result := ejson_text_cache
end
Expand All @@ -268,7 +268,7 @@ feature {NONE} -- Implementation
yaml_text: STRING
do
if yaml_text_cache.is_empty then
yaml_text_cache.append (safe_source.serialise_object (not differential_view, type_marking_on, {ODIN_DEFINITIONS}.Syntax_type_yaml))
yaml_text_cache.append (safe_source.serialised_object (not differential_view, type_marking_on, {ODIN_DEFINITIONS}.Syntax_type_yaml))
end
Result := yaml_text_cache
end
Expand All @@ -284,7 +284,7 @@ feature {NONE} -- Implementation
xml_text: STRING
do
if xml_text_cache.is_empty then
xml_text_cache.append (safe_source.serialise_object (not differential_view, type_marking_on, {ODIN_DEFINITIONS}.Syntax_type_xml))
xml_text_cache.append (safe_source.serialised_object (not differential_view, type_marking_on, {ODIN_DEFINITIONS}.Syntax_type_xml))
end
Result := xml_text_cache
end
Expand All @@ -300,7 +300,7 @@ feature {NONE} -- Implementation
odin_text: STRING
do
if odin_text_cache.is_empty then
odin_text_cache.append (safe_source.serialise_object (not differential_view, type_marking_on, {ARCHETYPE_DEFINITIONS}.Syntax_type_adl))
odin_text_cache.append (safe_source.serialised_object (not differential_view, type_marking_on, {ARCHETYPE_DEFINITIONS}.Syntax_type_adl))
end
Result := odin_text_cache
end
Expand Down
2 changes: 1 addition & 1 deletion apps/adl_workbench/src/gui/export/export_dialog.e
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ feature {NONE} -- Implementation
else
execution_state := es_ready_to_generate
end
archetype_exporter.setup_build ([output_directory, evx_format_cob.data_control_text, export_flat, evx_flatten_with_rm_cb.is_selected])
archetype_exporter.setup_build ([output_directory, evx_format_cob.data_control_text, export_flat, evx_flatten_with_rm_cb.is_selected, False])

-- start compilation
elseif execution_state = es_ready_to_compile then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ feature {NONE} -- Implementation
question_dialog.show_modal_to_window (proximate_ev_window (ev_root_container))
if attached question_dialog.selected_button as att_sel_btn and then att_sel_btn.same_string (get_text ({GENERAL_MESSAGES_IDS}.ec_yes_response)) then
src.remove_archetype (aca)
aca.remove_file
aca.remove_source_file
if attached aca.parent as att_parent then
remove_item_in_tree (aca.global_artefact_identifier)
library_tool_agents.call_update_explorers_and_select_agent (att_parent.global_artefact_identifier)
Expand Down
4 changes: 2 additions & 2 deletions apps/adl_workbench/src/gui/library_tool/gui_library_tool.e
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ feature {NONE} -- Implementation
-- finalise the file path & create a handle
set_last_user_save_directory (file_system.dirname (name))
format := format_list [save_dialog.selected_filter_index]
ext := archetype_file_extension (diff_flag, format)
ext := archetype_file_extension (not diff_flag, format)
if not file_system.has_extension (name, ext) then
name.append (ext)
end
Expand All @@ -531,7 +531,7 @@ feature {NONE} -- Implementation
if diff_flag then
aca.save_differential_as (name, format)
else
aca.save_flat_as (name, format)
aca.save_flat_as (name, format, False)
end
gui_agents.call_console_tool_append_agent (aca.status)
end
Expand Down
2 changes: 1 addition & 1 deletion apps/adl_workbench/src/gui/main/gui_test_tool.e
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ feature {NONE} -- Tests
flat_fname := extension_replaced (orig_fname, File_ext_archetype_flat)

flat_path := file_system.pathname (diff_dir_flat_new, flat_fname)
auth_target.save_flat_as (flat_path, Syntax_type_adl)
auth_target.save_flat_as (flat_path, Syntax_type_adl, False)

-- copy above flat file to $repository/source_flat/orig area as well, using extension .adlx (flat also uses this - diff tool needs to see same
-- extensions or else it gets confused)
Expand Down
17 changes: 10 additions & 7 deletions apps/adlc/src/main/application.e
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ note
adlc [-q] -L
adlc [-q] -D
adlc [-q] -X
adlc [-q] -b <library name> --build
adlc [-q] -b <library name> -l [<id_pattern>]
adlc [-q] -b <library name> -d [<id_pattern>]
adlc [-q] -b <library name> [-f <format>] --report [-o <output_dir>]
adlc [-q] -b <library name> --inject_term_bindings <terminology_namespace> -i <terms_file>
adlc [-q] -b <library name> --export_term_bindings
adlc [-q] -b <library> --build
adlc [-q] -b <library> -l [<id_pattern>]
adlc [-q] -b <library> -d [<id_pattern>]
adlc [-q] -b <library> --export [--format <format>] [--flat] [--templates] [--rm_multiplicities] [--output <output_dir>]
adlc [-q] -b <library> [-f <format>] --report [-o <output_dir>]
adlc [-q] -b <library> --inject_term_bindings <terminology_namespace> -i <terms_file>
adlc [-q] -b <library> --export_term_bindings
OPTIONS:
Options should be prefixed with: '-' or '/'
Expand All @@ -32,6 +33,8 @@ note
<library name>: library name
-f --format : output format for generated files (Optional)
<format>: file formats: json|adl|odin|yaml|xml|csv (default = adl or csv)
--templates : process only templates in operations like export
--rm_multiplicities : include RM cardinality and existences to AOM structures in output
--cfg : output default configuration file location (Optional)
<file path>: .cfg file path
Expand Down Expand Up @@ -280,7 +283,7 @@ feature -- Commands
-- PROCESS LIBRARY
if not error_reported then
report_std_out ("--------- Exporting to " + full_output_dir + "---------")
archetype_exporter.setup_build ([full_output_dir, output_format, opts.use_flat_source, opts.include_rm_multiplicities])
archetype_exporter.setup_build ([full_output_dir, output_format, opts.use_flat, opts.include_rm_multiplicities, opts.templates_only])
archetype_exporter.build_all
end
end
Expand Down
17 changes: 13 additions & 4 deletions apps/adlc/src/main/options_processor.e
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ feature -- Definitions
Result.extend (create {ARGUMENT_SWITCH}.make (quiet_switch, get_text (ec_adlc_quiet_switch_desc), True, False))
Result.extend (create {ARGUMENT_SWITCH}.make (flat_switch, get_text (ec_flat_switch_desc), True, False))
Result.extend (create {ARGUMENT_SWITCH}.make (rm_multiplicities_switch, get_text (ec_rm_multiplicities_switch_desc), True, False))
Result.extend (create {ARGUMENT_SWITCH}.make (templates_only_switch, get_text (ec_templates_only_switch_desc), True, False))

Result.extend (create {ARGUMENT_SWITCH}.make (show_config_switch, get_text (ec_show_config_switch_desc), False, False))
Result.extend (create {ARGUMENT_SWITCH}.make (list_archetypes_switch, get_text (ec_list_archetypes_switch_desc), False, False))
Result.extend (create {ARGUMENT_SWITCH}.make (display_archetypes_switch, get_text (ec_display_archetypes_switch_desc), False, False))
Expand Down Expand Up @@ -138,12 +140,14 @@ feature -- Definitions
switch_of_name (clean_term_bindings_switch)>>, False))

-- EXPORT
-- adlc [--quiet] [--cfg <file path>] --library <library name> --export [--format <format>] [--flat] [--output <output_dir>] [<id_pattern>]
-- adlc [--quiet] [--cfg <file path>] --library <library name> --export [--format <format>] [--flat] [--templates] [--rm_multiplicities] [--output <output_dir>] [<id_pattern>]
Result.extend (create {ARGUMENT_GROUP}.make (<< switch_of_name (quiet_switch),
switch_of_name (cfg_switch),
switch_of_name (library_switch),
switch_of_name (export_switch),
switch_of_name (flat_switch), switch_of_name (rm_multiplicities_switch),
switch_of_name (flat_switch),
switch_of_name (rm_multiplicities_switch),
switch_of_name (templates_only_switch),
switch_of_name (format_switch),
switch_of_name (output_dir_switch)>>, True))

Expand All @@ -166,6 +170,7 @@ feature -- Definitions
quiet_switch: STRING = "q|quiet"
flat_switch: STRING = "flat"
rm_multiplicities_switch: STRING = "rm_multiplicities"
templates_only_switch: STRING = "templates"
show_config_switch: STRING = "s|show_config"

list_rms_switch: STRING = "L|list_rms"
Expand Down Expand Up @@ -237,8 +242,10 @@ feature {NONE} -- Initialization
Precursor
if is_successful then
is_verbose := not has_option (quiet_switch)
use_flat_source := has_option (flat_switch)
use_flat := has_option (flat_switch)
include_rm_multiplicities := has_option (rm_multiplicities_switch)
templates_only := has_option (templates_only_switch)

show_config := has_option (show_config_switch)
list_archetypes := has_option (list_archetypes_switch)
display_archetypes := has_option (display_archetypes_switch)
Expand Down Expand Up @@ -349,10 +356,12 @@ feature -- Status Report

is_verbose: BOOLEAN

use_flat_source: BOOLEAN
use_flat: BOOLEAN

include_rm_multiplicities: BOOLEAN

templates_only: BOOLEAN

show_config: BOOLEAN

list_archetypes: BOOLEAN
Expand Down
3 changes: 2 additions & 1 deletion apps/resources/messages/compiled/adl_messages_db.e
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ feature -- Initialisation

make
do
create message_table.make (972)
create message_table.make (973)
message_table.put ("Terminology initialisation failed; reason: $1", ec_terminology_init_failed)
message_table.put ("Using ADL version $1 for output serialisation", ec_adl_version_warning)
message_table.put ("Validation level STRICT", ec_validation_strict)
Expand Down Expand Up @@ -292,6 +292,7 @@ feature -- Initialisation
message_table.put ("suppress verbose feedback, including configuration information on startup", ec_adlc_quiet_switch_desc)
message_table.put ("use flat form of archetype[s] for export", ec_flat_switch_desc)
message_table.put ("include RM multiplicities when flattening", ec_rm_multiplicities_switch_desc)
message_table.put ("export templates only", ec_templates_only_switch_desc)
message_table.put ("show current configuration and defaults", ec_show_config_switch_desc)
message_table.put ("generate list of archetypes in current library (use for further processing)", ec_list_archetypes_switch_desc)
message_table.put ("generate list of archetypes in current library in user-friendly format", ec_display_archetypes_switch_desc)
Expand Down
1 change: 1 addition & 0 deletions apps/resources/messages/compiled/adl_messages_ids.e
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ feature -- Definitions
ec_adlc_quiet_switch_desc: STRING = "adlc_quiet_switch_desc"
ec_flat_switch_desc: STRING = "flat_switch_desc"
ec_rm_multiplicities_switch_desc: STRING = "rm_multiplicities_switch_desc"
ec_templates_only_switch_desc: STRING = "templates_only_switch_desc"
ec_show_config_switch_desc: STRING = "show_config_switch_desc"
ec_list_archetypes_switch_desc: STRING = "list_archetypes_switch_desc"
ec_display_archetypes_switch_desc: STRING = "display_archetypes_switch_desc"
Expand Down
1 change: 1 addition & 0 deletions apps/resources/messages/source/app_adlc_ui_messages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ templates = <
["adlc_quiet_switch_desc"] = <"suppress verbose feedback, including configuration information on startup">
["flat_switch_desc"] = <"use flat form of archetype[s] for export">
["rm_multiplicities_switch_desc"] = <"include RM multiplicities when flattening">
["templates_only_switch_desc"] = <"export templates only">
["show_config_switch_desc"] = <"show current configuration and defaults">
["list_archetypes_switch_desc"] = <"generate list of archetypes in current library (use for further processing)">
["display_archetypes_switch_desc"] = <"generate list of archetypes in current library in user-friendly format">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ end
across a_flat_arch.suppliers_index as xrefs_csr loop
-- get the definition structure of the flat archetype corresponding to the archetype id in the suppliers list
check attached current_library.archetype_matching_ref (xrefs_csr.key) as att_ala then
matched_arch := if include_rm then att_ala.flat_archetype_with_rm else att_ala.flat_archetype end
matched_arch := att_ala.flat_archetype_processed (include_rm)
end

-- make a copy of the supplier archetype (or template)
Expand Down
30 changes: 18 additions & 12 deletions components/adl_compiler/src/interface/archetype_exporter.e
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ feature {NONE} -- Commands
syntax := args.syntax
export_flat := args.export_flat
export_with_rm := args.export_with_rm
templates_only := args.templates_only

artefact_count := current_library.archetype_count
end
Expand Down Expand Up @@ -120,6 +121,9 @@ feature {NONE} -- Build State
export_with_rm: BOOLEAN
-- True if exporting flat form with RM included

templates_only: BOOLEAN
-- True if we only want templates

feature {NONE} -- Implementation

process_archetype (ara: ARCH_LIB_ARCHETYPE)
Expand All @@ -128,18 +132,20 @@ feature {NONE} -- Implementation
filename, exc_trace_str: STRING
exception_encountered: BOOLEAN
do
if not exception_encountered then
if not is_interrupted then
if attached {ARCH_LIB_AUTHORED_ARCHETYPE} ara as auth_ara and then auth_ara.is_valid then
check attached archetype_file_extensions.item (syntax) as ext then
filename := file_system.pathname (output_dir, ara.id.as_filename) + ext
end
if export_flat then
auth_ara.save_flat_as (filename, syntax)
else
auth_ara.save_differential_as (filename, syntax)
if not templates_only or else attached {ARCH_LIB_TEMPLATE} ara then
if not exception_encountered then
if not is_interrupted then
if attached {ARCH_LIB_AUTHORED_ARCHETYPE} ara as auth_ara and then auth_ara.is_valid then
check attached archetype_file_extension (export_flat, syntax) as ext then
filename := file_system.pathname (output_dir, ara.id.as_filename) + ext
end
if export_flat then
auth_ara.save_flat_as (filename, syntax, export_with_rm)
else
auth_ara.save_differential_as (filename, syntax)
end
update_progress
end
update_progress
end
end
end
Expand All @@ -154,7 +160,7 @@ feature {NONE} -- Implementation
retry
end

build_args_type: TUPLE [export_dir, syntax: STRING; export_flat, export_with_rm: BOOLEAN]
build_args_type: TUPLE [export_dir, syntax: STRING; export_flat, export_with_rm, templates_only: BOOLEAN]
do
create Result
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ feature -- Access
-- File extensions for logical serialisation formats.
once ("PROCESS")
create Result.make (0)
Result.put (File_ext_archetype_source, Syntax_type_adl)
Result.put (File_ext_archetype_web_page, Syntax_type_adl_html)
Result.put (File_ext_archetype_source, {ARCHETYPE_DEFINITIONS}.Syntax_type_adl)
Result.put (File_ext_archetype_web_page, {ARCHETYPE_DEFINITIONS}.Syntax_type_adl_html)
Result.put ({ODIN_DEFINITIONS}.File_ext_odin, {ODIN_DEFINITIONS}.Syntax_type_odin)
Result.put ({ODIN_DEFINITIONS}.File_ext_xml_default, {ODIN_DEFINITIONS}.Syntax_type_xml)
Result.put ({ODIN_DEFINITIONS}.File_ext_json_default, {ODIN_DEFINITIONS}.Syntax_type_json)
Expand All @@ -128,7 +128,7 @@ feature -- Access
-- File extensions for logical serialisation formats.
once ("PROCESS")
create Result.make (0)
Result.put ({ARCHETYPE_DEFINITIONS}.File_ext_archetype_flat, {ARCHETYPE_DEFINITIONS}.Syntax_type_adl)
Result.put ({ARCHETYPE_DEFINITIONS}.File_ext_opt2, {ARCHETYPE_DEFINITIONS}.Syntax_type_adl)
Result.put ({ARCHETYPE_DEFINITIONS}.File_ext_archetype_web_page, {ARCHETYPE_DEFINITIONS}.Syntax_type_adl_html)
Result.put ({ODIN_DEFINITIONS}.File_ext_odin, {ODIN_DEFINITIONS}.Syntax_type_odin)
Result.put ({ODIN_DEFINITIONS}.File_ext_xml_default, {ODIN_DEFINITIONS}.Syntax_type_xml)
Expand All @@ -138,14 +138,14 @@ feature -- Access
not_empty: not Result.is_empty
end

archetype_file_extension (diff_flag: BOOLEAN; a_format: STRING): STRING
archetype_file_extension (flat_flag: BOOLEAN; a_format: STRING): STRING
do
if diff_flag then
check attached archetype_file_extensions [a_format] as ext then
if flat_flag then
check attached flat_archetype_file_extensions [a_format] as ext then
Result := ext
end
else
check attached flat_archetype_file_extensions [a_format] as ext then
check attached archetype_file_extensions [a_format] as ext then
Result := ext
end
end
Expand Down
Loading

0 comments on commit 0037e5b

Please sign in to comment.