From: Foster B. <fos...@us...> - 2006-02-03 18:34:24
|
Update of /cvsroot/adobe-source/sandbox/adobe-source/adobe/test/adam_tutorial In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6755/adobe/test/adam_tutorial Modified Files: default.adm main.cpp Log Message: asl 1.0.13 Index: main.cpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/test/adam_tutorial/main.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** main.cpp 6 Jan 2006 18:03:00 -0000 1.9 --- main.cpp 3 Feb 2006 18:33:38 -0000 1.10 *************** *** 1,6 **** /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt ! or a copy at http://opensource.adobe.com/licenses.html) */ --- 1,6 ---- /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt ! or a copy at http://opensource.adobe.com/licenses.html) */ *************** *** 42,49 **** void value_changed(cell_set_t::value_type& cell, const adobe::value_t& new_value) { ! cell.second = new_value; ! std::cout << "U \'" << cell.first.get() << "\' ==> " ! << adobe::begin_asl_cel << cell.second << adobe::end_asl_cel << std::endl; } --- 42,49 ---- void value_changed(cell_set_t::value_type& cell, const adobe::value_t& new_value) { ! cell.second = new_value; ! std::cout << "U \'" << cell.first.get() << "\' ==> " ! << adobe::begin_asl_cel << cell.second << adobe::end_asl_cel << std::endl; } *************** *** 52,56 **** void setup_monitor(adobe::sheet_t& sheet, cell_set_t::value_type& cell) { ! sheet.monitor_value(cell.first, boost::bind(value_changed, boost::ref(cell), _1)); } --- 52,56 ---- void setup_monitor(adobe::sheet_t& sheet, cell_set_t::value_type& cell) { ! sheet.monitor_value(cell.first, boost::bind(value_changed, boost::ref(cell), _1)); } *************** *** 59,65 **** void stream_cell_state(const cell_set_t::value_type& cell) { ! std::cout << " '" << cell.first.get() << "': " ! << adobe::begin_asl_cel << cell.second << adobe::end_asl_cel ! << std::endl; } --- 59,65 ---- void stream_cell_state(const cell_set_t::value_type& cell) { ! std::cout << " '" << cell.first.get() << "': " ! << adobe::begin_asl_cel << cell.second << adobe::end_asl_cel ! << std::endl; } *************** *** 68,111 **** struct sheet_tracker { ! explicit sheet_tracker(const bfs::path& sheet_path) : ! sheet_m(), callbacks_m(adobe::bind_to_sheet(sheet_m)) ! { ! std::string file_path(sheet_path.native_file_string()); ! std::ifstream sheet_file(file_path.c_str()); ! callbacks_m.add_cell_proc_m = boost::bind(&sheet_tracker::add_cell_trap, boost::ref(*this), callbacks_m.add_cell_proc_m, _1, _2, _3, _4); ! callbacks_m.add_interface_proc_m = boost::bind(&sheet_tracker::add_interface_trap, boost::ref(*this), callbacks_m.add_interface_proc_m, _1, _2, _3, _4, _5, _6); ! if (!sheet_file.is_open()) ! std::cerr << "Could not open \"" << file_path << "\"!\n"; ! // set up adam sheet ! adobe::parse(sheet_file, adobe::line_position_t(), callbacks_m); ! } ! void loop(); private: ! sheet_tracker(); // unimplemented ! sheet_tracker(const sheet_tracker&); // unimplemented ! sheet_tracker& operator = (const sheet_tracker&); // unimplemented ! void add_cell_trap( adobe::adam_callback_suite_t::add_cell_proc_t original, ! adobe::adam_callback_suite_t::cell_type_t type, ! adobe::name_t cell_name, ! const adobe::line_position_t& position, ! const adobe::array_t& expr_or_init); ! void add_interface_trap(adobe::adam_callback_suite_t::add_interface_proc_t original, ! adobe::name_t cell_name, ! bool linked, ! const adobe::line_position_t& position1, ! const adobe::array_t& initializer, ! const adobe::line_position_t& position2, ! const adobe::array_t& expression); ! adobe::sheet_t sheet_m; ! adobe::adam_callback_suite_t callbacks_m; ! std::map<adobe::name_t, adobe::value_t> cell_set_m; }; --- 68,111 ---- struct sheet_tracker { ! explicit sheet_tracker(const bfs::path& sheet_path) : ! sheet_m(), callbacks_m(adobe::bind_to_sheet(sheet_m)) ! { ! std::string file_path(sheet_path.native_file_string()); ! std::ifstream sheet_file(file_path.c_str()); ! callbacks_m.add_cell_proc_m = boost::bind(&sheet_tracker::add_cell_trap, boost::ref(*this), callbacks_m.add_cell_proc_m, _1, _2, _3, _4); ! callbacks_m.add_interface_proc_m = boost::bind(&sheet_tracker::add_interface_trap, boost::ref(*this), callbacks_m.add_interface_proc_m, _1, _2, _3, _4, _5, _6); ! if (!sheet_file.is_open()) ! std::cerr << "Could not open \"" << file_path << "\"!\n"; ! // set up adam sheet ! adobe::parse(sheet_file, adobe::line_position_t(), callbacks_m); ! } ! void loop(); private: ! sheet_tracker(); // unimplemented ! sheet_tracker(const sheet_tracker&); // unimplemented ! sheet_tracker& operator = (const sheet_tracker&); // unimplemented ! void add_cell_trap( adobe::adam_callback_suite_t::add_cell_proc_t original, ! adobe::adam_callback_suite_t::cell_type_t type, ! adobe::name_t cell_name, ! const adobe::line_position_t& position, ! const adobe::array_t& expr_or_init); ! void add_interface_trap(adobe::adam_callback_suite_t::add_interface_proc_t original, ! adobe::name_t cell_name, ! bool linked, ! const adobe::line_position_t& position1, ! const adobe::array_t& initializer, ! const adobe::line_position_t& position2, ! const adobe::array_t& expression); ! adobe::sheet_t sheet_m; ! adobe::adam_callback_suite_t callbacks_m; ! std::map<adobe::name_t, adobe::value_t> cell_set_m; }; *************** *** 114,158 **** adobe::name_t cell_type_to_name(adobe::adam_callback_suite_t::cell_type_t type) { ! switch (type) ! { ! case adobe::adam_callback_suite_t::input_k: return adobe::static_name_t("input"); break; ! case adobe::adam_callback_suite_t::output_k: return adobe::static_name_t("output"); break; ! case adobe::adam_callback_suite_t::constant_k: return adobe::static_name_t("constant"); break; ! case adobe::adam_callback_suite_t::logic_k: return adobe::static_name_t("logic"); break; ! case adobe::adam_callback_suite_t::invariant_k: return adobe::static_name_t("invariant"); break; ! default: return adobe::static_name_t("unknown"); break; ! } } /****************************************************************************************************/ ! void sheet_tracker::add_cell_trap( adobe::adam_callback_suite_t::add_cell_proc_t original, ! adobe::adam_callback_suite_t::cell_type_t type, ! adobe::name_t cell_name, ! const adobe::line_position_t& position, ! const adobe::array_t& expr_or_init) { ! original(type, cell_name, position, expr_or_init, std::string(), std::string()); ! std::cout << "A \'" << cell_name.get() << "\' (type " << cell_type_to_name(type) << ")" << std::endl; ! cell_set_m[cell_name] = adobe::value_t(); } /****************************************************************************************************/ ! void sheet_tracker::add_interface_trap( adobe::adam_callback_suite_t::add_interface_proc_t original, ! adobe::name_t cell_name, ! bool linked, ! const adobe::line_position_t& position1, ! const adobe::array_t& initializer, ! const adobe::line_position_t& position2, ! const adobe::array_t& expression) { ! original(cell_name, linked, position1, initializer, position2, expression, std::string(), std::string()); ! std::cout << "A \'" << cell_name.get() << "\' (interface)" << std::endl; ! cell_set_m[cell_name] = adobe::value_t(); } --- 114,158 ---- adobe::name_t cell_type_to_name(adobe::adam_callback_suite_t::cell_type_t type) { ! switch (type) ! { ! case adobe::adam_callback_suite_t::input_k: return adobe::static_name_t("input"); break; ! case adobe::adam_callback_suite_t::output_k: return adobe::static_name_t("output"); break; ! case adobe::adam_callback_suite_t::constant_k: return adobe::static_name_t("constant"); break; ! case adobe::adam_callback_suite_t::logic_k: return adobe::static_name_t("logic"); break; ! case adobe::adam_callback_suite_t::invariant_k: return adobe::static_name_t("invariant"); break; ! default: return adobe::static_name_t("unknown"); break; ! } } /****************************************************************************************************/ ! void sheet_tracker::add_cell_trap( adobe::adam_callback_suite_t::add_cell_proc_t original, ! adobe::adam_callback_suite_t::cell_type_t type, ! adobe::name_t cell_name, ! const adobe::line_position_t& position, ! const adobe::array_t& expr_or_init) { ! original(type, cell_name, position, expr_or_init, std::string(), std::string()); ! std::cout << "A \'" << cell_name.get() << "\' (type " << cell_type_to_name(type) << ")" << std::endl; ! cell_set_m[cell_name] = adobe::value_t(); } /****************************************************************************************************/ ! void sheet_tracker::add_interface_trap( adobe::adam_callback_suite_t::add_interface_proc_t original, ! adobe::name_t cell_name, ! bool linked, ! const adobe::line_position_t& position1, ! const adobe::array_t& initializer, ! const adobe::line_position_t& position2, ! const adobe::array_t& expression) { ! original(cell_name, linked, position1, initializer, position2, expression, std::string(), std::string()); ! std::cout << "A \'" << cell_name.get() << "\' (interface)" << std::endl; ! cell_set_m[cell_name] = adobe::value_t(); } *************** *** 161,198 **** void sheet_tracker::loop() { ! std::string cell_name_buffer; ! std::vector<char> new_value_buffer; ! cell_name_buffer.reserve(1024); ! new_value_buffer.reserve(1024); ! new_value_buffer.resize(1); ! adobe::for_each(cell_set_m, boost::bind(setup_monitor, boost::ref(sheet_m), _1)); ! while (true) ! { ! std::cout << "--" << std::endl; ! sheet_m.update(); ! std::cout << "sheet:" << std::endl; ! adobe::for_each(cell_set_m, stream_cell_state); ! std::cout << "Enter in the name of a cell for which you would like to change the value: "; ! std::cin.getline(&cell_name_buffer[0], 1024); ! if (cell_name_buffer[0] == 0) break; ! std::cout << "Enter in the new value for cell \'" << &cell_name_buffer[0] << "\': "; ! std::cin.getline(&new_value_buffer[0], 1024); ! if (new_value_buffer[0] == 0) break; ! adobe::virtual_machine_t machine; ! machine.evaluate(adobe::parse_adam_expression(&new_value_buffer[0])); ! sheet_m.set(adobe::name_t(&cell_name_buffer[0]), machine.back().value_m); ! } } --- 161,198 ---- void sheet_tracker::loop() { ! std::string cell_name_buffer; ! std::vector<char> new_value_buffer; ! cell_name_buffer.reserve(1024); ! new_value_buffer.reserve(1024); ! new_value_buffer.resize(1); ! adobe::for_each(cell_set_m, boost::bind(setup_monitor, boost::ref(sheet_m), _1)); ! while (true) ! { ! std::cout << "--" << std::endl; ! sheet_m.update(); ! std::cout << "sheet:" << std::endl; ! adobe::for_each(cell_set_m, stream_cell_state); ! std::cout << "Enter in the name of a cell for which you would like to change the value: "; ! std::cin.getline(&cell_name_buffer[0], 1024); ! if (cell_name_buffer[0] == 0) break; ! std::cout << "Enter in the new value for cell \'" << &cell_name_buffer[0] << "\': "; ! std::cin.getline(&new_value_buffer[0], 1024); ! if (new_value_buffer[0] == 0) break; ! adobe::virtual_machine_t machine; ! machine.evaluate(adobe::parse_adam_expression(&new_value_buffer[0])); ! sheet_m.set(adobe::name_t(&cell_name_buffer[0]), machine.back().value_m); ! } } *************** *** 205,228 **** int main(int argc, char* argv[]) { ! try ! { ! std::cout << "Adobe Adam Tutorial" << std::endl; ! std::cout << "Compiler: " << BOOST_COMPILER << std::endl; ! std::cout << " ASL: v" << ADOBE_VERSION_MAJOR << "." << ADOBE_VERSION_MINOR << "." << ADOBE_VERSION_SUBMINOR << std::endl; ! std::cout << " Boost: v" << BOOST_VERSION / 100000 << "." << BOOST_VERSION / 100 % 1000 << "." << BOOST_VERSION % 100 << std::endl; ! std::cout << "--" << std::endl; ! std::string pathname(argc > 1 ? (argv[1]) : ("./default.adm")); ! bfs::path filepath(pathname.c_str()); ! sheet_tracker(filepath).loop(); ! } ! catch (const std::exception& doh) ! { ! std::cerr << "Exception: " << doh.what() << "\n"; ! } ! catch (...) ! { ! std::cerr << "Unknown Exception\n"; ! } } --- 205,228 ---- int main(int argc, char* argv[]) { ! try ! { ! std::cout << "Adobe Adam Tutorial" << std::endl; ! std::cout << "Compiler: " << BOOST_COMPILER << std::endl; ! std::cout << " ASL: v" << ADOBE_VERSION_MAJOR << "." << ADOBE_VERSION_MINOR << "." << ADOBE_VERSION_SUBMINOR << std::endl; ! std::cout << " Boost: v" << BOOST_VERSION / 100000 << "." << BOOST_VERSION / 100 % 1000 << "." << BOOST_VERSION % 100 << std::endl; ! std::cout << "--" << std::endl; ! std::string pathname(argc > 1 ? (argv[1]) : ("./default.adm")); ! bfs::path filepath(pathname.c_str()); ! sheet_tracker(filepath).loop(); ! } ! catch (const std::exception& doh) ! { ! std::cerr << "Exception: " << doh.what() << "\n"; ! } ! catch (...) ! { ! std::cerr << "Unknown Exception\n"; ! } } Index: default.adm =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/test/adam_tutorial/default.adm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** default.adm 19 Mar 2005 00:16:43 -0000 1.1 --- default.adm 3 Feb 2006 18:33:38 -0000 1.2 *************** *** 2,14 **** { interface: ! distance : 15; ! rate : 3; ! time : 5; logic: ! relate { ! rate <== distance / time; ! time <== distance / rate; ! distance <== rate * time; ! } } --- 2,14 ---- { interface: ! distance : 15; ! rate : 3; ! time : 5; logic: ! relate { ! rate <== distance / time; ! time <== distance / rate; ! distance <== rate * time; ! } } |