{"action":"created","comment":{"url":"https://api.github.com/repos/privat/nit/pulls/comments/36591001","id":36591001,"diff_hunk":"@@ -0,0 +1,976 @@\n+# This file is part of NIT ( http://www.nitlanguage.org ).\n+#\n+# This file is free software, which comes along with NIT.  This software is\n+# distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;\n+# without  even  the implied warranty of  MERCHANTABILITY or  FITNESS FOR A\n+# PARTICULAR PURPOSE.  You can modify it is you want,  provided this header\n+# is kept unaltered, and a notification of the changes is added.\n+# You  are  allowed  to  redistribute it and sell it, alone or is a part of\n+# another product.\n+\n+# Basic integers of fixed-precision\n+#\n+# All classes defined here have C-equivalents and the semantics of their\n+# operations are the same as C's\n+#\n+# * Int8 => int8_t\n+# * Int16 => int16_t\n+# * UInt16 => uint16_t\n+# * Int32 => int32_t\n+# * UInt32 => uint32_t\n+#\n+# NOTE: No UInt8 is provided as Byte is the same\n+# SEE: kernel::Byte\n+#\n+# HOW TO USE:\n+# All classes can be instanciated via a literal rule.\n+# Namely, a suffix to append after the literal integer.\n+#\n+# * Int8 => i8\n+# * Byte => u8\n+# * Int16 => i16\n+# * UInt16 => u16\n+# * Int32 => i32\n+# * UInt32 => u32\n+module fixints\n+\n+import text\n+\n+redef class Numeric\n+\n+\t# The Int8 equivalent of `self`\n+\t#\n+\t#     assert (-1).to_i8 == 0xFFFFi8\n+\t#     assert (1.9).to_i8 == 1i8\n+\tfun to_i8: Int8 do return self.to_i.to_i8\n+\n+\t# The Int16 equivalent of `self`\n+\t#\n+\t#     assert (-1).to_i16 == 0xFFFFi16\n+\t#     assert (1.9).to_i16 == 1i16\n+\tfun to_i16: Int16 do return self.to_i.to_i16\n+\n+\t# The UInt16 equivalent of `self`\n+\t#\n+\t#     assert (-1).to_u16 == 0xFFFFu16\n+\t#     assert (1.9).to_u16 == 1u16\n+\tfun to_u16: UInt16 do return self.to_i.to_u16\n+\n+\t# The Int32 equivalent of `self`\n+\t#\n+\t#     assert (-1).to_i32 == 0xFFFFFFFFi32\n+\t#     assert (1.9).to_i32 == 1i32\n+\tfun to_i32: Int32 do return self.to_i.to_i32\n+\n+\t# The UInt32 equivalent of `self`\n+\t#\n+\t#     assert (-1).to_u32 == 0xFFFFFFFFu32\n+\t#     assert (1.9).to_u32 == 1u32\n+\tfun to_u32: UInt32 do return self.to_i.to_u32\n+\n+end\n+\n+redef class Float\n+\tredef fun to_i8 is intern\n+\tredef fun to_i16 is intern\n+\tredef fun to_u16 is intern\n+\tredef fun to_i32 is intern\n+\tredef fun to_u32 is intern\n+end\n+\n+redef class Byte\n+\tredef fun to_i8 is intern\n+\tredef fun to_i16 is intern\n+\tredef fun to_u16 is intern\n+\tredef fun to_i32 is intern\n+\tredef fun to_u32 is intern\n+end\n+\n+redef class Int\n+\tredef fun to_i8 is intern\n+\tredef fun to_i16 is intern\n+\tredef fun to_u16 is intern\n+\tredef fun to_i32 is intern\n+\tredef fun to_u32 is intern\n+end\n+\n+# Native 8-bit signed integer.\n+# Same as a C `int8_t`\n+universal Int8\n+\tsuper Discrete\n+\tsuper Numeric\n+\n+\tredef type OTHER: Int8\n+\n+\tredef fun successor(i) do return self + i.to_i8\n+\tredef fun predecessor(i) do return self - i.to_i8\n+\n+\tredef fun object_id is intern\n+\tredef fun hash do return self.to_i\n+\tredef fun ==(i) is intern\n+\tredef fun !=(i) is intern\n+\tredef fun output is intern\n+\n+\tredef fun <=(i) is intern\n+\tredef fun <(i) is intern\n+\tredef fun >=(i) is intern\n+\tredef fun >(i) is intern\n+\tredef fun +(i) is intern\n+\n+\t#     assert -1i8 == 0xFFi8\n+\t#     assert -0i8 == 0x00i8\n+\tredef fun - is intern\n+\tredef fun -(i) is intern\n+\tredef fun *(i) is intern\n+\tredef fun /(i) is intern\n+\n+\t# Modulo of `self` with `i`.\n+\t#\n+\t# Finds the remainder of division of `self` by `i`.\n+\t#\n+\t#     assert 5i8 % 2i8\t\t== 1i8\n+\t#     assert 10i8 % 2i8\t\t== 0i8\n+\tfun %(i: Int8): Int8 is intern\n+\n+\tredef fun zero do return 0.to_i8\n+\tredef fun value_of(val) do return val.to_i8\n+\n+\t# `i` bits shift fo the left\n+\t#\n+\t#     assert 5i8 << 1    == 10i8\n+\tfun <<(i: Int): Int8 is intern\n+\n+\t# `i` bits shift fo the right","path":"lib/standard/fixints.nit","position":143,"original_position":143,"commit_id":"1ea011a1f56b7d8f25d51c65b3469bea3fbf0414","original_commit_id":"1ea011a1f56b7d8f25d51c65b3469bea3fbf0414","user":{"login":"Morriar","id":583144,"avatar_url":"https://avatars.githubusercontent.com/u/583144?v=3","gravatar_id":"","url":"https://api.github.com/users/Morriar","html_url":"https://github.com/Morriar","followers_url":"https://api.github.com/users/Morriar/followers","following_url":"https://api.github.com/users/Morriar/following{/other_user}","gists_url":"https://api.github.com/users/Morriar/gists{/gist_id}","starred_url":"https://api.github.com/users/Morriar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Morriar/subscriptions","organizations_url":"https://api.github.com/users/Morriar/orgs","repos_url":"https://api.github.com/users/Morriar/repos","events_url":"https://api.github.com/users/Morriar/events{/privacy}","received_events_url":"https://api.github.com/users/Morriar/received_events","type":"User","site_admin":false},"body":"to*","created_at":"2015-08-09T17:31:11Z","updated_at":"2015-08-09T17:31:11Z","html_url":"https://github.com/privat/nit/pull/1588#discussion_r36591001","pull_request_url":"https://api.github.com/repos/privat/nit/pulls/1588","_links":{"self":{"href":"https://api.github.com/repos/privat/nit/pulls/comments/36591001"},"html":{"href":"https://github.com/privat/nit/pull/1588#discussion_r36591001"},"pull_request":{"href":"https://api.github.com/repos/privat/nit/pulls/1588"}}},"pull_request":{"url":"https://api.github.com/repos/privat/nit/pulls/1588","id":40784293,"html_url":"https://github.com/privat/nit/pull/1588","diff_url":"https://github.com/privat/nit/pull/1588.diff","patch_url":"https://github.com/privat/nit/pull/1588.patch","issue_url":"https://api.github.com/repos/privat/nit/issues/1588","number":1588,"state":"open","locked":false,"title":"Fixints","user":{"login":"R4PaSs","id":1444825,"avatar_url":"https://avatars.githubusercontent.com/u/1444825?v=3","gravatar_id":"","url":"https://api.github.com/users/R4PaSs","html_url":"https://github.com/R4PaSs","followers_url":"https://api.github.com/users/R4PaSs/followers","following_url":"https://api.github.com/users/R4PaSs/following{/other_user}","gists_url":"https://api.github.com/users/R4PaSs/gists{/gist_id}","starred_url":"https://api.github.com/users/R4PaSs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/R4PaSs/subscriptions","organizations_url":"https://api.github.com/users/R4PaSs/orgs","repos_url":"https://api.github.com/users/R4PaSs/repos","events_url":"https://api.github.com/users/R4PaSs/events{/privacy}","received_events_url":"https://api.github.com/users/R4PaSs/received_events","type":"User","site_admin":false},"body":"As promised, a check off the TODO list for #1266 and for low-level users: fixed-size Integers.\r\n\r\nThis is still a proof of concept more than anything else, and comments are welcome for this PR.\r\n\r\nA literal rule has been added for these types, namely:\r\n\r\n* i8: Signed Integer 8 bits\r\n* i16: Signed Integer 16 bits\r\n* i32: Signed Integer 32 bits\r\n* u16: Unsigned Integer 16 bits\r\n* u32: Unsigned Integer 32 bits\r\n\r\nNote that an Unsigned Integer 8 bits is missing because of Bytes, which gets to keep its `u8` suffix until we decide of something","created_at":"2015-07-24T15:07:10Z","updated_at":"2015-08-09T17:31:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ba03196cbd03b668192b8f18bc7bae609cda9ba8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/privat/nit/pulls/1588/commits","review_comments_url":"https://api.github.com/repos/privat/nit/pulls/1588/comments","review_comment_url":"https://api.github.com/repos/privat/nit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/privat/nit/issues/1588/comments","statuses_url":"https://api.github.com/repos/privat/nit/statuses/1ea011a1f56b7d8f25d51c65b3469bea3fbf0414","head":{"label":"R4PaSs:int_arbitrary","ref":"int_arbitrary","sha":"1ea011a1f56b7d8f25d51c65b3469bea3fbf0414","user":{"login":"R4PaSs","id":1444825,"avatar_url":"https://avatars.githubusercontent.com/u/1444825?v=3","gravatar_id":"","url":"https://api.github.com/users/R4PaSs","html_url":"https://github.com/R4PaSs","followers_url":"https://api.github.com/users/R4PaSs/followers","following_url":"https://api.github.com/users/R4PaSs/following{/other_user}","gists_url":"https://api.github.com/users/R4PaSs/gists{/gist_id}","starred_url":"https://api.github.com/users/R4PaSs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/R4PaSs/subscriptions","organizations_url":"https://api.github.com/users/R4PaSs/orgs","repos_url":"https://api.github.com/users/R4PaSs/repos","events_url":"https://api.github.com/users/R4PaSs/events{/privacy}","received_events_url":"https://api.github.com/users/R4PaSs/received_events","type":"User","site_admin":false},"repo":{"id":4930337,"name":"nit","full_name":"R4PaSs/nit","owner":{"login":"R4PaSs","id":1444825,"avatar_url":"https://avatars.githubusercontent.com/u/1444825?v=3","gravatar_id":"","url":"https://api.github.com/users/R4PaSs","html_url":"https://github.com/R4PaSs","followers_url":"https://api.github.com/users/R4PaSs/followers","following_url":"https://api.github.com/users/R4PaSs/following{/other_user}","gists_url":"https://api.github.com/users/R4PaSs/gists{/gist_id}","starred_url":"https://api.github.com/users/R4PaSs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/R4PaSs/subscriptions","organizations_url":"https://api.github.com/users/R4PaSs/orgs","repos_url":"https://api.github.com/users/R4PaSs/repos","events_url":"https://api.github.com/users/R4PaSs/events{/privacy}","received_events_url":"https://api.github.com/users/R4PaSs/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/R4PaSs/nit","description":"Nit language","fork":true,"url":"https://api.github.com/repos/R4PaSs/nit","forks_url":"https://api.github.com/repos/R4PaSs/nit/forks","keys_url":"https://api.github.com/repos/R4PaSs/nit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/R4PaSs/nit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/R4PaSs/nit/teams","hooks_url":"https://api.github.com/repos/R4PaSs/nit/hooks","issue_events_url":"https://api.github.com/repos/R4PaSs/nit/issues/events{/number}","events_url":"https://api.github.com/repos/R4PaSs/nit/events","assignees_url":"https://api.github.com/repos/R4PaSs/nit/assignees{/user}","branches_url":"https://api.github.com/repos/R4PaSs/nit/branches{/branch}","tags_url":"https://api.github.com/repos/R4PaSs/nit/tags","blobs_url":"https://api.github.com/repos/R4PaSs/nit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/R4PaSs/nit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/R4PaSs/nit/git/refs{/sha}","trees_url":"https://api.github.com/repos/R4PaSs/nit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/R4PaSs/nit/statuses/{sha}","languages_url":"https://api.github.com/repos/R4PaSs/nit/languages","stargazers_url":"https://api.github.com/repos/R4PaSs/nit/stargazers","contributors_url":"https://api.github.com/repos/R4PaSs/nit/contributors","subscribers_url":"https://api.github.com/repos/R4PaSs/nit/subscribers","subscription_url":"https://api.github.com/repos/R4PaSs/nit/subscription","commits_url":"https://api.github.com/repos/R4PaSs/nit/commits{/sha}","git_commits_url":"https://api.github.com/repos/R4PaSs/nit/git/commits{/sha}","comments_url":"https://api.github.com/repos/R4PaSs/nit/comments{/number}","issue_comment_url":"https://api.github.com/repos/R4PaSs/nit/issues/comments{/number}","contents_url":"https://api.github.com/repos/R4PaSs/nit/contents/{+path}","compare_url":"https://api.github.com/repos/R4PaSs/nit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/R4PaSs/nit/merges","archive_url":"https://api.github.com/repos/R4PaSs/nit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/R4PaSs/nit/downloads","issues_url":"https://api.github.com/repos/R4PaSs/nit/issues{/number}","pulls_url":"https://api.github.com/repos/R4PaSs/nit/pulls{/number}","milestones_url":"https://api.github.com/repos/R4PaSs/nit/milestones{/number}","notifications_url":"https://api.github.com/repos/R4PaSs/nit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/R4PaSs/nit/labels{/name}","releases_url":"https://api.github.com/repos/R4PaSs/nit/releases{/id}","created_at":"2012-07-06T19:56:01Z","updated_at":"2014-12-09T16:44:12Z","pushed_at":"2015-08-07T22:08:49Z","git_url":"git://github.com/R4PaSs/nit.git","ssh_url":"git@github.com:R4PaSs/nit.git","clone_url":"https://github.com/R4PaSs/nit.git","svn_url":"https://github.com/R4PaSs/nit","homepage":"http://nitlanguage.org","size":68760,"stargazers_count":2,"watchers_count":2,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"privat:master","ref":"master","sha":"02961c0f4bb953908ca7bab9d21cfcb4da83c402","user":{"login":"privat","id":135828,"avatar_url":"https://avatars.githubusercontent.com/u/135828?v=3","gravatar_id":"","url":"https://api.github.com/users/privat","html_url":"https://github.com/privat","followers_url":"https://api.github.com/users/privat/followers","following_url":"https://api.github.com/users/privat/following{/other_user}","gists_url":"https://api.github.com/users/privat/gists{/gist_id}","starred_url":"https://api.github.com/users/privat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/privat/subscriptions","organizations_url":"https://api.github.com/users/privat/orgs","repos_url":"https://api.github.com/users/privat/repos","events_url":"https://api.github.com/users/privat/events{/privacy}","received_events_url":"https://api.github.com/users/privat/received_events","type":"User","site_admin":false},"repo":{"id":328597,"name":"nit","full_name":"privat/nit","owner":{"login":"privat","id":135828,"avatar_url":"https://avatars.githubusercontent.com/u/135828?v=3","gravatar_id":"","url":"https://api.github.com/users/privat","html_url":"https://github.com/privat","followers_url":"https://api.github.com/users/privat/followers","following_url":"https://api.github.com/users/privat/following{/other_user}","gists_url":"https://api.github.com/users/privat/gists{/gist_id}","starred_url":"https://api.github.com/users/privat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/privat/subscriptions","organizations_url":"https://api.github.com/users/privat/orgs","repos_url":"https://api.github.com/users/privat/repos","events_url":"https://api.github.com/users/privat/events{/privacy}","received_events_url":"https://api.github.com/users/privat/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/privat/nit","description":"Nit language","fork":false,"url":"https://api.github.com/repos/privat/nit","forks_url":"https://api.github.com/repos/privat/nit/forks","keys_url":"https://api.github.com/repos/privat/nit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/privat/nit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/privat/nit/teams","hooks_url":"https://api.github.com/repos/privat/nit/hooks","issue_events_url":"https://api.github.com/repos/privat/nit/issues/events{/number}","events_url":"https://api.github.com/repos/privat/nit/events","assignees_url":"https://api.github.com/repos/privat/nit/assignees{/user}","branches_url":"https://api.github.com/repos/privat/nit/branches{/branch}","tags_url":"https://api.github.com/repos/privat/nit/tags","blobs_url":"https://api.github.com/repos/privat/nit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/privat/nit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/privat/nit/git/refs{/sha}","trees_url":"https://api.github.com/repos/privat/nit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/privat/nit/statuses/{sha}","languages_url":"https://api.github.com/repos/privat/nit/languages","stargazers_url":"https://api.github.com/repos/privat/nit/stargazers","contributors_url":"https://api.github.com/repos/privat/nit/contributors","subscribers_url":"https://api.github.com/repos/privat/nit/subscribers","subscription_url":"https://api.github.com/repos/privat/nit/subscription","commits_url":"https://api.github.com/repos/privat/nit/commits{/sha}","git_commits_url":"https://api.github.com/repos/privat/nit/git/commits{/sha}","comments_url":"https://api.github.com/repos/privat/nit/comments{/number}","issue_comment_url":"https://api.github.com/repos/privat/nit/issues/comments{/number}","contents_url":"https://api.github.com/repos/privat/nit/contents/{+path}","compare_url":"https://api.github.com/repos/privat/nit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/privat/nit/merges","archive_url":"https://api.github.com/repos/privat/nit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/privat/nit/downloads","issues_url":"https://api.github.com/repos/privat/nit/issues{/number}","pulls_url":"https://api.github.com/repos/privat/nit/pulls{/number}","milestones_url":"https://api.github.com/repos/privat/nit/milestones{/number}","notifications_url":"https://api.github.com/repos/privat/nit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/privat/nit/labels{/name}","releases_url":"https://api.github.com/repos/privat/nit/releases{/id}","created_at":"2009-10-06T15:03:00Z","updated_at":"2015-07-30T17:24:29Z","pushed_at":"2015-08-08T01:01:59Z","git_url":"git://github.com/privat/nit.git","ssh_url":"git@github.com:privat/nit.git","clone_url":"https://github.com/privat/nit.git","svn_url":"https://github.com/privat/nit","homepage":"http://nitlanguage.org","size":93538,"stargazers_count":76,"watchers_count":76,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":44,"mirror_url":null,"open_issues_count":125,"forks":44,"open_issues":125,"watchers":76,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/privat/nit/pulls/1588"},"html":{"href":"https://github.com/privat/nit/pull/1588"},"issue":{"href":"https://api.github.com/repos/privat/nit/issues/1588"},"comments":{"href":"https://api.github.com/repos/privat/nit/issues/1588/comments"},"review_comments":{"href":"https://api.github.com/repos/privat/nit/pulls/1588/comments"},"review_comment":{"href":"https://api.github.com/repos/privat/nit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/privat/nit/pulls/1588/commits"},"statuses":{"href":"https://api.github.com/repos/privat/nit/statuses/1ea011a1f56b7d8f25d51c65b3469bea3fbf0414"}}}}