From f533f98ccca249547e314fa2931897a15bfcf682 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Wed, 25 Nov 2015 11:54:06 -0500 Subject: [PATCH] code: explicitly call init in some named constructors Signed-off-by: Jean Privat --- contrib/nitrpg/src/statistics.nit | 1 + contrib/refund/src/refund_base.nit | 4 ++-- lib/android/assets_and_resources.nit | 3 +-- lib/csv/csv.nit | 4 ++-- lib/github/api.nit | 6 ++---- lib/github/events.nit | 2 +- lib/html/bootstrap.nit | 6 ++---- lib/html/html.nit | 2 +- lib/markdown/markdown.nit | 2 +- 9 files changed, 13 insertions(+), 17 deletions(-) diff --git a/contrib/nitrpg/src/statistics.nit b/contrib/nitrpg/src/statistics.nit index 0bdb421..2827ae9 100644 --- a/contrib/nitrpg/src/statistics.nit +++ b/contrib/nitrpg/src/statistics.nit @@ -166,6 +166,7 @@ class GameStats # Load `self` from saved data. init from_json(game: Game, period: String, owner: GameEntity, json: JsonObject) do + init(game, period, owner) var values = json.get_or_null("values") if not values isa JsonObject then return for k, v in values do self[k] = v.as(Int) diff --git a/contrib/refund/src/refund_base.nit b/contrib/refund/src/refund_base.nit index ec1de5a..48e1833 100644 --- a/contrib/refund/src/refund_base.nit +++ b/contrib/refund/src/refund_base.nit @@ -352,7 +352,7 @@ class UniqCare # * `max`: max amount refunded for this `Care` in a reclamation sheet. # * `month_max`: max amount refunded by month. init with_vals(id: Int, cover: Float, max, month_max: nullable Dollar) do - self.id = id + init(id) self.cover = cover self.max = max self.month_max = month_max @@ -382,7 +382,7 @@ class RangeCare # * `max`: max amount refunded for this `Care` in a reclamation sheet. # * `month_max`: max amount refunded by month. init with_vals(id: Range[Int], cover: Float, max, month_max: nullable Dollar) do - self.id = id + init(id) self.cover = cover self.max = max self.month_max = month_max diff --git a/lib/android/assets_and_resources.nit b/lib/android/assets_and_resources.nit index 624a03d..8bbc7da 100644 --- a/lib/android/assets_and_resources.nit +++ b/lib/android/assets_and_resources.nit @@ -218,8 +218,7 @@ class ResourcesManager private init native(res: NativeResources, app_package: String) do - self.android_resources = res.new_global_ref - self.app_package = app_package + init(res.new_global_ref, app_package) end # Get a color from resources diff --git a/lib/csv/csv.nit b/lib/csv/csv.nit index f76d41c..57590ad 100644 --- a/lib/csv/csv.nit +++ b/lib/csv/csv.nit @@ -169,7 +169,7 @@ class CsvWriter # Create a new writer with the specified format. init with_format(ostream:Writer, format: CsvFormat) do - self.ostream = ostream + init(ostream) self.format = format end @@ -260,7 +260,7 @@ class CsvReader # Create a new reader with the specified format. init with_format(istream:Reader, format: CsvFormat) do - self.istream = istream + init(istream) self.format = format end diff --git a/lib/github/api.nit b/lib/github/api.nit index 18880ec..59917c5 100644 --- a/lib/github/api.nit +++ b/lib/github/api.nit @@ -557,8 +557,7 @@ abstract class RepoEntity # Init `self` from a `json` object. init from_json(api: GithubAPI, repo: Repo, json: JsonObject) do - self.api = api - self.repo = repo + init(api, repo) self.json = json end end @@ -1572,8 +1571,7 @@ class ContributorStats # Init `self` from a `json` object. init from_json(api: GithubAPI, json: JsonObject) do - self.api = api - self.json = json + init(api, json) end # User these statistics are about. diff --git a/lib/github/events.nit b/lib/github/events.nit index 543a786..33c637f 100644 --- a/lib/github/events.nit +++ b/lib/github/events.nit @@ -34,7 +34,7 @@ class GithubEvent # Init `self` from a `json` object. init from_json(api: GithubAPI, json: JsonObject) do - self.api = api + init(api) self.json = json end diff --git a/lib/html/bootstrap.nit b/lib/html/bootstrap.nit index 66befa3..d7960e3 100644 --- a/lib/html/bootstrap.nit +++ b/lib/html/bootstrap.nit @@ -70,8 +70,7 @@ class Link # Creates a link with a `title` attribute. init with_title(href: String, text: Writable, title: nullable String) do - self.href = href - self.text = text + init(href, text) self.title = title end @@ -112,8 +111,7 @@ class Header # Creates a link with a `title` attribute. init with_subtext(level: Int, text: Writable, subtext: String) do - self.level = level - self.text = text + init(level, text) self.subtext = subtext end diff --git a/lib/html/html.nit b/lib/html/html.nit index 6cb192b..b5f5529 100644 --- a/lib/html/html.nit +++ b/lib/html/html.nit @@ -123,7 +123,7 @@ class HTMLTag # Create a HTML elements with the specifed type and attributes. init with_attrs(tag: String, attrs: Map[String, String]) do - self.tag = tag + init(tag) self.attrs = attrs end diff --git a/lib/markdown/markdown.nit b/lib/markdown/markdown.nit index 7907409..ef247be 100644 --- a/lib/markdown/markdown.nit +++ b/lib/markdown/markdown.nit @@ -634,7 +634,7 @@ class LinkRef # Create a link with a title. init with_title(link: String, title: nullable String) do - self.link = link + init(link) self.title = title end end -- 1.7.9.5