virtual_machine_extension.hpp
Go to the documentation of this file.
00001 /* 00002 Copyright 2007 Adobe Systems Incorporated 00003 Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt 00004 or a copy at http://stlab.adobe.com/licenses.html) 00005 */ 00006 00007 /**************************************************************************************************/ 00008 00009 #ifndef ADOBE_VIRTUAL_MACHINE_EXTENSION_HPP 00010 #define ADOBE_VIRTUAL_MACHINE_EXTENSION_HPP 00011 00012 /**************************************************************************************************/ 00013 00014 #include <adobe/config.hpp> 00015 00016 #include <adobe/closed_hash.hpp> 00017 #include <adobe/name.hpp> 00018 #include <adobe/string.hpp> 00019 #include <adobe/virtual_machine.hpp> 00020 #include <adobe/adam.hpp> 00021 00022 #include <boost/bind.hpp> 00023 #include <boost/function.hpp> 00024 #include <boost/gil/gil_all.hpp> 00025 00026 /**************************************************************************************************/ 00027 00028 namespace adobe { 00029 00030 /**************************************************************************************************/ 00031 00032 namespace implementation { 00033 00034 /**************************************************************************************************/ 00035 00036 any_regular_t vm_dictionary_image_proc(const dictionary_t& named_argument_set); 00037 any_regular_t vm_array_image_proc(const array_t& argument_set); 00038 00039 /**************************************************************************************************/ 00040 00041 } // namespace implementation 00042 00043 /**************************************************************************************************/ 00050 std::ostream& operator<<(std::ostream& s, const boost::gil::rgba8_image_t& image); 00051 00052 /**************************************************************************************************/ 00053 00054 any_regular_t asl_standard_dictionary_function_lookup(name_t function_name, 00055 const dictionary_t& named_argument_set); 00056 00057 any_regular_t asl_standard_array_function_lookup(name_t function_name, 00058 const array_t& argument_set); 00059 00060 /**************************************************************************************************/ 00061 00062 inline 00063 void set_dictionary_function_lookup_to(virtual_machine_t& machine, 00064 const virtual_machine_t::dictionary_function_lookup_t& proc) 00065 { 00066 machine.set_dictionary_function_lookup(proc); 00067 } 00068 00069 /**************************************************************************************************/ 00070 00071 inline 00072 void set_array_function_lookup_to(virtual_machine_t& machine, 00073 const virtual_machine_t::array_function_lookup_t& proc) 00074 { 00075 machine.set_array_function_lookup(proc); 00076 } 00077 00078 /**************************************************************************************************/ 00079 00080 inline void default_vm_function_lookup(virtual_machine_t& machine) 00081 { 00082 machine.set_dictionary_function_lookup(&asl_standard_dictionary_function_lookup); 00083 machine.set_array_function_lookup(&asl_standard_array_function_lookup); 00084 } 00085 00086 /**************************************************************************************************/ 00087 00088 struct vm_lookup_t 00089 { 00090 public: 00091 typedef boost::function<any_regular_t (const dictionary_t&)> dictionary_function_t; 00092 typedef boost::function<any_regular_t (const array_t&)> array_function_t; 00093 typedef boost::function<any_regular_t (name_t)> variable_function_t; 00094 00095 typedef closed_hash_map<name_t, dictionary_function_t> dictionary_function_map_t; 00096 typedef closed_hash_map<name_t, array_function_t > array_function_map_t; 00097 00098 vm_lookup_t(); 00099 00100 void insert_dictionary_function(name_t name, const dictionary_function_t& proc); 00101 void insert_array_function(name_t name, const array_function_t& proc); 00102 00103 void attach_to(virtual_machine_t& vm); 00104 void attach_to(sheet_t&); 00105 00106 private: 00107 any_regular_t dproc(name_t name, const dictionary_t& argument_set) const; 00108 any_regular_t aproc(name_t name, const array_t& argument_set) const; 00109 00110 dictionary_function_map_t dmap_m; 00111 array_function_map_t amap_m; 00112 00113 /* 00114 REVISIT (sparent) : Currently there is no mechanism for adding variable lookup functions. 00115 This is a shim used by attach_to(sheet) - which should be replaced with a general 00116 mechanism later. 00117 */ 00118 00119 variable_function_t variable_lookup_m; 00120 }; 00121 00122 /**************************************************************************************************/ 00123 00124 } // namespace adobe 00125 00126 /**************************************************************************************************/ 00127 00128 #endif 00129 00130 /**************************************************************************************************/ |