# Get the web page
var body = download_html_page
+ if opts.verbose.value > 1 then
+ print " # Body"
+ print body
+ end
+
# Parse the Web page and get the available beers
var beers = parse_beers_from_html(body)
+ if opts.verbose.value > 0 then
+ print " # Beers"
+ print beers
+ end
+
var db = new DB.open(db_path)
# Update the database with the beers of the day
# Set the email if desired
if send_emails then
var subs = db.subscribers
+ if opts.verbose.value > 0 then
+ print " # Subscribers"
+ print subs
+ end
send_emails_to subs
end
var of_interest = body.substring(start, finish-start)
var lines = of_interest.strip_tags.to_clean_lines
+ if opts.verbose.value > 0 then
+ print " # Lines"
+ print lines
+ end
+
var beers = new HashSet[Beer]
for line in lines do
- var parts = line.split(" - ")
+ var parts = line.split("- ")
if parts.length >= 2 then
beers.add new Beer(parts[0].trim, parts[1].trim)
end
# Shall we mail the mailing list?
var send_emails = new OptionBool("Send emails to subscribers", "-e", "--email")
+ # Display more debug messages
+ var verbose = new OptionCount("Display extra debug messages", "-v")
+
# Print the usage message
var help = new OptionBool("Print this help message", "-h", "--help")
- redef init do add_option(send_emails, help)
+ redef init do add_option(send_emails, verbose, help)
+end
+
+redef class Sys
+ # Command line options
+ var opts = new OptionContext
end
# Avoid executing when running tests
if "NIT_TESTING".environ == "true" then exit 0
-var opts = new OptionContext
opts.parse args
if not opts.errors.is_empty or opts.help.value == true then
print opts.errors.join("\n")
--- /dev/null
+first page
--- /dev/null
+# A independant trail
+
+a [[trail: first]] and a [[trail: second]] page.
--- /dev/null
+a second page
var res = new Template
res.add "<ul class=\"trail\">"
- if pos > 0 then
- var target = flat[pos-1]
- res.add "<li>{target.a_from(self, "prev")}</li>"
- end
var parent = wiki.trails.parent(self)
+ # Up and prev are disabled on a root
if parent != null then
+ if pos > 0 then
+ var target = flat[pos-1]
+ res.add "<li>{target.a_from(self, "prev")}</li>"
+ end
res.add "<li>{parent.a_from(self, "up")}</li>"
end
if pos < flat.length - 1 then
var target = flat[pos+1]
- res.add "<li>{target.a_from(self, "next")}</li>"
+ # Only print the next if it is not a root
+ if target.parent != null then
+ res.add "<li>{target.a_from(self, "next")}</li>"
+ end
end
res.add "</ul>"
class Achievement
super GameEntity
- redef var key is lazy do return "achievements" / id
redef var game
+ redef var key is lazy do
+ var owner = self.owner
+ if owner == null then return id
+ return "{owner.key}-{id}"
+ end
+
# Uniq ID for this achievement.
var id: String
# Is this achievement unlocked by somebody?
var is_unlocked: Bool is lazy do return not load_events.is_empty
+ # Game entity this achievement is about.
+ var owner: nullable GameEntity = null
+
# Init `self` from a `json` object.
#
# Used to load achievements from storage.
json["name"] = name
json["desc"] = desc
json["reward"] = reward
+ json["game"] = game.key
+ if owner != null then json["owner"] = owner.key
return json
end
end
if not event.action == "closed" then return
if not event.pull.merged then return
var player = event.pull.user.player(game)
- if player.stats["commits"] == threshold then
+ if player.stats["commits"] >= threshold then
var a = new_achievement(game)
player.unlock_achievement(a, event)
end
class Player1KComments
super PlayerXComments
- redef var id = "player_1000__comments"
+ redef var id = "player_1000_comments"
redef var name = "You sir, talk a lot!"
redef var desc = "Comment 1000 times on issues."
redef var reward = 1000
redef class GameEntity
- # Saves `event` in `self`.
- fun add_event(event: GameEvent) do event.save_in(self.key)
+ fun add_event(event: GameEvent) do
+ event.owner = self
+ event.save
+ end
# List all events registered in this entity.
#
class GameEvent
super GameEntity
- redef var key is lazy do return "events" / internal_id
redef var game
+ # Entity this event belongs to.
+ var owner: nullable GameEntity = null
+
# String used to dissociate events in the display.
var kind: String
# GameEvent uniq id used for storage.
var internal_id: String is noinit
+ redef var key = internal_id is lazy
+
# Date and time of the event.
var time: ISODate is noinit, writable
json["kind"] = kind
json["time"] = time.to_s
json["data"] = data
+ json["game"] = game.key
+ if owner != null then json["owner"] = owner.key
return json
end
end
redef fun game do return self
- # Returns the repo `full_name`.
- #
- # Example: `"nitlang/nit"`
- redef fun key do return repo.full_name
-
# We need a `GithubAPI` client to load Github data.
var api: GithubAPI
# A game takes place in a `github::Repo`.
var repo: Repo
+ # Game name
+ var name: String = repo.full_name is lazy
+
# Directory where game data are stored.
var game_dir: String is lazy do return "nitrpg_data" / repo.full_name
+ redef var key = name is lazy
+
# Used for data storage.
#
# File are stored in `game_dir`.
# Used to load entities from saved data.
fun from_json(json: JsonObject) do end
+ redef fun to_json do
+ var json = super
+ json["name"] = name
+ return json
+ end
+
# Create a player from a Github `User`.
#
# Or return the existing one from game data.
class Player
super GameEntity
- # Key is based on player `name`.
- redef var key is lazy do return "players" / name
-
redef var game
# FIXME contructor should be private
# The name is also used to load the user data lazilly from Github API.
var name: String
+ redef var key = name is lazy
+
# Player amount of nitcoins.
#
# Nitcoins is the currency used in nitrpg.
redef fun to_json do
var json = super
+ json["game"] = game.key
json["name"] = name
json["nitcoins"] = nitcoins
return json
# Rewards player for opened pull requests.
redef fun react_player_event(r, game) do
- if action == "opened" then
+ if action == "opened" or action == "reopened" then
react_pull_open(r, game)
else if action == "closed" then
react_pull_close(r, game)
# Rewards player for review comments.
#
# TODO only give nitcoins if reviewers < 2
+ # TODO give more points to first reviewer
redef fun react_player_event(r, game) do
if comment.is_ack then
react_player_review(r, game)
end
end
+ # TODO same player should not be authorized to review multiple times? How to handle rerols?
private fun react_player_review(r: PlayerReactor, game: Game) do
+ if issue.state == "closed" then return
var player = comment.user.player(game)
+ if issue.user == player.user then return
player.nitcoins += r.nc_pull_review
player.save
var event = player_reward_event("pull_review", player, r.nc_pull_review)
# The GameEntity monitored by these statistics.
var owner: GameEntity
- redef var key = "stats"
+ # Current date to extract stats
+ private var date = new Tm.gmtime
# Returns the `GameStats` instance for the overall statistics.
- var overall: GameStats is lazy do
- return load_stats_for("all")
- end
+ var overall: GameStats = load_stats_for("all") is lazy
# Returns the `GameStats` instance for the current year statistics.
- var yearly: GameStats is lazy do
- var date = new Tm.gmtime
- var key = date.strftime("%Y")
- return load_stats_for(key)
- end
+ var yearly: GameStats = load_stats_for(date.strftime("%Y")) is lazy
# Returns the `GameStats` instance for the current month statistics.
- var monthly: GameStats is lazy do
- var date = new Tm.gmtime
- var key = date.strftime("%Y-%m")
- return load_stats_for(key)
- end
+ var monthly: GameStats = load_stats_for(date.strftime("%Y-%m")) is lazy
# Returns the `GameStats` instance for the current day statistics.
- var daily: GameStats is lazy do
- var date = new Tm.gmtime
- var key = date.strftime("%Y-%m-%d")
- return load_stats_for(key)
- end
+ var daily: GameStats = load_stats_for(date.strftime("%Y-%m-%d")) is lazy
# Returns the `GameStats` instance for the current week statistics.
- var weekly: GameStats is lazy do
- var date = new Tm.gmtime
- var key = date.strftime("%Y-W%U")
- return load_stats_for(key)
- end
+ var weekly: GameStats = load_stats_for(date.strftime("%Y-W%U")) is lazy
# Load statistics for a `period` key.
fun load_stats_for(period: String): GameStats do
var key = owner.key / self.key / period
if not game.store.has_key(key) then
- return new GameStats(game, period)
+ return new GameStats(game, period, owner)
end
var json = game.store.load_object(key)
- return new GameStats.from_json(game, period, json)
+ return new GameStats.from_json(game, period, owner, json)
end
redef fun [](key) do return overall[key]
redef var game
- # The pedriod these stats are about.
+ # The period these stats are about.
var period: String
- redef fun key do return period
+ # The game entity these stats are about.
+ var owner: GameEntity
+
+ redef var key = "{owner.key}-{period}" is lazy
# Load `self` from saved data.
- init from_json(game: Game, period: String, json: JsonObject) do
- for k, v in json do self[k] = v.as(Int)
+ init from_json(game: Game, period: String, owner: GameEntity, json: JsonObject) do
+ 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)
end
redef fun to_json do
- var obj = new JsonObject
- for k, v in self do obj[k] = v
+ var obj = super
+ obj["period"] = period
+ obj["owner"] = owner.key
+ var values = new JsonObject
+ values.recover_with(self)
+ obj["values"] = values
return obj
end
redef fun url do return "{root_url}/games" / key
- # Displayed name.
- fun name: String do return repo.full_name
-
# Return a HTML link to this Game.
fun link: String do return "<a href=\"{url}\">{name}</a>"
end
var default_soundpool: SoundPool is lazy do return new SoundPool
# Get the native audio manager
- fun audio_manager: NativeAudioManager import native_activity in "Java" `{
+ private fun audio_manager: NativeAudioManager import native_activity in "Java" `{
return (AudioManager)App_native_activity(self).getSystemService(Context.AUDIO_SERVICE);
`}
# WARNING: SEE: `TermCharFormat`
fun underline: String do return apply_format(normal.underline)
end
+
+# A dynamic progressbar displayable in console.
+#
+# Example:
+# ~~~nitish
+# var max = 10
+# var current = 0
+# var pb = new TermProgress(max, current)
+#
+# pb.display
+# for i in [current + 1 .. max] do
+# nanosleep(1, 0)
+# pb.update(i)
+# end
+#
+# print "\ndone"
+# ~~~
+#
+# Progressbar can accept metadata to display a small amount of data.
+#
+# Example with metadata:
+# ~~~nitish
+# var pb = new TermProgress(10, 0)
+# for i in [0..10] do
+# pb.update(i, "Step {i}")
+# end
+# ~~~
+class TermProgress
+
+ # Max value of the progress bar (business value).
+ var max_value: Int
+
+ # Current value of the progress bar (business value).
+ var current_value: Int
+
+ # Number of columns used to display the progress bar.
+ var max_columns = 70 is writable
+
+ # Get the current percent value.
+ fun current_percentage: Int do
+ return current_value * 100 / max_value
+ end
+
+ # Display the progress bar.
+ #
+ # `metadata` can be used to pass a small amount of data to display after
+ # the progressbar.
+ fun display(metadata: nullable String) do
+ var percent = current_percentage
+ var p = current_value * max_columns / max_value
+ printn "\r{percent}% ["
+ for i in [1..max_columns] do
+ if i < p then
+ printn "="
+ else if i == p then
+ printn ">"
+ else
+ printn " "
+ end
+ end
+ printn "]"
+ if metadata != null then printn " ({metadata})"
+ end
+
+ # Update and display the progresssbar.
+ #
+ # See `display`.
+ fun update(new_current: Int, metadata: nullable String) do
+ current_value = new_current
+ display(metadata)
+ end
+end
end
end
- redef fun iterator: ArrayIterator[E] do
+ redef fun iterator: IndexedIterator[E] do
var res = _free_iterator
if res == null then return new ArrayIterator[E](self)
res._index = 0
redef fun item: E do return _iter.item
- var iter: ArrayIterator[E]
+ var iter: Iterator[E]
end
end
end
- redef fun iterator: HashMapIterator[K, V] do return new HashMapIterator[K,V](self)
+ redef fun iterator do return new HashMapIterator[K,V](self)
redef fun length do return _the_length
fun substring(from: Int, count: Int): SELFTYPE is abstract
# Iterates on the substrings of self if any
- fun substrings: Iterator[FlatText] is abstract
+ private fun substrings: Iterator[FlatText] is abstract
# Is the current Text empty (== "")
#
super
end
+ # Issue id.
+ fun id: Int do return json["id"].as(Int)
+
+ # Set issue id.
+ fun id=(id: Int) do json["id"] = id
+
# Issue title.
fun title: String do return json["title"].as(String)
for obj in array do
if not obj isa JsonObject then continue
var id = obj["id"].as(Int)
- res.add(api.load_issue_comment(repo, id).as(not null))
+ var comment = api.load_issue_comment(repo, id)
+ if comment == null then continue
+ res.add(comment)
end
page += 1
- array = api.get("{key}/comments?page={page}").as(JsonArray)
+ var json = api.get("{key}/comments?page={page}")
+ if not json isa JsonArray then
+ return res
+ end
+ array = json
end
return res
end
self.json = json
end
+ # Event ID from Github.
+ fun id: String do return json["id"].as(String)
+
+ # Set id.
+ fun id=(id: String) do json["id"] = id
+
# Action performed by the event.
fun action: String do return json["action"].as(String)
struct hostent *hostent = gethostbyname(address);
+ if (!hostent) {
+ return NULL;
+ }
+
memset(&sin, 0, sizeof(sin));
sin.sin_family = hostent->h_addrtype;
sin.sin_port = htons(port);
# * [Binary JSON spec](http://bsonspec.org/)
# * [Libbson](http://api.mongodb.org/libbson/1.1.4/)#
private class BSON
- super Finalizable
+ super FinalizableOnce
# Native instance pointer.
var native: NativeBSON
- # Is the native instance valid?
- #
- # This is set to false if the `native` is destroyed.
- var is_alive = true
-
# Returns a new BSON object initialized from the content of `json`.
#
# ~~~
end
redef fun to_s do
- assert is_alive
var ns = native.to_native_string
var res = ns.to_s_with_copy
ns.free # manual free of gc allocated NativeString
# assert json["ELS"].as(JsonArray).is_empty
# ~~~
fun to_json: JsonObject do
- assert is_alive
- return to_s.parse_json.as(JsonObject)
- end
-
- redef fun finalize do
- if is_alive then
- native.destroy
- is_alive = false
+ var json = to_s.parse_json
+ if json isa JsonParseError then
+ print json.message
+ sys.exit 1
end
+ return json.as(JsonObject)
end
+
+ redef fun finalize_once do native.destroy
end
redef class JsonObject
private var native: BSONError
- # Is the native instance valid?
- #
- # This is set to false if the `native` is destroyed.
- private var is_alive = true
-
# Logical domain within a library that created the error.
- fun domain: Int do
- assert is_alive
- return native.domain
- end
+ fun domain: Int do return native.domain
# Domain specific error code.
- fun code: Int do
- assert is_alive
- return native.code
- end
+ fun code: Int do return native.code
# Human readable error message.
fun message: String do
- assert is_alive
var ns = native.message
var res = ns.to_s_with_copy
ns.free
# assert client.server_uri == uri
# ~~~
class MongoClient
- super Finalizable
+ super FinalizableOnce
# Server URI.
var server_uri: String
private var native: NativeMongoClient is noinit
- # Is the native instance valid?
- #
- # This is set to false if the `native` is destroyed.
- private var is_alive = true
-
- init do
- native = new NativeMongoClient(server_uri.to_cstring)
- end
+ init do native = new NativeMongoClient(server_uri.to_cstring)
# Gets server data.
#
# assert client.server_status["process"] == "mongod"
# ~~~
fun server_status: nullable JsonObject do
- assert is_alive
var nbson = native.server_status
if nbson == null then return null
var bson = new BSON(nbson)
# assert client.database_names.has("test")
# ~~~
fun database_names: Array[String] do
- assert is_alive
var res = new Array[String]
var nas = native.database_names
if nas == null then return res
# var client = new MongoClient("mongodb://localhost:27017/")
# assert client.database("test").name == "test"
# ~~~
- fun database(name: String): MongoDb do
- assert is_alive
- return new MongoDb(self, name)
- end
+ fun database(name: String): MongoDb do return new MongoDb(self, name)
# Close the connexion and destroy the instance.
#
# The reference should not be used beyond this point!
- fun close do
- assert is_alive
- finalize
- end
+ fun close do finalize_once
- redef fun finalize do
- if is_alive then
- native.destroy
- is_alive = false
- end
- end
+ redef fun finalize_once do native.destroy
# Last error raised by mongoc.
fun last_error: nullable MongoError do
# first document into a collection.
# There is no need to create a database manually.
class MongoDb
- super Finalizable
+ super FinalizableOnce
# `MongoClient` used to load this database.
var client: MongoClient
private var native: NativeMongoDb is noinit
- # Is the native instance valid?
- #
- # This is set to false if the `native` is destroyed.
- private var is_alive = true
-
- init do
- native = new NativeMongoDb(client.native, name.to_cstring)
- end
+ init do native = new NativeMongoDb(client.native, name.to_cstring)
# Lists available collection names.
#
# assert db.collection_names.has("test")
# ~~~
fun collection_names: Array[String] do
- assert is_alive
var res = new Array[String]
var nas = native.collection_names
if nas == null then return res
# assert col.name == "test"
# ~~~
fun collection(name: String): MongoCollection do
- assert is_alive
return new MongoCollection(self, name)
end
# assert not db.has_collection("qwerty")
# ~~~
fun has_collection(name: String): Bool do
- assert is_alive
# TODO handle error
return native.has_collection(name.to_cstring)
end
# Drop `self`, returns false if an error occured.
- fun drop: Bool do
- assert is_alive
- return native.drop
- end
+ fun drop: Bool do return native.drop
- redef fun finalize do
- if is_alive then
- native.destroy
- is_alive = false
- end
- end
+ redef fun finalize_once do native.destroy
end
# A Mongo collection.
# the first document.
# There is no need to create a database manually.
class MongoCollection
- super Finalizable
+ super FinalizableOnce
# Database that collection belongs to.
var database: MongoDb
private var native: NativeMongoCollection is noinit
- # Is the native instance valid?
- #
- # This is set to false if the `native` is destroyed.
- private var is_alive = true
-
# Loads a collection.
#
# Call `MongoDb::collection` instead.
# assert doc.has_key("_id")
# ~~~
fun insert(doc: JsonObject): Bool do
- assert is_alive
var res = native.insert(doc.to_bson.native)
if res then set_id(doc)
return res
#
# See `insert`.
fun insert_all(docs: Collection[JsonObject]): Bool do
- assert is_alive
var res = true
for doc in docs do res = insert(doc) and res
return res
# assert doc["_id"] == id
# ~~~
fun save(doc: JsonObject): Bool do
- assert is_alive
- var res = native.save(doc.to_bson.native)
+ var bson = doc.to_bson
+ var nat = bson.native
+ var res = native.save(nat)
if res then set_id(doc)
+ assert nat != self #FIXME used to avoid GC crashes
+ assert bson != self #FIXME used to avoid GC crashes
return res
end
# assert col.remove(sel)
# ~~~
fun remove(selector: JsonObject): Bool do
- assert is_alive
return native.remove(selector.to_bson.native)
end
#
# See `remove`.
fun remove_all(selector: JsonObject): Bool do
- assert is_alive
return native.remove_all(selector.to_bson.native)
end
# assert col.update(sel, upd)
# ~~~
fun update(selector: JsonObject, update: JsonObject): Bool do
- assert is_alive
return native.update(
selector.to_bson.native,
update.to_bson.native)
# assert col.count(query) > 0
# ~~~
fun count(query: JsonObject): Int do
- assert is_alive
return native.count(query.to_bson.native)
end
# Finds the first document that matches `query`.
#
+ # Params:
+ # * `skip` number of documents to skip
+ # * `limit` number of documents to return
+ #
# Returns `null` if an error occured. See `Sys::last_mongoc_error`.
#
# ~~~
# var doc = col.find(query)
# assert doc["foo"] == 10
# ~~~
- fun find(query: JsonObject): nullable JsonObject do
- assert is_alive
+ fun find(query: JsonObject, skip, limit: nullable Int): nullable JsonObject do
var q = new NativeBSON.from_json_string(query.to_json.to_cstring)
- var c = native.find(q)
+ var s = skip or else 0
+ var l = limit or else 0
+ var c = native.find(q, s, l)
q.destroy
if c == null then return null
var cursor = new MongoCursor(c)
- if cursor.is_ok then return cursor.item
- return null
+ if not cursor.is_ok then
+ return null
+ end
+ var item = cursor.item
+ assert cursor != self
+ return item
end
# Finds all the documents matching the `query`.
#
+ # Params:
+ # * `skip` number of documents to skip
+ # * `limit` number of documents to return
+ #
# ~~~
# var client = new MongoClient("mongodb://localhost:27017/")
# var col = client.database("test").collection("test")
# query["foo"] = 10
# assert col.find_all(query).length > 0
# ~~~
- fun find_all(query: JsonObject): Array[JsonObject] do
- assert is_alive
+ fun find_all(query: JsonObject, skip, limit: nullable Int): Array[JsonObject] do
+ var s = skip or else 0
+ var l = limit or else 0
var res = new Array[JsonObject]
- var c = native.find(query.to_bson.native)
+ var c = native.find(query.to_bson.native, s, l)
if c == null then return res
var cursor = new MongoCursor(c)
- for item in cursor do res.add item
+ while cursor.is_ok do
+ res.add cursor.item
+ cursor.next
+ end
return res
end
# assert col.stats["ns"] == "test.test"
# ~~~
fun stats: nullable JsonObject do
- assert is_alive
var bson = native.stats
if bson == null then return null
return new JsonObject.from_bson(new BSON(bson))
end
# Drops `self`, returns false if an error occured.
- fun drop: Bool do
- assert is_alive
- return native.drop
- end
+ fun drop: Bool do return native.drop
# Moves `self` to another `database`.
#
# this collection after the move.
# Additional operations will occur on moved collection.
fun move(database: MongoDb): Bool do
- assert is_alive
self.database = database
return native.rename(database.name.to_cstring, name.to_cstring)
end
# to continue using this collection after the rename.
# Additional operations will occur on renamed collection.
fun rename(name: String): Bool do
- assert is_alive
self.name = name
return native.rename(database.name.to_cstring, name.to_cstring)
end
- redef fun finalize do
- if is_alive then
- native.destroy
- is_alive = false
- end
- end
+ redef fun finalize_once do native.destroy
end
# A MongoDB query cursor.
# It wraps up the wire protocol negotation required to initiate a query and
# retreive an unknown number of documents.
class MongoCursor
- super Finalizable
+ super FinalizableOnce
super Iterator[JsonObject]
private var native: NativeMongoCursor
- # Is the native instance valid?
- #
- # This is set to false if the `native` is destroyed.
- private var is_alive = true
-
init do next
- redef fun is_ok do
- assert is_alive
- return native.more
- end
+ redef var is_ok = true
- redef fun next do
- assert is_alive
- native.next
- end
+ redef fun next do is_ok = native.next
redef fun item do
- assert is_alive
return new JsonObject.from_bson(new BSON(native.current))
end
- redef fun finalize do
- if is_alive then
- native.destroy
- is_alive = false
- end
- end
+ redef fun finalize_once do native.destroy
end
#
# If you would like to specify options such as a sort order,
# the query must be placed inside of `{"$query": {}}`.
- fun find(query: NativeBSON): nullable NativeMongoCursor import
+ fun find(query: NativeBSON, skip, limit: Int): nullable NativeMongoCursor import
NativeMongoCursor.as nullable, set_mongoc_error `{
bson_error_t error;
mongoc_cursor_t *cursor;
- cursor = mongoc_collection_find(self, MONGOC_QUERY_NONE, 0, 0, 0, query, NULL, NULL);
+ cursor = mongoc_collection_find(self, MONGOC_QUERY_NONE, skip, limit, 0, query, NULL, NULL);
if (mongoc_cursor_error(cursor, &error)) {
NativeMongoCollection_set_mongoc_error(self, &error);
return null_NativeMongoCursor();
# Wrapper for `mongoc_cursor_current()`.
#
# Fetches the cursors current document or NULL if there has been an error.
- fun current: NativeBSON `{ return (bson_t*) mongoc_cursor_current(self); `}
+ fun current: NativeBSON `{
+ // As said in documentation, BSON objects should not be freed manually.
+ bson_t* bson = (bson_t*) mongoc_cursor_current(self);
+ // Copy BSON so we can let the GC free it automatically.
+ return bson_copy(bson);
+ `}
# Wrapper for `mongoc_cursor_next()`.
#
return mongoc_cursor_next(self, &doc);
`}
- # Wrapper for `mongoc_cursor_more()`.
- #
- # This function shall indicate if there is more data to be read from the cursor.
- fun more: Bool `{ return mongoc_cursor_more(self); `}
-
# Wrapper for `mongoc_cursor_destroy()`.
#
# This instance should not be used beyond this point!
fun compile_callback_to_cpp(mmodule: MModule, mainmodule: MModule) do end
end
-fun cpp_call_context: CppCallContext do return once new CppCallContext
-fun to_cpp_call_context: ToCppCallContext do return once new ToCppCallContext
-fun from_cpp_call_context: FromCppCallContext do return once new FromCppCallContext
+private fun cpp_call_context: CppCallContext do return once new CppCallContext
+private fun to_cpp_call_context: ToCppCallContext do return once new ToCppCallContext
+private fun from_cpp_call_context: FromCppCallContext do return once new FromCppCallContext
redef class MExplicitCall
redef fun compile_callback_to_cpp(mmodule, mainmodule)
end
end
- if mysignature.arity > 0 then
+ if nsig != null then
# Check parameters visibility
for i in [0..mysignature.arity[ do
var nt = nsig.n_params[i].n_type
import semantize
-private import csv # for live_types_to_csv
+import csv # for live_types_to_csv
private import ordered_tree # for live_methods_to_tree
private import more_collections
protected fun proA(a: A) do end
private fun priA(a: A) do end
+ fun pubA2: A do abort
+ protected fun proA2: A do abort
+ private fun priA2: A do abort
+
var vpubA: nullable A is writable, noinit
protected var vproA: nullable A is protected writable, noinit
private var vpriA: nullable A is noinit
#alt2#protected fun proB(a: B) do end
private fun priB(a: B) do end
+ #alt1#fun pubB2: B do abort
+ #alt2#protected fun proB2: B do abort
+ private fun priB2: B do abort
+
#alt3#var vpubB: nullable B is writable, noinit
#alt4#protected var vproB: nullable B is protected writable, noinit
private var vpriB: nullable B is noinit
-alt/base_prot_sig_alt1.nit:29,14: Error: the public property `pubB` cannot contain the private type `B`.
+alt/base_prot_sig_alt1.nit:33,14: Error: the public property `pubB` cannot contain the private type `B`.
+alt/base_prot_sig_alt1.nit:37,13: Error: the public property `pubB2` cannot contain the private type `B`.
-alt/base_prot_sig_alt2.nit:30,24: Error: the protected property `proB` cannot contain the private type `B`.
+alt/base_prot_sig_alt2.nit:34,24: Error: the protected property `proB` cannot contain the private type `B`.
+alt/base_prot_sig_alt2.nit:38,23: Error: the protected property `proB2` cannot contain the private type `B`.
-alt/base_prot_sig_alt3.nit:33,13--22: Error: the public property `vpubB` cannot contain the private type `B`.
-alt/base_prot_sig_alt3.nit:33,13--22: Error: the public property `vpubB=` cannot contain the private type `B`.
+alt/base_prot_sig_alt3.nit:41,13--22: Error: the public property `vpubB` cannot contain the private type `B`.
+alt/base_prot_sig_alt3.nit:41,13--22: Error: the public property `vpubB=` cannot contain the private type `B`.
-alt/base_prot_sig_alt4.nit:34,23--32: Error: the protected property `vproB` cannot contain the private type `B`.
-alt/base_prot_sig_alt4.nit:34,23--32: Error: the protected property `vproB=` cannot contain the private type `B`.
+alt/base_prot_sig_alt4.nit:42,23--32: Error: the protected property `vproB` cannot contain the private type `B`.
+alt/base_prot_sig_alt4.nit:42,23--32: Error: the protected property `vproB=` cannot contain the private type `B`.
-alt/base_prot_sig_alt5.nit:37,6--11: Error: the public property `vpubB2` cannot contain the private type `B`.
-alt/base_prot_sig_alt5.nit:37,6--11: Error: the public property `vpubB2=` cannot contain the private type `B`.
+alt/base_prot_sig_alt5.nit:45,6--11: Error: the public property `vpubB2` cannot contain the private type `B`.
+alt/base_prot_sig_alt5.nit:45,6--11: Error: the public property `vpubB2=` cannot contain the private type `B`.
-alt/base_prot_sig_alt6.nit:38,16--21: Error: the protected property `vproB2` cannot contain the private type `B`.
-alt/base_prot_sig_alt6.nit:38,16--21: Error: the protected property `vproB2=` cannot contain the private type `B`.
+alt/base_prot_sig_alt6.nit:46,16--21: Error: the protected property `vproB2` cannot contain the private type `B`.
+alt/base_prot_sig_alt6.nit:46,16--21: Error: the protected property `vproB2=` cannot contain the private type `B`.
-alt/base_prot_sig_alt7.nit:46,2--10: Error: `private` is the only legal visibility for properties in a private class.
-alt/base_prot_sig_alt7.nit:50,2--10: Error: `private` is the only legal visibility for properties in a private class.
-alt/base_prot_sig_alt7.nit:50,37--45: Error: `private` is the only legal visibility for properties in a private class.
alt/base_prot_sig_alt7.nit:54,2--10: Error: `private` is the only legal visibility for properties in a private class.
-alt/base_prot_sig_alt7.nit:54,34--42: Error: `private` is the only legal visibility for properties in a private class.
alt/base_prot_sig_alt7.nit:58,2--10: Error: `private` is the only legal visibility for properties in a private class.
+alt/base_prot_sig_alt7.nit:58,37--45: Error: `private` is the only legal visibility for properties in a private class.
alt/base_prot_sig_alt7.nit:62,2--10: Error: `private` is the only legal visibility for properties in a private class.
-alt/base_prot_sig_alt7.nit:62,37--45: Error: `private` is the only legal visibility for properties in a private class.
+alt/base_prot_sig_alt7.nit:62,34--42: Error: `private` is the only legal visibility for properties in a private class.
alt/base_prot_sig_alt7.nit:66,2--10: Error: `private` is the only legal visibility for properties in a private class.
-alt/base_prot_sig_alt7.nit:66,34--42: Error: `private` is the only legal visibility for properties in a private class.
+alt/base_prot_sig_alt7.nit:70,2--10: Error: `private` is the only legal visibility for properties in a private class.
+alt/base_prot_sig_alt7.nit:70,37--45: Error: `private` is the only legal visibility for properties in a private class.
+alt/base_prot_sig_alt7.nit:74,2--10: Error: `private` is the only legal visibility for properties in a private class.
+alt/base_prot_sig_alt7.nit:74,34--42: Error: `private` is the only legal visibility for properties in a private class.
Object -> Task [dir=back arrowtail=open style=dashed];
A [
- label = "{A|- _vpubA: nullable A\l- _vproA: nullable A\l- _vpriA: nullable A\l- _vpubA2: A\l- _vproA2: A\l- _vpriA2: A\l- _vpriB: nullable B\l- _vpriB2: B\l|+ pubA(a: A)\l# proA(a: A)\l- priA(a: A)\l+ vpubA(): nullable A\l+ vpubA=(vpubA: nullable A)\l# vproA(): nullable A\l# vproA=(vproA: nullable A)\l- vpriA(): nullable A\l- vpriA=(vpriA: nullable A)\l+ vpubA2(): A\l+ vpubA2=(vpubA2: A)\l# vproA2(): A\l# vproA2=(vproA2: A)\l- vpriA2(): A\l- vpriA2=(vpriA2: A)\l- priB(a: B)\l- vpriB(): nullable B\l- vpriB=(vpriB: nullable B)\l- vpriB2(): B\l- vpriB2=(vpriB2: B)\l}"
+ label = "{A|- _vpubA: nullable A\l- _vproA: nullable A\l- _vpriA: nullable A\l- _vpubA2: A\l- _vproA2: A\l- _vpriA2: A\l- _vpriB: nullable B\l- _vpriB2: B\l|+ pubA(a: A)\l# proA(a: A)\l- priA(a: A)\l+ pubA2(): A\l# proA2(): A\l- priA2(): A\l+ vpubA(): nullable A\l+ vpubA=(vpubA: nullable A)\l# vproA(): nullable A\l# vproA=(vproA: nullable A)\l- vpriA(): nullable A\l- vpriA=(vpriA: nullable A)\l+ vpubA2(): A\l+ vpubA2=(vpubA2: A)\l# vproA2(): A\l# vproA2=(vproA2: A)\l- vpriA2(): A\l- vpriA2=(vpriA2: A)\l- priB(a: B)\l- priB2(): B\l- vpriB(): nullable B\l- vpriB=(vpriB: nullable B)\l- vpriB2(): B\l- vpriB2=(vpriB2: B)\l}"
]
Object -> A [dir=back arrowtail=open style=dashed];
Object -> Task [dir=back arrowtail=open style=dashed];
A [
- label = "{A||+ pubA(a: A)\l+ vpubA(): nullable A\l+ vpubA=(vpubA: nullable A)\l+ vpubA2(): A\l+ vpubA2=(vpubA2: A)\l}"
+ label = "{A||+ pubA(a: A)\l+ pubA2(): A\l+ vpubA(): nullable A\l+ vpubA=(vpubA: nullable A)\l+ vpubA2(): A\l+ vpubA2=(vpubA2: A)\l}"
]
Object -> A [dir=back arrowtail=open style=dashed];