#% text_encoding = iso8859_1 # Copyright (C) Field Consulting and Services, Inc. :y, all rights reserved. ######################################################################## ## ## Created By: Mark Field (FCSI) ## Date: 2014/03/14 ## Last Modified Time-stamp: <10/25/2018 11:54, Mark Field (FCSI)> ## ## Project Files ## ## Description: ## ######################################################################## _package user $ _pragma(classify_level=advanced, topic={FCSI}) def_slotted_exemplar(:fcsi_method_manip, {{:fcsi_overwrites,property_list.new(),:readable} }) $ _pragma(classify_level=advanced, topic={FCSI}) _method fcsi_method_manip.fcsi_copy_method(exemplar,method_name, _optional prefix,display_method?) ## Parameters : exemplar - the exemplar (not symbol) to copy ## method_name on ## method_name - the method name to copy to ## prefix+method_name. Should be symbol ## prefix - default :sw! the name of the newly copied method ## display_method? - if true, then write a stub method on ## the magik prompt with a TB for debugging. ## Returns : nothing ## Function : copies the value of the method/exemplar given ## to the prefix + method_nem. Also reqords the copy onto .fcsi_overwrites ## Methodology : #---------------- HISTORY --------------------- # (14/03/14 - Mark Field (FCSI)): Created. # (2015/07/29 - Mark Field (FCSI)): Modified - test for local method! # (2018/08/14 - Mark Field (FCSI)): Modified - record copys #---------------------------------------------- _local newMeth << prefix.default(:sw!)+method_name # Need to do special testing for mixin exemplars! _local newMethLocal? << exemplar.method(newMeth) newMethLocal? << _if newMethLocal? _is _unset _then >> _false _else >> newMethLocal?.owner.meta_at(:exemplar_global).value _is exemplar _endif _local methLocal? << exemplar.method(method_name) methLocal? << _if methLocal? _is _unset _then >> _false _else >> methLocal?.owner.meta_at(:exemplar_global).value _is exemplar _endif _if newMethLocal? _is _true _orif methLocal? _is _false _then # nothing to do... _return _endif write("Copying method: ",exemplar,%.,method_name," to ",newMeth) write("Original source: ",exemplar.method(method_name).source_file) _local fmi << get_global_value(:fcsi_method_information) _if fmi _isnt _unset _then fmi.fcsi_record_copy(exemplar,method_name,prefix.default(:sw!)) _endif _local meth << exemplar.method(method_name) _if meth.shared_constant? _then exemplar.define_shared_constant(newMeth,meth.value,_false) _elif meth.shared_variable? _then exemplar.define_shared_variable(newMeth,meth.value,:public) _else exemplar.define_method(newMeth,meth.value,_false) _endif _if display_method? _is _true _andif method_name.last _is %) _then write("_method ",exemplar.class_name,%., method_name.subseq(1,method_name.size-1), "_gather args)") write(%tab,"show(:",exemplar.class_name,",:|",method_name, "|,_scatter args)") write(%tab,"_return _self.", newMeth.subseq(1,newMeth.size-1), "_scatter args)") write("_endmethod") _endif _self.fcsi_record_ex_meth(exemplar,method_name) _endmethod $ _pragma(classify_level=advanced, topic={FCSI}) _method fcsi_method_manip.fcsi_record_ex_meth(exemplar,method_name) ## Parameters : exemplar - the exemplar (not symbol) to copy ## method_name on ## method_name - the method name to copy to ## prefix+method_name. Should be symbol ## Returns : ## Function : records information on .fcsi_overwrites ## Methodology : #---------------- HISTORY --------------------- # (14/03/14 - Mark Field (FCSI)): Created. #---------------------------------------------- _local exName << exemplar.class_name _if .fcsi_overwrites[exName] _is _unset _then .fcsi_overwrites[exName] << rope.new_for(5) _endif .fcsi_overwrites[exName].add_last(method_name) _endmethod $ _pragma(classify_level=advanced, topic={FCSI}) _method fcsi_method_manip.fcsi_report_overwrites(_optional list) ## Parameters : list - property list of changes. Uses ## .fcsi_overwrites if unset . ## Returns : nothing ## Function : reports the overwrites in alphabetical order ## Methodology : #---------------- HISTORY --------------------- # (2015/08/10 - Mark Field (FCSI)): Created. #---------------------------------------------- list << list.default(.fcsi_overwrites) _local sc << sorted_collection.new_from(list.keys) _local sm _for aKey _over sc.fast_elements() _loop sm << sorted_collection.new_from(list[aKey].elements) _for aMeth _over sm.fast_elements() _loop write(aKey,%.,aMeth) _endloop _endloop _endmethod $ _pragma(classify_level=advanced, topic={FCSI}) _method fcsi_method_manip.fcsi_show_args(exmplr,a_method) ## Parameters : exmplr - the exemplar ## a_method - the method to show arguments ## Returns : nothing ## Function : creates a copied method with prefix :db! ## showing the method & args ## Methodology : #---------------- HISTORY --------------------- # (2017/01/16 - Mark Field (FCSI)): Created. #---------------------------------------------- _self.fcsi_copy_method(exmplr,a_method,:db!) _local methProc << _proc (_gather args) _import exmplr,a_method show(exmplr.class_name,a_method,_scatter args) _return _self.perform(:db!+a_method,_scatter args) _endproc exmplr.define_method(a_method,methProc,_false) _endmethod $ _pragma(classify_level=advanced, topic={FCSI}) _method fcsi_method_manip.fcsi_show_traceback(exmplr,a_method) ## Parameters : exmplr - the exemplar ## a_method - the method to show tb within ## Returns : nothing ## Function : creates a copied method with prefix :db! ## showing a traceback ## Methodology : #---------------- HISTORY --------------------- # (2017/10/25 - Mark Field (FCSI)) : Created. #---------------------------------------------- _self.fcsi_copy_method(exmplr,a_method,:db!) _local methProc << _proc (_gather args) _import exmplr,a_method !traceback!(!terminal!) _return _self.perform(:db!+a_method,_scatter args) _endproc exmplr.define_method(a_method,methProc,_false) _endmethod $ _pragma(classify_level=advanced, topic={FCSI}) _method fcsi_method_manip.fcsi_create_traceback_snapshot(exmplr,a_method) ## Parameters : exmplr - the exemplar ## a_method - the method to show arguments ## Returns : nothing ## Function : creates a copied method with prefix :tb! ## This will create traceback_snapshot type objects and store ## them on traceback_snapshot.fcsi_stack ## Methodology : #---------------- HISTORY --------------------- # (2018/03/12 - Mark Field (FCSI)) : Created. # (2018/05/11 - Mark Field (FCSI)): Modified - test for local # copied method #---------------------------------------------- _if _not exmplr.method_table.local_method?(:tb!+a_method) _then _return _endif _self.fcsi_copy_method(exmplr,a_method,:tb!) _local methProc << _proc (_gather args) _import exmplr,a_method _local tbss << get_global_value(:traceback_snapshot) tbss.fcsi_new(_self,args,a_method) _return _self.perform(:tb!+a_method,_scatter args) _endproc exmplr.define_method(a_method,methProc,_false) _endmethod $ _pragma(classify_level=advanced, topic={FCSI}) _method fcsi_method_manip.fcsi_restore_method(exmplr,a_method,prefix) ## Parameters : ## ## prefix :sw! or db! or whatever you used ## Returns : ## Function : ## Methodology : #---------------- HISTORY --------------------- # (2017/10/25 - Mark Field (FCSI)): Created. # (2018/03/12 - Mark Field (FCSI)): Modified - redid algorithm #---------------------------------------------- _local meth << exmplr.method(prefix+a_method) _if meth _is _unset _then _return _endif exmplr.define_method(a_method,meth.value,_false) exmplr.remove_method(prefix+a_method) # _self.fcsi_copy_method(exmplr,a_method,prefix) # _local methProc << # _proc (_gather args) # _import exmplr,a_method,prefix # _return _self.perform(prefix+a_method,_scatter args) # _endproc # exmplr.define_method(a_method,methProc,_false) _endmethod $