To compile the multimedia submodule for a compilation unit, which contains _external_file, _figure and _sound packages.
void RTMultimedia::compile_files(void) { files_data *exf; LOOP_OVER(exf, files_data) { text_stream *desc = Str::new(); WRITE_TO(desc, "external file '%W'", exf->name); Sequence::queue(&RTMultimedia::compilation_agent, STORE_POINTER_files_data(exf), desc); } } void RTMultimedia::compile_internal_files(void) { internal_files_data *inf; LOOP_OVER(inf, internal_files_data) { text_stream *desc = Str::new(); WRITE_TO(desc, "internal file '%W'", inf->name); Sequence::queue(&RTMultimedia::internal_compilation_agent, STORE_POINTER_internal_files_data(inf), desc); } } void RTMultimedia::compile_figures(void) { figures_data *bf; LOOP_OVER(bf, figures_data) { package_request *pack = RTInstances::package(bf->as_instance); Hierarchy::apply_metadata_from_number(pack, INSTANCE_FIGURE_ID_MD_HL, (inter_ti) bf->figure_number); Hierarchy::apply_metadata_from_filename(pack, INSTANCE_FIGURE_FILENAME_MD_HL, bf->filename_of_image_file); } } void RTMultimedia::compile_sounds(void) { sounds_data *bs; LOOP_OVER(bs, sounds_data) { package_request *pack = RTInstances::package(bs->as_instance); Hierarchy::apply_metadata_from_number(pack, INSTANCE_SOUND_ID_MD_HL, (inter_ti) bs->sound_number); Hierarchy::apply_metadata_from_filename(pack, INSTANCE_SOUND_FILENAME_MD_HL, bs->filename_of_sound_file); } }
§2. Files are made with the following agent, which makes a single _external_file package:
void RTMultimedia::compilation_agent(compilation_subtask *t) { files_data *exf = RETRIEVE_POINTER_files_data(t->data); wording W = exf->name; package_request *P = Hierarchy::local_package_to(EXTERNAL_FILES_HAP, exf->where_created); inter_name *exf_iname = Hierarchy::make_iname_with_memo(FILE_HL, P, W); inter_name *IFID_array_iname = NULL; if (exf->file_ownership == OWNED_BY_SPECIFIC_PROJECT) Make an ownership record2.1; Make the file metadata array2.2; Make the value metadata2.3; }
§2.1. Make an ownership record2.1 =
IFID_array_iname = Hierarchy::make_iname_with_memo(IFID_HL, P, W); packaging_state save = EmitArrays::begin_byte(IFID_array_iname, K_value); TEMPORARY_TEXT(II) WRITE_TO(II, "//%S", exf->IFID_of_owner); LOOP_THROUGH_TEXT(pos, II) EmitArrays::numeric_entry((inter_ti) Str::get(pos)); DISCARD_TEXT(II) EmitArrays::end(save);
- This code is used in §2.
§2.2. Make the file metadata array2.2 =
packaging_state save = EmitArrays::begin_word(exf_iname, K_value); EmitArrays::iname_entry(Hierarchy::find(AUXF_MAGIC_VALUE_HL)); EmitArrays::iname_entry(Hierarchy::find(AUXF_STATUS_IS_CLOSED_HL)); if (exf->file_is_binary) EmitArrays::numeric_entry(EXTERNAL_BINARY_FILE_NFSMF); else EmitArrays::numeric_entry(EXTERNAL_TEXT_FILE_NFSMF); EmitArrays::numeric_entry(0); TEMPORARY_TEXT(WW) WRITE_TO(WW, "%w", Lexer::word_raw_text(exf->unextended_filename)); Str::delete_first_character(WW); Str::delete_last_character(WW); EmitArrays::text_entry(WW); DISCARD_TEXT(WW) switch (exf->file_ownership) { case OWNED_BY_THIS_PROJECT: EmitArrays::iname_entry(RTBibliographicData::IFID_iname()); break; case OWNED_BY_ANOTHER_PROJECT: EmitArrays::null_entry(); break; case OWNED_BY_SPECIFIC_PROJECT: EmitArrays::iname_entry(IFID_array_iname); break; } EmitArrays::end(save);
- This code is used in §2.
§2.3. Make the value metadata2.3 =
package_request *pack = RTInstances::package(exf->as_instance); Hierarchy::apply_metadata_from_iname(pack, INSTANCE_FILE_VALUE_MD_HL, exf_iname); Hierarchy::apply_metadata_from_raw_wording(pack, INSTANCE_LEAFNAME_MD_HL, Wordings::one_word(exf->unextended_filename)); Hierarchy::apply_metadata_from_number(pack, INSTANCE_FILE_IS_BINARY_MD_HL, (inter_ti) exf->file_is_binary); switch (exf->file_ownership) { case OWNED_BY_THIS_PROJECT: Hierarchy::apply_metadata_from_number(pack, INSTANCE_FILE_OWNED_MD_HL, 1); break; case OWNED_BY_ANOTHER_PROJECT: Hierarchy::apply_metadata_from_number(pack, INSTANCE_FILE_OWNED_BY_OTHER_MD_HL, 1); break; case OWNED_BY_SPECIFIC_PROJECT: Hierarchy::apply_metadata(pack, INSTANCE_FILE_OWNER_MD_HL, exf->IFID_of_owner); break; }
- This code is used in §2.
§3. Internal files are simpler:
void RTMultimedia::internal_compilation_agent(compilation_subtask *t) { internal_files_data *inf = RETRIEVE_POINTER_internal_files_data(t->data); wording W = inf->name; package_request *P = Hierarchy::local_package_to(INTERNAL_FILES_HAP, inf->where_created); inter_name *inf_iname = Hierarchy::make_iname_with_memo(INTERNAL_FILE_HL, P, W); Make the internal value metadata3.1; Make the internal file metadata array3.2; }
§3.1. Make the internal value metadata3.1 =
package_request *pack = RTInstances::package(inf->as_instance); Hierarchy::apply_metadata_from_iname(pack, INSTANCE_FILE_VALUE_MD_HL, inf_iname); Hierarchy::apply_metadata_from_filename(pack, INSTANCE_LEAFNAME_MD_HL, inf->local_filename); Hierarchy::apply_metadata_from_number(pack, INSTANCE_INTERNAL_FILE_FORMAT_MD_HL, (inter_ti) inf->file_format); Hierarchy::apply_metadata_from_number(pack, INSTANCE_INTERNAL_FILE_ID_MD_HL, (inter_ti) inf->resource_id);
- This code is used in §3.
§3.2. Make the internal file metadata array3.2 =
packaging_state save = EmitArrays::begin_word(inf_iname, K_value); EmitArrays::iname_entry(Hierarchy::find(AUXF_MAGIC_VALUE_HL)); EmitArrays::iname_entry(Hierarchy::find(AUXF_STATUS_IS_CLOSED_HL)); EmitArrays::numeric_entry((inter_ti) inf->file_format); EmitArrays::numeric_entry(0); EmitArrays::text_entry(Filenames::get_leafname(inf->local_filename)); EmitArrays::iname_entry(RTBibliographicData::IFID_iname()); EmitArrays::numeric_entry((inter_ti) inf->resource_id); EmitArrays::end(save);
- This code is used in §3.