From: Jean Privat Date: Thu, 26 Feb 2015 04:08:14 +0000 (+0700) Subject: code: replace `is cached` by `is lazy` X-Git-Tag: v0.7.2~2^2~5 X-Git-Url: http://nitlanguage.org code: replace `is cached` by `is lazy` Signed-off-by: Jean Privat --- diff --git a/contrib/jwrapper/src/model.nit b/contrib/jwrapper/src/model.nit index 34792c9..d38a7a1 100644 --- a/contrib/jwrapper/src/model.nit +++ b/contrib/jwrapper/src/model.nit @@ -230,9 +230,9 @@ class JavaType return id end - fun collections_list: Array[String] is cached do return ["List", "ArrayList", "LinkedList", "Vector", "Set", "SortedSet", "HashSet", "TreeSet", "LinkedHashSet", "Map", "SortedMap", "HashMap", "TreeMap", "Hashtable", "LinkedHashMap"] - fun iterable: Array[String] is cached do return ["ArrayList", "Set", "HashSet", "LinkedHashSet", "LinkedList", "Stack", "TreeSet", "Vector"] - fun maps: Array[String] is cached do return ["Map", "SortedMap", "HashMap", "TreeMap", "Hashtable", "LinkedHashMap"] + var collections_list: Array[String] is lazy do return ["List", "ArrayList", "LinkedList", "Vector", "Set", "SortedSet", "HashSet", "TreeSet", "LinkedHashSet", "Map", "SortedMap", "HashMap", "TreeMap", "Hashtable", "LinkedHashMap"] + var iterable: Array[String] is lazy do return ["ArrayList", "Set", "HashSet", "LinkedHashSet", "LinkedList", "Stack", "TreeSet", "Vector"] + var maps: Array[String] is lazy do return ["Map", "SortedMap", "HashMap", "TreeMap", "Hashtable", "LinkedHashMap"] end class NitType diff --git a/contrib/nitiwiki/src/wiki_base.nit b/contrib/nitiwiki/src/wiki_base.nit index fa78818..1527d4c 100644 --- a/contrib/nitiwiki/src/wiki_base.nit +++ b/contrib/nitiwiki/src/wiki_base.nit @@ -308,7 +308,7 @@ abstract class WikiEntry # Result is returned as an array containg ordered entries: # `breadcrumbs.first` is the root entry and # `breadcrumbs.last == self` - fun breadcrumbs: Array[WikiEntry] is cached do + var breadcrumbs: Array[WikiEntry] is lazy do var path = new Array[WikiEntry] var entry: nullable WikiEntry = self while entry != null and not entry.is_root do @@ -538,7 +538,7 @@ class WikiArticle # Extract the markdown text from `source_file`. # # REQUIRE: `has_source`. - fun md: String is cached do + var md: String is lazy do assert has_source var file = new FileReader.open(src_full_path.to_s) var md = file.read_all @@ -577,7 +577,7 @@ class WikiConfig # # * key: `wiki.name` # * default: `MyWiki` - fun wiki_name: String is cached do return value_or_default("wiki.name", "MyWiki") + var wiki_name: String is lazy do return value_or_default("wiki.name", "MyWiki") # Site description. # @@ -585,7 +585,7 @@ class WikiConfig # # * key: `wiki.desc` # * default: `` - fun wiki_desc: String is cached do return value_or_default("wiki.desc", "") + var wiki_desc: String is lazy do return value_or_default("wiki.desc", "") # Site logo url. # @@ -593,13 +593,13 @@ class WikiConfig # # * key: `wiki.logo` # * default: `` - fun wiki_logo: String is cached do return value_or_default("wiki.logo", "") + var wiki_logo: String is lazy do return value_or_default("wiki.logo", "") # Root url of the wiki. # # * key: `wiki.root_url` # * default: `http://localhost/` - fun root_url: String is cached do return value_or_default("wiki.root_url", "http://localhost/") + var root_url: String is lazy do return value_or_default("wiki.root_url", "http://localhost/") # Root directory of the wiki. @@ -608,7 +608,7 @@ class WikiConfig # # * key: `wiki.root_dir` # * default: `./` - fun root_dir: String is cached do return value_or_default("wiki.root_dir", "./").simplify_path + var root_dir: String is lazy do return value_or_default("wiki.root_dir", "./").simplify_path # Pages directory. # @@ -616,7 +616,7 @@ class WikiConfig # # * key: `wiki.source_dir # * default: `pages/` - fun source_dir: String is cached do + var source_dir: String is lazy do return value_or_default("wiki.source_dir", "pages/").simplify_path end @@ -627,7 +627,7 @@ class WikiConfig # # * key: `wiki.out_dir` # * default: `out/` - fun out_dir: String is cached do return value_or_default("wiki.out_dir", "out/").simplify_path + var out_dir: String is lazy do return value_or_default("wiki.out_dir", "out/").simplify_path # Asset files directory. # @@ -636,7 +636,7 @@ class WikiConfig # # * key: `wiki.assets_dir` # * default: `assets/` - fun assets_dir: String is cached do + var assets_dir: String is lazy do return value_or_default("wiki.assets_dir", "assets/").simplify_path end @@ -647,7 +647,7 @@ class WikiConfig # # * key: `wiki.templates_dir` # * default: `templates/` - fun templates_dir: String is cached do + var templates_dir: String is lazy do return value_or_default("wiki.templates_dir", "templates/").simplify_path end @@ -657,7 +657,7 @@ class WikiConfig # # * key: `wiki.template` # * default: `template.html` - fun template_file: String is cached do + var template_file: String is lazy do return value_or_default("wiki.template", "template.html") end @@ -668,7 +668,7 @@ class WikiConfig # # * key: `wiki.header` # * default: `header.html` - fun header_file: String is cached do + var header_file: String is lazy do return value_or_default("wiki.header", "header.html") end @@ -678,7 +678,7 @@ class WikiConfig # # * key: `wiki.menu` # * default: `menu.html` - fun menu_file: String is cached do + var menu_file: String is lazy do return value_or_default("wiki.menu", "menu.html") end @@ -689,7 +689,7 @@ class WikiConfig # # * key: `wiki.footer` # * default: `footer.html` - fun footer_file: String is cached do + var footer_file: String is lazy do return value_or_default("wiki.footer", "footer.html") end @@ -699,19 +699,19 @@ class WikiConfig # # * key: `wiki.rsync_dir` # * default: `` - fun rsync_dir: String is cached do return value_or_default("wiki.rsync_dir", "") + var rsync_dir: String is lazy do return value_or_default("wiki.rsync_dir", "") # Remote repository used to pull modifications on sources. # # * key: `wiki.git_origin` # * default: `origin` - fun git_origin: String is cached do return value_or_default("wiki.git_origin", "origin") + var git_origin: String is lazy do return value_or_default("wiki.git_origin", "origin") # Remote branch used to pull modifications on sources. # # * key: `wiki.git_branch` # * default: `master` - fun git_branch: String is cached do return value_or_default("wiki.git_branch", "master") + var git_branch: String is lazy do return value_or_default("wiki.git_branch", "master") end # WikiSection custom configuration. diff --git a/contrib/nitiwiki/src/wiki_html.nit b/contrib/nitiwiki/src/wiki_html.nit index 10ab09b..3427016 100644 --- a/contrib/nitiwiki/src/wiki_html.nit +++ b/contrib/nitiwiki/src/wiki_html.nit @@ -107,7 +107,7 @@ redef class WikiSection # # If no file `index.md` exists for this section, # a summary is generated using contained articles. - fun index: WikiArticle is cached do + var index: WikiArticle is lazy do for child in children.values do if child isa WikiArticle and child.is_index then return child end diff --git a/lib/android/assets_and_resources.nit b/lib/android/assets_and_resources.nit index 8195e2c..ae124ba 100644 --- a/lib/android/assets_and_resources.nit +++ b/lib/android/assets_and_resources.nit @@ -372,10 +372,10 @@ end redef class App # Resource Manager used to manage resources placed in the `res` folder of the app - fun resource_manager: ResourcesManager is cached do return new ResourcesManager(self.resources, self.package_name.to_s) + var resource_manager: ResourcesManager is lazy do return new ResourcesManager(self.resources, self.package_name.to_s) # Assets Manager used to manage resources placed in the `assets` folder of the app - fun asset_manager: AssetManager is cached do return new AssetManager(self) + var asset_manager: AssetManager is lazy do return new AssetManager(self) # Get the native AssetsManager of the application, used to initialize the nit's AssetManager private fun assets: NativeAssetManager import native_activity in "Java" `{ return App_native_activity(recv).getAssets(); `} diff --git a/lib/android/audio.nit b/lib/android/audio.nit index 2301bd0..74452e0 100644 --- a/lib/android/audio.nit +++ b/lib/android/audio.nit @@ -415,12 +415,12 @@ redef class App # Returns the default MediaPlayer of the application. # When you load a music, it goes in this MediaPlayer. # Use it for advanced sound management - fun default_mediaplayer: MediaPlayer is cached do return new MediaPlayer + var default_mediaplayer: MediaPlayer is lazy do return new MediaPlayer # Returns the default MediaPlayer of the application. # When you load a short sound (not a music), it's added to this soundpool. # Use it for advanced sound management. - fun default_soundpool: SoundPool is cached do return new SoundPool + var default_soundpool: SoundPool is lazy do return new SoundPool # Get the native audio manager fun audio_manager: NativeAudioManager import native_activity in "Java" `{ diff --git a/lib/android/shared_preferences/shared_preferences_api10.nit b/lib/android/shared_preferences/shared_preferences_api10.nit index 05dbf82..6b6edde 100644 --- a/lib/android/shared_preferences/shared_preferences_api10.nit +++ b/lib/android/shared_preferences/shared_preferences_api10.nit @@ -404,7 +404,7 @@ class SharedPreferences end redef class App - fun shared_preferences: SharedPreferences is cached do + var shared_preferences: SharedPreferences is lazy do return new SharedPreferences.privately(self, "") end end diff --git a/lib/android/vibration.nit b/lib/android/vibration.nit index f56dbef..79941dc 100644 --- a/lib/android/vibration.nit +++ b/lib/android/vibration.nit @@ -48,7 +48,7 @@ end redef class App # Get the handle to this device vibrator as a global ref - fun vibrator: Vibrator is cached do + var vibrator: Vibrator is lazy do var v = vibrator_native(native_activity) return v.new_global_ref end diff --git a/lib/sqlite3/sqlite3.nit b/lib/sqlite3/sqlite3.nit index 23b1ef7..0fe8050 100644 --- a/lib/sqlite3/sqlite3.nit +++ b/lib/sqlite3/sqlite3.nit @@ -161,7 +161,7 @@ class StatementEntry # Name of the column # # require: `self.statement.is_open` - fun name: String is cached do + var name: String is lazy do assert statement_closed: statement.is_open return statement.native_statement.column_name(index) diff --git a/lib/standard/ropes.nit b/lib/standard/ropes.nit index 243f98f..644e3dc 100644 --- a/lib/standard/ropes.nit +++ b/lib/standard/ropes.nit @@ -67,7 +67,7 @@ private abstract class RopeString super Rope super String - redef fun chars is cached do return new RopeChars(self) + redef var chars is lazy do return new RopeChars(self) end # Node that represents a concatenation between two `String` @@ -80,7 +80,7 @@ private class Concat redef fun empty do return "" - redef fun to_cstring is cached do + redef var to_cstring is lazy do var len = length var ns = new NativeString(len + 1) ns[len] = '\0' @@ -177,7 +177,7 @@ class RopeBuffer super Rope super Buffer - redef fun chars: Sequence[Char] is cached do return new RopeBufferChars(self) + redef var chars: Sequence[Char] is lazy do return new RopeBufferChars(self) # The final string being built on the fly private var str: String is noinit diff --git a/src/model_utils.nit b/src/model_utils.nit index 7302619..24105e6 100644 --- a/src/model_utils.nit +++ b/src/model_utils.nit @@ -34,7 +34,7 @@ redef class MConcern end redef class MProject - redef fun concern_rank is cached do + redef var concern_rank is lazy do var max = 0 for mgroup in mgroups do var mmax = mgroup.concern_rank @@ -87,7 +87,7 @@ redef class MGroup return res end - redef fun concern_rank is cached do + redef var concern_rank is lazy do var max = 0 for mmodule in collect_mmodules do var mmax = mmodule.concern_rank @@ -163,7 +163,7 @@ redef class MModule return mclasses end - redef fun concern_rank is cached do + redef var concern_rank is lazy do var max = 0 for p in in_importation.direct_greaters do var pmax = p.concern_rank diff --git a/src/nitserial.nit b/src/nitserial.nit index 98b1923..ea2e4b4 100644 --- a/src/nitserial.nit +++ b/src/nitserial.nit @@ -78,7 +78,7 @@ end redef class MModule # Get the type of the class `Serializable` - fun serializable_type: MClassType is cached do + var serializable_type: MClassType is lazy do return self.get_primitive_class("Serializable").mclass_type end end