Merge: Annotation lateinit
authorJean Privat <jean@pryen.org>
Fri, 29 May 2015 01:38:43 +0000 (21:38 -0400)
committerJean Privat <jean@pryen.org>
Fri, 29 May 2015 01:38:43 +0000 (21:38 -0400)
#857 introduced `autoinit` on attributes that has a default value to initialize them latter.

This is a rarely used feature. It is also not POLA because it overloads the name `autoinit` that has a different meaning on methods cf #1308.

Thus in order to polaize the spec, the annotation is renamed `lateinit`. So close #1308.
Note: maybe the annotation will just be removed in a future PR, this one is a last attempt to keep it.

Related to #1322; required by #1311

Pull-Request: #1409
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>

172 files changed:
contrib/jwrapper/src/code_generator.nit
contrib/nitcc/examples/minilang.nit
contrib/objcwrapper/header_static/makefile [new file with mode: 0644]
contrib/objcwrapper/header_static/src/header_static.nit [new file with mode: 0644]
contrib/sort_downloads/src/sort_downloads.nit
contrib/wiringPi/lib/wiringPi.nit
examples/callback_chimpanze.nit
examples/callback_monkey.nit
examples/draw_operation.nit
examples/extern_methods.nit
examples/mnit_simple/src/simple_android.nit
lib/android/activities.nit
lib/android/assets_and_resources.nit
lib/android/audio.nit
lib/android/bundle/bundle.nit
lib/android/cardboard.nit
lib/android/dalvik.nit
lib/android/input_events.nit
lib/android/intent/intent_api10.nit
lib/android/intent/intent_api15.nit
lib/android/intent/intent_api16.nit
lib/android/native_app_glue.nit
lib/android/nit_activity.nit
lib/android/notification/native_notification.nit
lib/android/sensors.nit
lib/android/shared_preferences/shared_preferences_api10.nit
lib/android/shared_preferences/shared_preferences_api11.nit
lib/android/toast.nit
lib/android/ui/native_ui.nit
lib/android/vibration.nit
lib/bcm2835/bcm2835.nit
lib/binary/binary.nit
lib/c.nit
lib/cocoa/app_kit.nit
lib/cocoa/foundation.nit
lib/cpp.nit
lib/curl/curl.nit
lib/curl/curl_c.nit
lib/curl/examples/curl_http.nit
lib/curses/curses.nit
lib/egl.nit
lib/geometry/boxes.nit
lib/geometry/points_and_lines.nit
lib/geometry/quadtree.nit
lib/gettext.nit
lib/glesv2/examples/opengles2_hello_triangle.nit
lib/glesv2/glesv2.nit
lib/gtk/v3_4/gtk_assistant.nit
lib/gtk/v3_4/gtk_core.nit
lib/gtk/v3_4/gtk_dialogs.nit
lib/gtk/v3_4/gtk_widgets_ext.nit
lib/gtk/v3_6.nit
lib/gtk/v3_8.nit
lib/ios/app.nit
lib/ios/examples/hello_ios.nit
lib/java/collections.nit
lib/java/io.nit
lib/java/java.nit
lib/json/dynamic.nit
lib/json/serialization.nit
lib/jvm.nit
lib/libevent.nit
lib/markdown/markdown.nit
lib/markdown/test_markdown.nit
lib/markdown/wikilinks.nit
lib/md5.nit
lib/mnit/opengles1.nit
lib/mnit_android/android_assets.nit
lib/mnit_android/android_opengles1.nit
lib/mongodb/native_mongodb.nit
lib/mpi.nit
lib/neo4j/graph/graph.nit
lib/neo4j/graph/json_graph_store.nit
lib/neo4j/graph/sequential_id.nit
lib/nitcorn/http_response.nit
lib/pnacl.nit
lib/posix_ext.nit
lib/pthreads/extra.nit
lib/pthreads/pthreads.nit
lib/realtime.nit
lib/sax/helpers/attributes_impl.nit
lib/sax/helpers/sax_locator_impl.nit
lib/sax/helpers/xml_filter_impl.nit
lib/saxophonit/saxophonit.nit
lib/saxophonit/testing.nit
lib/sdl.nit
lib/sdl2/events.nit
lib/sdl2/image.nit
lib/sdl2/sdl2_base.nit
lib/sdl2/syswm.nit
lib/serialization/caching.nit [new file with mode: 0644]
lib/serialization/engine_tools.nit
lib/serialization/serialization.nit
lib/sha1.nit
lib/signals.nit
lib/socket/socket.nit
lib/socket/socket_c.nit
lib/sqlite3/native_sqlite3.nit
lib/sqlite3/sqlite3.nit
lib/standard/bitset.nit
lib/standard/bytes.nit
lib/standard/collection/abstract_collection.nit
lib/standard/collection/array.nit
lib/standard/collection/range.nit
lib/standard/collection/union_find.nit
lib/standard/file.nit
lib/standard/kernel.nit
lib/standard/math.nit
lib/standard/posix.nit
lib/standard/re.nit
lib/standard/ropes.nit
lib/standard/string.nit
lib/standard/time.nit
lib/string_experimentations/utf8.nit
lib/string_experimentations/utf8_noindex.nit
lib/template/template.nit
lib/xdg_basedir/xdg_basedir.nit
src/compiler/compiler_ffi/compiler_ffi.nit
src/doc/doc_base.nit
src/doc/doc_phases/doc_concerns.nit
src/doc/doc_phases/doc_console.nit
src/doc/doc_phases/doc_extract.nit
src/doc/doc_phases/doc_graphs.nit
src/doc/doc_phases/doc_hierarchies.nit
src/doc/doc_phases/doc_html.nit
src/doc/doc_phases/doc_intros_redefs.nit
src/doc/doc_phases/doc_lin.nit
src/doc/doc_phases/doc_pages.nit
src/doc/doc_phases/doc_poset.nit
src/doc/doc_phases/doc_structure.nit
src/doc/html_templates/html_model.nit
src/ffi/cpp.nit
src/ffi/java.nit
src/modelize/modelize_property.nit
src/nitni/nitni_utilities.nit
src/nitpick.nit
src/vm/virtual_machine.nit
src/vm/vm_optimizations.nit
tests/base_init_autoinit3.nit
tests/nitpick.args [new file with mode: 0644]
tests/sav/base_init_autoinit3_alt9.res [new file with mode: 0644]
tests/sav/nitpick_args1.res [new file with mode: 0644]
tests/sav/nitpretty_args21.res
tests/sav/nitpretty_args52.res
tests/sav/nitserial_args1.res
tests/sav/test_new_native_alt1.res
tests/sav/utf_noindex_test.res [deleted file]
tests/string_ffi_ref_test.nit
tests/test_advice_repeated_types.nit [new file with mode: 0644]
tests/test_curl.nit
tests/test_ffi_c_accessor.nit
tests/test_ffi_c_callback_extern_receiver.nit
tests/test_ffi_c_callbacks.nit
tests/test_ffi_c_fibonacci.nit
tests/test_ffi_c_lots_of_refs.nit
tests/test_ffi_c_more.nit
tests/test_ffi_c_more_callbacks.nit
tests/test_ffi_c_new.nit
tests/test_ffi_c_new_extern.nit
tests/test_ffi_c_operators.nit
tests/test_ffi_c_super.nit
tests/test_ffi_c_types.nit
tests/test_ffi_cpp_callbacks.nit
tests/test_ffi_cpp_strings.nit
tests/test_ffi_cpp_types.nit
tests/test_ffi_java_callbacks.nit
tests/test_ffi_java_generics.nit
tests/test_ffi_java_string.nit
tests/test_ffi_java_types.nit
tests/test_ffi_objc_types_and_callbacks.nit
tests/test_pretty/test_extern1.nit
tests/utf_noindex_test.nit [deleted file]

index f0be48c..ee0942f 100644 (file)
@@ -223,16 +223,16 @@ class CodeGenerator
 
                # FIXME : This huge `if` block is only necessary to copy primitive arrays as long as there's no better way to do it
                if comment == "#" then
-                       temp.add(" in \"Java\" `\{\n{comment}\t\trecv.{jmethod_id}({java_params});\n{comment}\t`\}\n")
+                       temp.add(" in \"Java\" `\{\n{comment}\t\tself.{jmethod_id}({java_params});\n{comment}\t`\}\n")
                # Methods with return type
                else if return_type != null then
-                       temp.add(" in \"Java\" `\{\n{comment}\t\treturn {jreturn_type.return_cast}recv.{jmethod_id}({java_params});\n{comment}\t`\}\n")
+                       temp.add(" in \"Java\" `\{\n{comment}\t\treturn {jreturn_type.return_cast}self.{jmethod_id}({java_params});\n{comment}\t`\}\n")
                # Methods without return type
                else if jreturn_type.is_void then
-                       temp.add(" in \"Java\" `\{\n{comment}\t\trecv.{jmethod_id}({java_params});\n{comment}\t`\}\n")
+                       temp.add(" in \"Java\" `\{\n{comment}\t\tself.{jmethod_id}({java_params});\n{comment}\t`\}\n")
                # No copy
                else
-                       temp.add(" in \"Java\" `\{\n{comment}\t\trecv.{jmethod_id}({java_params});\n{comment}\t`\}\n")
+                       temp.add(" in \"Java\" `\{\n{comment}\t\tself.{jmethod_id}({java_params});\n{comment}\t`\}\n")
                end
 
                return temp.join("")
index e316369..29ea62e 100644 (file)
@@ -13,45 +13,45 @@ class Interpretor
        # The current values assigned to each variable
        var vars = new HashMap[String, Int]
 
-       redef fun visit(n) do n.accept_calculator(self)
+       redef fun visit(n) do n.accept_minilang(self)
 end
 
 redef class Node
        # Execution of the node by the interpreter `v`
-       fun accept_calculator(v: Interpretor) do visit_children(v)
+       fun accept_minilang(v: Interpretor) do visit_children(v)
 end
 
 redef class Nint
-       redef fun accept_calculator(v) do v.stack.push(text.to_i)
+       redef fun accept_minilang(v) do v.stack.push(text.to_i)
 end
 
 redef class Ns_assign
-       redef fun accept_calculator(v) do
+       redef fun accept_minilang(v) do
                super
                v.vars[n_id.text] = v.stack.pop
        end
 end
 
 redef class Ns_print
-       redef fun accept_calculator(v) do
+       redef fun accept_minilang(v) do
                super
                printn v.stack.pop
        end
 end
 redef class Ns_print_str
-       redef fun accept_calculator(v) do
+       redef fun accept_minilang(v) do
                var text = n_str.text
                text = text.substring(1, text.length-2)
                printn text
        end
 end
 redef class Ns_println
-       redef fun accept_calculator(v) do
+       redef fun accept_minilang(v) do
                print ""
        end
 end
 redef class Ns_if
-       redef fun accept_calculator(v) do
+       redef fun accept_minilang(v) do
                v.enter_visit(n_c)
                if v.bstack.pop then
                        v.enter_visit(n_then)
@@ -62,7 +62,7 @@ redef class Ns_if
        end
 end
 redef class Ns_while
-       redef fun accept_calculator(v) do
+       redef fun accept_minilang(v) do
                loop
                        v.enter_visit(n_c)
                        if not v.bstack.pop then break
@@ -73,7 +73,7 @@ end
 
 
 redef class Nc_and
-       redef fun accept_calculator(v) do
+       redef fun accept_minilang(v) do
                super
                var b1 = v.bstack.pop
                var b2 = v.bstack.pop
@@ -82,7 +82,7 @@ redef class Nc_and
 end
 
 redef class Nc_or
-       redef fun accept_calculator(v) do
+       redef fun accept_minilang(v) do
                super
                var b1 = v.bstack.pop
                var b2 = v.bstack.pop
@@ -91,93 +91,93 @@ redef class Nc_or
 end
 
 redef class Nc_not
-       redef fun accept_calculator(v) do
+       redef fun accept_minilang(v) do
                super
                v.bstack.push(not v.bstack.pop)
        end
 end
 
 redef class Nc_eq
-       redef fun accept_calculator(v) do
+       redef fun accept_minilang(v) do
                super
                v.bstack.push(v.stack.pop == v.stack.pop)
        end
 end
 
 redef class Nc_ne
-       redef fun accept_calculator(v) do
+       redef fun accept_minilang(v) do
                super
                v.bstack.push(v.stack.pop != v.stack.pop)
        end
 end
 
 redef class Nc_lt
-       redef fun accept_calculator(v) do
+       redef fun accept_minilang(v) do
                super
                v.bstack.push(v.stack.pop > v.stack.pop)
        end
 end
 
 redef class Nc_le
-       redef fun accept_calculator(v) do
+       redef fun accept_minilang(v) do
                super
                v.bstack.push(v.stack.pop >= v.stack.pop)
        end
 end
 
 redef class Nc_gt
-       redef fun accept_calculator(v) do
+       redef fun accept_minilang(v) do
                super
                v.bstack.push(v.stack.pop < v.stack.pop)
        end
 end
 
 redef class Nc_ge
-       redef fun accept_calculator(v) do
+       redef fun accept_minilang(v) do
                super
                v.bstack.push(v.stack.pop <= v.stack.pop)
        end
 end
 
 redef class Ne_add
-       redef fun accept_calculator(v) do
+       redef fun accept_minilang(v) do
                super
                v.stack.push(v.stack.pop+v.stack.pop)
        end
 end
 redef class Ne_sub
-       redef fun accept_calculator(v) do
+       redef fun accept_minilang(v) do
                super
                var n1 = v.stack.pop
                v.stack.push(v.stack.pop-n1)
        end
 end
 redef class Ne_neg
-       redef fun accept_calculator(v) do
+       redef fun accept_minilang(v) do
                super
                v.stack.push(-v.stack.pop)
        end
 end
 redef class Ne_mul
-       redef fun accept_calculator(v) do
+       redef fun accept_minilang(v) do
                super
                v.stack.push(v.stack.pop*v.stack.pop)
        end
 end
 redef class Ne_div
-       redef fun accept_calculator(v) do
+       redef fun accept_minilang(v) do
                super
                var n1 = v.stack.pop
                v.stack.push(v.stack.pop/n1)
        end
 end
 redef class Ne_var
-       redef fun accept_calculator(v) do
+       redef fun accept_minilang(v) do
                v.stack.push v.vars[n_id.text]
        end
 end
 redef class Ne_read
-       redef fun accept_calculator(v) do
+       redef fun accept_minilang(v) do
                var t = gets
                v.stack.push(t.to_i)
        end
diff --git a/contrib/objcwrapper/header_static/makefile b/contrib/objcwrapper/header_static/makefile
new file mode 100644 (file)
index 0000000..e4d3e19
--- /dev/null
@@ -0,0 +1,7 @@
+bin/header_static:
+       mkdir -p bin
+       ../../../bin/nitc --dir bin src/header_static.nit
+
+tests: bin/header_static
+       cat CGGeometry.h | bin/header_static > static_CGGeometry.h
+       cat NSObject.h | bin/header_static > static_NSObject.h
diff --git a/contrib/objcwrapper/header_static/src/header_static.nit b/contrib/objcwrapper/header_static/src/header_static.nit
new file mode 100644 (file)
index 0000000..c43fe2a
--- /dev/null
@@ -0,0 +1,96 @@
+# This file is part of NIT (http://www.nitlanguage.org).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Filters preprocessed C-like header files to remove static code and keep their signatures.
+#
+# This tool is used in the process of parsing header files to extract
+# information on the declared services (the functions and structures).
+# This information is then used to generate bindings for Nit code
+# to access these services.
+#
+# The C header sometimes contains static code. It deletes static code of
+# headers, but keep their signatures. This tool is an extension of
+# header_keeper. It searches the keyword static to identify
+# the static code, and ignores the code into their brackets. The result is
+# printed to sdtout.
+#
+# ~~~sh
+# cat Pre-Processed/CGGeometry.h | header_static > Pre-Processed/static_header.h
+# ~~~
+#
+# This module can also be used as a library.
+# The main service is the method `header_static`
+module header_static
+
+redef class Char
+       private fun is_endline: Bool do return "\};".has(self)
+end
+
+# Filters the preprocessed `input` to keep signatures for static code and write to the `output`
+fun header_static(input: Reader, output: Writer) do
+       var static_target = false
+       var static_attribute_target = false
+       var bracket_counter = 0
+       var previous_letter = ""
+       var instruction = ""
+       var double_underscore = 0
+       var position = 0
+
+       while not input.eof do
+               var line = input.read_line
+               if line.to_s.has("static") then static_target = true
+
+               if static_target then
+                       if line.to_s.has("__attribute__") then static_attribute_target = true
+                       for letter in line do
+                               if letter == '{' then bracket_counter += 1
+                               if letter == '}' then bracket_counter -= 1
+
+                               if letter == '_' and previous_letter == "_" and bracket_counter == 0 then
+                                       double_underscore += 1
+                               end
+
+                               # Sometimes we lost space between return type and signature name,
+                               # because he has a return line between both.
+                               # We add a space before signature name for safety.
+                               if bracket_counter == 0 and letter == '_' and double_underscore >= 1 and not static_attribute_target then
+                                       instruction = instruction.insert_at(" ", position - 2)
+                               end
+                               if bracket_counter == 0 and not letter.is_endline then instruction += letter.to_s
+                               if bracket_counter == 0 and letter.is_endline then
+                                       instruction += ";"
+                                       static_target = false
+                                       static_attribute_target = false
+                               end
+
+                               if bracket_counter == 0 and (letter == '}' and double_underscore >= 1 or letter == ';') then
+                                       output.write instruction + "\n"
+                               end
+
+                               if letter.is_endline and bracket_counter == 0 then
+                                       double_underscore = 0
+                                       position = 0
+                                       instruction = ""
+                               end
+
+                               previous_letter = letter.to_s
+                               position += 1
+                       end
+               else
+                       output.write line + "\n"
+               end
+       end
+end
+
+header_static(sys.stdin, sys.stdout)
index 6b849c9..4cfc3a1 100755 (executable)
@@ -65,7 +65,7 @@ redef class String
        # Returns null on success
        fun file_rename_to(dest: String): nullable String import String.to_cstring,
        NativeString.to_s, String.as nullable `{
-               int res = rename(String_to_cstring(recv), String_to_cstring(dest));
+               int res = rename(String_to_cstring(self), String_to_cstring(dest));
                if (res == 0) return null_String();
                return String_as_nullable(NativeString_to_s(strerror(errno)));
        `}
index 2852256..ac91fdb 100644 (file)
@@ -53,28 +53,28 @@ extern class RPiPin `{ CRPiPin *`}
        `}
 
        # The pin `id` depends on wiringPi setup used
-       fun id: Int `{ return recv->id; `}
+       fun id: Int `{ return self->id; `}
 
        # Sets the mode of the pin
-       fun mode(mode: RPiPinMode) `{ pinMode(recv->id, mode); `}
+       fun mode(mode: RPiPinMode) `{ pinMode(self->id, mode); `}
 
        # This sets the pull-up or pull-down resistor mode on the given pin,
        # which should be set as an input.
-       fun pullup_dncontrol(pud: PUDControl) `{ pullUpDnControl(recv->id, pud); `}
+       fun pullup_dncontrol(pud: PUDControl) `{ pullUpDnControl(self->id, pud); `}
 
        # Writes the value HIGH or LOW (true or false) to the given pin which must
        # have been previously set as an output.
-       fun write(high: Bool) `{ digitalWrite(recv->id, high? HIGH: LOW); `}
+       fun write(high: Bool) `{ digitalWrite(self->id, high? HIGH: LOW); `}
 
        # Writes the value to the PWM register for the given pin.
        # The Raspberry Pi has one on-board PWM pin, pin 1 (BMC_GPIO 18, Phys 12)
        # and the range is 0-1024.
        # Other PWM devices may have other PWM ranges.
-       fun pwm_write(value: Int) `{ pwmWrite(recv->id, value); `}
+       fun pwm_write(value: Int) `{ pwmWrite(self->id, value); `}
 
        # This function returns the value read at the given pin.
        # It will be HIGH or LOW (true or false) depending on the logic level at the pin.
-       fun read: Bool `{ return digitalRead(recv->id) == HIGH? true: false; `}
+       fun read: Bool `{ return digitalRead(self->id) == HIGH? true: false; `}
 end
 
 # RPI Pin modes
index 2ca8dc3..caf3f2e 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# This sample has been implemented to show you how simple is it to play 
-# with native callbacks (C) through an high level with NIT program.
-
+# This sample has been implemented to show you how simple is it to relay
+# native callbacks from C to a Nit program.
 module callback_chimpanze
+
 import callback_monkey
 
 class Chimpanze
@@ -27,15 +27,16 @@ class Chimpanze
        do
                var monkey = new Monkey
                print "Hum, I'm sleeping ..."
-               # Invoking method which will take some time to compute, and 
-               # will be back in wokeUp method with information.
+
+               # Invoking method which will take some time to compute, and
+               # will be back in woke_up method with information.
                # - Callback method defined in MonkeyActionCallable Interface
-               monkey.wokeUpAction(self, "Hey, I'm awake.")
+               monkey.woke_up_action(self, "Hey, I'm awake.")
        end
 
        # Inherit callback method, defined by MonkeyActionCallable interface
-       # - Back of wokeUpAction method 
-       redef fun wokeUp( sender:Monkey, message:Object )
+       # - Back of woke_up_action method
+       redef fun woke_up(sender:Monkey, message:Object)
        do
                print message
        end
index 6e1ed26..434edd1 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# This sample has been implemented to show you how simple is it to play 
-# with native callbacks (C) through an high level with NIT program.
-
+# This sample has been implemented to show you how simple is it to relay
+# native callbacks from C to a Nit program.
 module callback_monkey
 
 in "C header" `{
        #include <stdio.h>
        #include <stdlib.h>
 
-       typedef struct { 
+       typedef struct {
                int id;
                int age;
        } CMonkey;
@@ -40,53 +39,53 @@ in "C body" `{
        void cbMonkey(CMonkey *mkey, void callbackFunc(CMonkey*, MonkeyAction*), MonkeyAction *data)
        {
                sleep(2);
-               callbackFunc( mkey, data );
+               callbackFunc(mkey, data);
        }
 
        // Back of background treatment, will be redirected to callback function
-       void nit_monkey_callback_func( CMonkey *mkey, MonkeyAction *data )
+       void nit_monkey_callback_func(CMonkey *mkey, MonkeyAction *data)
        {
-               // To call a your method, the signature must be written like this :
+               // To call a your method, the signature must be written like this:
                // <Interface Name>_<Method>...
-               MonkeyActionCallable_wokeUp( data->toCall, mkey, data->message );
+               MonkeyActionCallable_woke_up(data->toCall, mkey, data->message);
        }
 `}
 
 # Implementable interface to get callback in defined methods
 interface MonkeyActionCallable
-       fun wokeUp( sender:Monkey, message: Object) is abstract
+       fun woke_up(sender:Monkey, message: Object) is abstract
 end
 
 # Defining my object type Monkey, which is, in a low level, a pointer to a C struct (CMonkey)
 extern class Monkey `{ CMonkey * `}
-       
+
        new `{
-               CMonkey *monkey = malloc( sizeof(CMonkey) );
+               CMonkey *monkey = malloc(sizeof(CMonkey));
                monkey->age = 10;
                monkey->id = 1;
                return monkey;
        `}
-       
-       # Object method which will get a callback in wokeUp method, defined in MonkeyActionCallable interface
+
+       # Object method which will get a callback in woke_up method, defined in MonkeyActionCallable interface
        # Must be defined as Nit/C method because of C call inside
-       fun wokeUpAction( toCall: MonkeyActionCallable, message: Object ) is extern import MonkeyActionCallable.wokeUp `{
+       fun woke_up_action(toCall: MonkeyActionCallable, message: Object) is extern import MonkeyActionCallable.woke_up `{
 
-               // Allocating memory to keep reference of received parameters :
+               // Allocating memory to keep reference of received parameters:
                // - Object receiver
-               // - Message 
-               MonkeyAction *data = malloc( sizeof(MonkeyAction) );
+               // - Message
+               MonkeyAction *data = malloc(sizeof(MonkeyAction));
 
                // Incrementing reference counter to prevent from releasing
-               MonkeyActionCallable_incr_ref( toCall );
-               Object_incr_ref( message );
-               
+               MonkeyActionCallable_incr_ref(toCall);
+               Object_incr_ref(message);
+
                data->toCall = toCall;
                data->message = message;
-               
-               // Calling method which reproduce a callback by passing :
+
+               // Calling method which reproduce a callback by passing:
                // - Receiver
                // - Function pointer to object return method
                // - Datas
-               cbMonkey( recv, &nit_monkey_callback_func, data );
+               cbMonkey(self, &nit_monkey_callback_func, data);
        `}
 end
index cada831..2db1595 100644 (file)
@@ -20,11 +20,11 @@ module draw_operation
 redef enum Int
        fun n_chars: Int `{
                int c;
-               if ( abs(recv) >= 10 )
-                       c = 1+(int)log10f( (float)abs(recv) );
+               if ( abs(self) >= 10 )
+                       c = 1+(int)log10f( (float)abs(self) );
                else
                        c = 1;
-               if ( recv < 0 ) c ++;
+               if ( self < 0 ) c ++;
                return c;
        `}
 end
index 00c6b68..333540b 100644 (file)
@@ -21,21 +21,21 @@ module extern_methods
 redef enum Int
        # Returns self'th fibonnaci number
        # implemented here in C for optimization purposes
-       fun fib : Int import fib `{
-               if ( recv < 2 )
-                       return recv;
+       fun fib: Int import fib `{
+               if (self < 2)
+                       return self;
                else
-                       return Int_fib( recv-1 ) + Int_fib( recv-2 );
+                       return Int_fib(self-1) + Int_fib(self-2);
        `}
 
        # System call to sleep for "self" seconds
        fun sleep `{
-               sleep( recv );
+               sleep(self);
        `}
 
-       # Return atan2l( self, x ) from libmath
-       fun atan_with( x : Int ) : Float `{
-               return atan2( recv, x );
+       # Return atan2l(self, x) from libmath
+       fun atan_with(x: Int): Float `{
+               return atan2(self, x);
        `}
 
        # This method callback to Nit methods from C code
@@ -45,13 +45,13 @@ redef enum Int
        # * to_s, a method of all objects
        # * String.to_cstring, a method of String to return an equivalent char*
        fun foo import fib, +, to_s, String.to_cstring `{
-               long recv_fib = Int_fib( recv );
-               long recv_plus_fib = Int__plus( recv, recv_fib );
+               long self_fib = Int_fib(self);
+               long self_plus_fib = Int__plus(self, self_fib);
 
-               String nit_string = Int_to_s( recv_plus_fib );
-               char *c_string = String_to_cstring( nit_string );
+               String nit_string = Int_to_s(self_plus_fib);
+               char *c_string = String_to_cstring(nit_string);
 
-               printf( "from C: self + fib(self) = %s\n", c_string );
+               printf("from C: self + fib(self) = %s\n", c_string);
        `}
 
        # Equivalent to foo but written in pure Nit
@@ -63,7 +63,7 @@ print 12.fib
 print "sleeping 1 second..."
 1.sleep
 
-print 100.atan_with( 200 )
+print 100.atan_with(200)
 8.foo
 8.bar
 
index 8d5a296..a451597 100644 (file)
@@ -43,7 +43,7 @@ redef class App
                android.util.Log.d("mnit_simple", "Java within NIT!!!");
 
                // - Context needed from now on
-               final android.app.Activity context = App_native_activity(recv);
+               final android.app.Activity context = App_native_activity(self);
 
                // Vibration
                android.os.Vibrator v = (android.os.Vibrator)
index e3e0e65..c037d7b 100644 (file)
@@ -33,8 +33,8 @@ extern class NativeActivity in "Java" `{ android.app.Activity `}
 
        # HACK for bug #845
        redef fun new_global_ref: SELF import sys, Sys.jni_env `{
-               Sys sys = NativeActivity_sys(recv);
+               Sys sys = NativeActivity_sys(self);
                JNIEnv *env = Sys_jni_env(sys);
-               return (*env)->NewGlobalRef(env, recv);
+               return (*env)->NewGlobalRef(env, self);
        `}
 end
index f70b26f..871c13c 100644 (file)
@@ -47,11 +47,11 @@ in "Java" `{
 extern class NativeAssetManager in "Java" `{ android.content.res.AssetManager `}
        super JavaObject
 
-       fun close in "Java" `{ recv.close(); `}
+       fun close in "Java" `{ self.close(); `}
 
        fun get_locales: Array[JavaString] import Array[JavaString], Array[JavaString].add in "Java" `{
                int arr = new_Array_of_JavaString();
-               for (String s : recv.getLocales()) {
+               for (String s : self.getLocales()) {
                        Array_of_JavaString_add(arr, s);
                }
                return arr;
@@ -60,7 +60,7 @@ extern class NativeAssetManager in "Java" `{ android.content.res.AssetManager `}
        fun list(path: JavaString): Array[JavaString] import Array[JavaString], Array[JavaString].add  in "Java" `{
                int arr = new_Array_of_JavaString();
                try {
-                       for (String s : recv.list(path)) {
+                       for (String s : self.list(path)) {
                                Array_of_JavaString_add(arr, s);
                        }
                }catch (IOException e) {
@@ -73,7 +73,7 @@ extern class NativeAssetManager in "Java" `{ android.content.res.AssetManager `}
        fun open(file_name: JavaString): NativeInputStream in "Java" `{
                InputStream stream = null;
                try {
-                       stream = recv.open(file_name);
+                       stream = self.open(file_name);
                }catch (IOException e) {
                        Log.e("Error while opening " + file_name, e.getMessage());
                        e.printStackTrace();
@@ -84,7 +84,7 @@ extern class NativeAssetManager in "Java" `{ android.content.res.AssetManager `}
        fun open_fd(file_name: JavaString): NativeAssetFileDescriptor in "Java" `{
                AssetFileDescriptor afd = null;
                try {
-                       afd = recv.openFd(file_name);
+                       afd = self.openFd(file_name);
                }catch(IOException e){
                        Log.e("Error while opening " + file_name, e.getMessage());
                        e.printStackTrace();
@@ -95,7 +95,7 @@ extern class NativeAssetManager in "Java" `{ android.content.res.AssetManager `}
        fun open_non_asset_fd(file_name: JavaString): NativeAssetFileDescriptor in "Java" `{
                AssetFileDescriptor afd = null;
                try {
-                       afd =  recv.openNonAssetFd(file_name);
+                       afd =  self.openNonAssetFd(file_name);
                }catch(IOException e){
                        Log.e("Error while opening " + file_name, e.getMessage());
                        e.printStackTrace();
@@ -105,9 +105,9 @@ extern class NativeAssetManager in "Java" `{ android.content.res.AssetManager `}
 
        # HACK for bug #845
        redef fun new_global_ref import sys, Sys.jni_env `{
-               Sys sys = NativeResources_sys(recv);
+               Sys sys = NativeResources_sys(self);
                JNIEnv *env = Sys_jni_env(sys);
-               return (*env)->NewGlobalRef(env, recv);
+               return (*env)->NewGlobalRef(env, self);
        `}
 end
 
@@ -183,24 +183,24 @@ end
 extern class NativeResources in "Java" `{ android.content.res.Resources `}
        super JavaObject
 
-       fun get_assets:NativeAssetManager in "Java" `{ return recv.getAssets(); `}
-       fun get_color(id: Int): Int in "Java" `{ return recv.getColor((int)id); `}
-       fun get_boolean(id: Int): Bool in "Java" `{ return recv.getBoolean((int)id); `}
-       fun get_dimension(id: Int): Int in "Java" `{ return (int)recv.getDimension((int)id); `}
-       fun get_drawable(id: Int): NativeDrawable in "Java" `{ return recv.getDrawable((int)id); `}
-       fun get_identifier(name, def_type, def_package: JavaString): Int in "Java" `{ return recv.getIdentifier(name, def_type, def_package); `}
-       fun get_integer(id: Int): Int in "Java" `{ return recv.getInteger((int)id); `}
-       fun get_string(id: Int): JavaString in "Java" `{ return recv.getString((int)id); `}
-       fun get_resource_entry_name(resid: Int): JavaString in "Java" `{ return recv.getResourceEntryName((int)resid); `}
-       fun get_resource_name(resid: Int): JavaString in "Java" `{ return recv.getResourceName((int)resid); `}
-       fun get_resource_pakage_name(resid: Int): JavaString in "Java" `{ return recv.getResourcePackageName((int)resid); `}
-       fun get_resource_type_name(resid: Int): JavaString in "Java" `{ return recv.getResourceTypeName((int)resid); `}
+       fun get_assets:NativeAssetManager in "Java" `{ return self.getAssets(); `}
+       fun get_color(id: Int): Int in "Java" `{ return self.getColor((int)id); `}
+       fun get_boolean(id: Int): Bool in "Java" `{ return self.getBoolean((int)id); `}
+       fun get_dimension(id: Int): Int in "Java" `{ return (int)self.getDimension((int)id); `}
+       fun get_drawable(id: Int): NativeDrawable in "Java" `{ return self.getDrawable((int)id); `}
+       fun get_identifier(name, def_type, def_package: JavaString): Int in "Java" `{ return self.getIdentifier(name, def_type, def_package); `}
+       fun get_integer(id: Int): Int in "Java" `{ return self.getInteger((int)id); `}
+       fun get_string(id: Int): JavaString in "Java" `{ return self.getString((int)id); `}
+       fun get_resource_entry_name(resid: Int): JavaString in "Java" `{ return self.getResourceEntryName((int)resid); `}
+       fun get_resource_name(resid: Int): JavaString in "Java" `{ return self.getResourceName((int)resid); `}
+       fun get_resource_pakage_name(resid: Int): JavaString in "Java" `{ return self.getResourcePackageName((int)resid); `}
+       fun get_resource_type_name(resid: Int): JavaString in "Java" `{ return self.getResourceTypeName((int)resid); `}
 
        # HACK for bug #845
        redef fun new_global_ref import sys, Sys.jni_env `{
-               Sys sys = NativeResources_sys(recv);
+               Sys sys = NativeResources_sys(self);
                JNIEnv *env = Sys_jni_env(sys);
-               return (*env)->NewGlobalRef(env, recv);
+               return (*env)->NewGlobalRef(env, self);
        `}
 end
 
@@ -300,14 +300,14 @@ extern class NativeBitmap in "Java" `{ android.graphics.Bitmap `}
        # Create a NativeBitmap using a resource ID and the NativeResources
        # Called by the ResourceManager
        new from_resources(res: NativeResources, id: Int) in "Java" `{ return BitmapFactory.decodeResource(res, (int)id); `}
-       fun width: Int in "Java" `{ return recv.getWidth(); `}
-       fun height: Int in "Java" `{ return recv.getHeight(); `}
+       fun width: Int in "Java" `{ return self.getWidth(); `}
+       fun height: Int in "Java" `{ return self.getHeight(); `}
 
        # HACK for bug #845
        redef fun new_global_ref import sys, Sys.jni_env `{
-               Sys sys = NativeResources_sys(recv);
+               Sys sys = NativeResources_sys(self);
                JNIEnv *env = Sys_jni_env(sys);
-               return (*env)->NewGlobalRef(env, recv);
+               return (*env)->NewGlobalRef(env, self);
        `}
 
 end
@@ -318,14 +318,14 @@ extern class NativeAssetFileDescriptor in "Java" `{ android.content.res.AssetFil
 
        fun close in "Java" `{
                try {
-                       recv.close();
+                       self.close();
                }catch(IOException e){
                        e.printStackTrace();
                }
        `}
        fun create_input_stream: NativeFileInputStream in "Java" `{
                try {
-                       return recv.createInputStream();
+                       return self.createInputStream();
                }catch(IOException e){
                        Log.e("Error creating input_stream", e.getMessage());
                        e.printStackTrace();
@@ -334,34 +334,34 @@ extern class NativeAssetFileDescriptor in "Java" `{ android.content.res.AssetFil
        `}
        fun create_output_stream: NativeFileOutputStream in "Java" `{
                try {
-                       return recv.createOutputStream();
+                       return self.createOutputStream();
                }catch(IOException e){
                        Log.e("Error creating output stream", e.getMessage());
                        e.printStackTrace();
                        return null;
                }
        `}
-       fun describe_contents: Int in "Java" `{ return (int)recv.describeContents(); `}
-       fun declared_length: Int in "Java" `{ return (int)recv.getDeclaredLength(); `}
-       # fun extras: Bundle in "Java" `{ return recv.getExtras(); `}
+       fun describe_contents: Int in "Java" `{ return (int)self.describeContents(); `}
+       fun declared_length: Int in "Java" `{ return (int)self.getDeclaredLength(); `}
+       # fun extras: Bundle in "Java" `{ return self.getExtras(); `}
 
        fun  file_descriptor: NativeFileDescriptor in "Java" `{
-               FileDescriptor fd =  recv.getFileDescriptor();
+               FileDescriptor fd =  self.getFileDescriptor();
                if (fd == null) {
                        Log.e("AssetFileDesciptorError", "Can't retrieve the FileDescriptor of this AssetFileDescriptor");
                }
                return fd;
        `}
 
-       fun length: Int in "Java" `{ return (int)recv.getLength(); `}
-       fun start_offset: Int in "Java" `{ return (int)recv.getStartOffset(); `}
-       redef fun to_s: String import JavaString.to_s in "Java" `{ return JavaString_to_s(recv.toString()); `}
+       fun length: Int in "Java" `{ return (int)self.getLength(); `}
+       fun start_offset: Int in "Java" `{ return (int)self.getStartOffset(); `}
+       redef fun to_s: String import JavaString.to_s in "Java" `{ return JavaString_to_s(self.toString()); `}
 
        # HACK for bug #845
        redef fun new_global_ref import sys, Sys.jni_env `{
-               Sys sys = NativeResources_sys(recv);
+               Sys sys = NativeResources_sys(self);
                JNIEnv *env = Sys_jni_env(sys);
-               return (*env)->NewGlobalRef(env, recv);
+               return (*env)->NewGlobalRef(env, self);
        `}
 end
 
@@ -378,11 +378,11 @@ redef class App
        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(); `}
+       private fun assets: NativeAssetManager import native_activity in "Java" `{ return App_native_activity(self).getAssets(); `}
 
        # Get the package name of the application
-       private fun package_name: JavaString import native_activity in "Java" `{ return App_native_activity(recv).getPackageName(); `}
+       private fun package_name: JavaString import native_activity in "Java" `{ return App_native_activity(self).getPackageName(); `}
 
        # Get the native ResourceManager of the application, used to initialize the nit's ResourceManager
-       private fun resources: NativeResources import native_activity in "Java" `{ return App_native_activity(recv).getResources(); `}
+       private fun resources: NativeResources import native_activity in "Java" `{ return App_native_activity(self).getResources(); `}
 end
index 464b2f8..9374ac7 100644 (file)
@@ -72,19 +72,19 @@ extern class NativeAudioManager in "Java" `{ android.media.AudioManager `}
 
        # Current audio mode.
        # ( MODE_NORMAL = 0, MODE_RINGTONE = 1, MODE_IN_CALL = 2 or MODE_IN_COMMUNICATION = 3 )
-       fun mode: Int in "Java" `{ return recv.getMode(); `}
+       fun mode: Int in "Java" `{ return self.getMode(); `}
 
        # Sets the audio mode.
        # ( MODE_NORMAL = 0, MODE_RINGTONE = 1, MODE_IN_CALL = 2 or MODE_IN_COMMUNICATION = 3 )
-       fun mode=(i: Int) in "Java" `{ recv.setMode((int)i); `}
+       fun mode=(i: Int) in "Java" `{ self.setMode((int)i); `}
 
        # Sends a request to obtain audio focus
        fun request_audio_focus: Int in "Java" `{
-               return recv.requestAudioFocus(afChangeListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
+               return self.requestAudioFocus(afChangeListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
        `}
 
        # Gives up audio focus
-       fun abandon_audio_focus: Int in "Java" `{ return recv.abandonAudioFocus(afChangeListener); `}
+       fun abandon_audio_focus: Int in "Java" `{ return self.abandonAudioFocus(afChangeListener); `}
 end
 
 # Media Player from Java, used to play long sounds or musics, not simultaneously
@@ -97,30 +97,30 @@ private extern class NativeMediaPlayer in "Java" `{ android.media.MediaPlayer `}
                mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
                return mp;
        `}
-       fun start in "Java" `{ recv.start(); `}
+       fun start in "Java" `{ self.start(); `}
        fun prepare in "Java" `{
                try {
-                       recv.prepare();
+                       self.prepare();
                }catch(IOException e) {
                        Log.e("Error preparing the Media Player", e.getMessage());
                        e.printStackTrace();
                }
        `}
 
-       fun create(context: NativeActivity, id: Int): NativeMediaPlayer in "Java" `{ return recv.create(context, (int)id); `}
-       fun pause in "Java" `{ recv.pause(); `}
-       fun stop in "Java" `{ recv.stop(); `}
-       fun playing: Bool in "Java" `{ return recv.isPlaying(); `}
-       fun release in "Java" `{ recv.release(); `}
-       fun duration: Int in "Java" `{ return recv.getDuration(); `}
-       fun looping: Bool in "Java" `{ return recv.isLooping(); `}
-       fun looping=(b: Bool) in "Java" `{ recv.setLooping(b); `}
-       fun volume=(vol: Float) in "Java" `{ recv.setVolume((float)vol, (float)vol); `}
-       fun both_volume(left_volume, right_volume: Float) in "Java" `{ recv.setVolume((float)left_volume, (float)right_volume); `}
-       fun stream_type=(stream_type: Int) in "Java" `{ recv.setAudioStreamType((int)stream_type); `}
+       fun create(context: NativeActivity, id: Int): NativeMediaPlayer in "Java" `{ return self.create(context, (int)id); `}
+       fun pause in "Java" `{ self.pause(); `}
+       fun stop in "Java" `{ self.stop(); `}
+       fun playing: Bool in "Java" `{ return self.isPlaying(); `}
+       fun release in "Java" `{ self.release(); `}
+       fun duration: Int in "Java" `{ return self.getDuration(); `}
+       fun looping: Bool in "Java" `{ return self.isLooping(); `}
+       fun looping=(b: Bool) in "Java" `{ self.setLooping(b); `}
+       fun volume=(vol: Float) in "Java" `{ self.setVolume((float)vol, (float)vol); `}
+       fun both_volume(left_volume, right_volume: Float) in "Java" `{ self.setVolume((float)left_volume, (float)right_volume); `}
+       fun stream_type=(stream_type: Int) in "Java" `{ self.setAudioStreamType((int)stream_type); `}
        fun data_source_fd(fd: NativeFileDescriptor, start_offset, length: Int) in "Java"  `{
                try {
-                       recv.setDataSource(fd, start_offset, length);
+                       self.setDataSource(fd, start_offset, length);
                }catch(IOException e) {
                        Log.e("Error loading the Media Player with a file descriptor", e.getMessage());
                        e.printStackTrace();
@@ -128,13 +128,13 @@ private extern class NativeMediaPlayer in "Java" `{ android.media.MediaPlayer `}
        `}
        fun data_source_path(path: JavaString) in "Java" `{
                try {
-                       recv.setDataSource(path);
+                       self.setDataSource(path);
                }catch(IOException e) {
                        Log.e("Error loading the Media Player", e.getMessage());
                        e.printStackTrace();
                }
        `}
-       fun reset in "Java" `{ recv.reset(); `}
+       fun reset in "Java" `{ self.reset(); `}
 end
 
 # Sound Pool from Java, used to play sounds simultaneously
@@ -145,23 +145,23 @@ private extern class NativeSoundPool in "Java" `{ android.media.SoundPool `}
        new(max_streams, stream_type, src_quality: Int) in "Java" `{
                return new SoundPool((int)max_streams, (int)stream_type, (int)src_quality);
        `}
-       fun load_asset_fd(afd: NativeAssetFileDescriptor, priority: Int): Int in "Java" `{ return recv.load(afd, (int)priority); `}
-       fun load_id(context: NativeActivity, resid, priority: Int): Int in "Java" `{ return recv.load(context, (int)resid, (int)priority); `}
-       fun load_path(path: JavaString, priority: Int): Int in "Java" `{ return recv.load(path, (int)priority); `}
+       fun load_asset_fd(afd: NativeAssetFileDescriptor, priority: Int): Int in "Java" `{ return self.load(afd, (int)priority); `}
+       fun load_id(context: NativeActivity, resid, priority: Int): Int in "Java" `{ return self.load(context, (int)resid, (int)priority); `}
+       fun load_path(path: JavaString, priority: Int): Int in "Java" `{ return self.load(path, (int)priority); `}
        fun play(sound_id: Int, left_volume, right_volume: Float, priority, l: Int, rate: Float): Int in "Java" `{
-               return recv.play((int)sound_id, (float)left_volume, (float)right_volume, (int)priority, (int)l, (float)rate);
+               return self.play((int)sound_id, (float)left_volume, (float)right_volume, (int)priority, (int)l, (float)rate);
        `}
-       fun pause(stream_id: Int) in "Java" `{ recv.pause((int)stream_id); `}
-       fun auto_pause in "Java" `{ recv.autoPause(); `}
-       fun auto_resume in "Java" `{ recv.autoResume(); `}
-       fun resume(stream_id: Int) in "Java" `{ recv.resume((int)stream_id); `}
-       fun set_loop(stream_id, l: Int) in "Java" `{ recv.setLoop((int)stream_id, (int)l); `}
-       fun set_priority(stream_id, priority: Int) in "Java" `{ recv.setPriority((int)stream_id, (int)priority); `}
-       fun set_rate(stream_id: Int, rate: Float) in "Java" `{ recv.setRate((int)stream_id, (float)rate); `}
-       fun set_volume(stream_id: Int, left_volume, right_volume: Float) in "Java" `{ recv.setVolume((int)stream_id, (float)left_volume, (float)right_volume); `}
-       fun stop(stream_id: Int) in "Java" `{ recv.stop((int)stream_id); `}
-       fun unload(sound_id: Int): Bool in "Java" `{ return recv.unload((int)sound_id); `}
-       fun release in "Java" `{ recv.release(); `}
+       fun pause(stream_id: Int) in "Java" `{ self.pause((int)stream_id); `}
+       fun auto_pause in "Java" `{ self.autoPause(); `}
+       fun auto_resume in "Java" `{ self.autoResume(); `}
+       fun resume(stream_id: Int) in "Java" `{ self.resume((int)stream_id); `}
+       fun set_loop(stream_id, l: Int) in "Java" `{ self.setLoop((int)stream_id, (int)l); `}
+       fun set_priority(stream_id, priority: Int) in "Java" `{ self.setPriority((int)stream_id, (int)priority); `}
+       fun set_rate(stream_id: Int, rate: Float) in "Java" `{ self.setRate((int)stream_id, (float)rate); `}
+       fun set_volume(stream_id: Int, left_volume, right_volume: Float) in "Java" `{ self.setVolume((int)stream_id, (float)left_volume, (float)right_volume); `}
+       fun stop(stream_id: Int) in "Java" `{ self.stop((int)stream_id); `}
+       fun unload(sound_id: Int): Bool in "Java" `{ return self.unload((int)sound_id); `}
+       fun release in "Java" `{ self.release(); `}
 end
 
 
@@ -425,13 +425,13 @@ redef class App
 
        # Get the native audio manager
        fun audio_manager: NativeAudioManager import native_activity in "Java" `{
-               return (AudioManager)App_native_activity(recv).getSystemService(Context.AUDIO_SERVICE);
+               return (AudioManager)App_native_activity(self).getSystemService(Context.AUDIO_SERVICE);
        `}
 
        # Sets the stream of the app to STREAM_MUSIC.
        # STREAM_MUSIC is the default stream used by android apps.
        private fun manage_audio_stream import native_activity, native_app_glue in "Java" `{
-               App_native_activity(recv).setVolumeControlStream(AudioManager.STREAM_MUSIC);
+               App_native_activity(self).setVolumeControlStream(AudioManager.STREAM_MUSIC);
        `}
 
        # Retrieves a sound with a soundpool in the `assets` folder using its name.
index 19b2f8e..fde88af 100644 (file)
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# A mapping class of `String` to various value types used by the 
+# A mapping class of `String` to various value types used by the
 # Android API for various data exchange purposes
 module bundle
 
@@ -36,17 +36,17 @@ extern class NativeBundle in "Java" `{ android.os.Bundle `}
 
        new in "Java" `{ return new Bundle(); `}
 
-       fun clone: JavaObject in "Java" `{ return recv.clone(); `}
-       fun size: Int in "Java" `{ return recv.size(); `}
-       fun is_empty: Bool in "Java" `{ return recv.isEmpty(); `}
-       fun clear in "Java" `{ recv.clear(); `}
-       fun contains_key(key: JavaString): Bool in "Java" `{ return recv.containsKey(key); `}
-       fun get(key: JavaString): JavaObject in "Java" `{ return recv.get(key); `}
-       fun remove(key: JavaString) in "Java" `{ recv.remove(key); `}
-       fun put_all(bundle: NativeBundle) in "Java" `{ recv.putAll(bundle); `}
+       fun clone: JavaObject in "Java" `{ return self.clone(); `}
+       fun size: Int in "Java" `{ return self.size(); `}
+       fun is_empty: Bool in "Java" `{ return self.isEmpty(); `}
+       fun clear in "Java" `{ self.clear(); `}
+       fun contains_key(key: JavaString): Bool in "Java" `{ return self.containsKey(key); `}
+       fun get(key: JavaString): JavaObject in "Java" `{ return self.get(key); `}
+       fun remove(key: JavaString) in "Java" `{ self.remove(key); `}
+       fun put_all(bundle: NativeBundle) in "Java" `{ self.putAll(bundle); `}
        fun key_set: HashSet[JavaString] import HashSet[JavaString], 
          HashSet[JavaString].add in "Java" `{ 
-               Set<String> java_set = recv.keySet(); 
+               Set<String> java_set = self.keySet();
                int nit_hashset = new_HashSet_of_JavaString();
 
                for (String element: java_set)
@@ -54,209 +54,209 @@ extern class NativeBundle in "Java" `{ android.os.Bundle `}
 
                return nit_hashset;
        `}
-       fun has_file_descriptors: Bool in "Java" `{ return recv.hasFileDescriptors(); `}
-       fun put_boolean(key: JavaString, value: Bool) in "Java" `{ 
-               recv.putBoolean(key, value); 
+       fun has_file_descriptors: Bool in "Java" `{ return self.hasFileDescriptors(); `}
+       fun put_boolean(key: JavaString, value: Bool) in "Java" `{
+               self.putBoolean(key, value);
        `}
-       fun put_byte(key: JavaString, value: Int) in "Java" `{ 
-               recv.putByte(key, (byte) value); 
+       fun put_byte(key: JavaString, value: Int) in "Java" `{
+               self.putByte(key, (byte) value);
        `}
        # FIXME: Java's `char` are encoded on 16-bits whereas Nit's are on 8-bits.
-       fun put_char(key: JavaString, value: Char) in "Java" `{ 
-               recv.putChar(key, value); 
+       fun put_char(key: JavaString, value: Char) in "Java" `{
+               self.putChar(key, value);
        `}
-       fun put_short(key: JavaString, value: Int) in "Java" `{ 
-               recv.putShort(key, (short) value); 
+       fun put_short(key: JavaString, value: Int) in "Java" `{
+               self.putShort(key, (short) value);
        `}
-       fun put_int(key: JavaString, value: Int) in "Java" `{ 
-               recv.putInt(key, (int) value); 
+       fun put_int(key: JavaString, value: Int) in "Java" `{
+               self.putInt(key, (int) value);
        `}
-       fun put_long(key: JavaString, value: Int) in "Java" `{ 
-               recv.putLong(key, value); 
+       fun put_long(key: JavaString, value: Int) in "Java" `{
+               self.putLong(key, value);
        `}
-       fun put_float(key: JavaString, value: Float) in "Java" `{ 
-               recv.putFloat(key, (float) value); 
+       fun put_float(key: JavaString, value: Float) in "Java" `{
+               self.putFloat(key, (float) value);
        `}
-       fun put_double(key: JavaString, value: Float) in "Java" `{ 
-               recv.putDouble(key, value); 
+       fun put_double(key: JavaString, value: Float) in "Java" `{
+               self.putDouble(key, value);
        `}
-       fun put_string(key: JavaString, value: JavaString) in "Java" `{ 
-               recv.putString(key, value); 
+       fun put_string(key: JavaString, value: JavaString) in "Java" `{
+               self.putString(key, value);
        `}
-       fun put_char_sequence(key: JavaString, value: JavaString) in "Java" `{ 
-               recv.putCharSequence(key, value); 
+       fun put_char_sequence(key: JavaString, value: JavaString) in "Java" `{
+               self.putCharSequence(key, value);
        `}
-       fun put_integer_array_list(key: JavaString, value: Array[Int]) 
+       fun put_integer_array_list(key: JavaString, value: Array[Int])
          import Array[Int].length, Array[Int].[] in "Java" `{
-               ArrayList<Integer> java_array = 
+               ArrayList<Integer> java_array =
                        new ArrayList<Integer>((int) Array_of_Int_length(value));
-               
+
                for(int i=0; i < java_array.size(); ++i)
                        java_array.add((int) Array_of_Int__index(value, i));
 
-               recv.putIntegerArrayList(key, java_array); 
+               self.putIntegerArrayList(key, java_array);
        `}
        fun put_string_array_list(key: JavaString, value: Array[JavaString])
          import Array[JavaString].length, Array[JavaString].[] in "Java" `{
                ArrayList<String> java_array = new ArrayList<String>((int)Array_of_JavaString_length(value));
-               
+
                for(int i=0; i < java_array.size(); ++i)
                        java_array.add(Array_of_JavaString__index(value, i));
 
-               recv.putStringArrayList(key, java_array); 
+               self.putStringArrayList(key, java_array);
        `}
        fun put_char_sequence_array_list(key: JavaString, value: Array[JavaString])
          import Array[JavaString].length, Array[JavaString].[] in "Java" `{
-               ArrayList<CharSequence> java_array = 
+               ArrayList<CharSequence> java_array =
                  new ArrayList<CharSequence>((int)Array_of_JavaString_length(value));
-               
+
                for(int i=0; i < java_array.size(); ++i)
                        java_array.add(Array_of_JavaString__index(value, i));
 
-               recv.putCharSequenceArrayList(key, java_array); 
+               self.putCharSequenceArrayList(key, java_array);
        `}
        fun put_boolean_array(key: JavaString, value: Array[Bool])
          import Array[Bool].length, Array[Bool].[] in "Java" `{
                boolean[] java_array = new boolean[(int)Array_of_Bool_length(value)];
-               
+
                for(int i=0; i < java_array.length; ++i)
                        java_array[i] = Array_of_Bool__index(value, i);
 
-               recv.putBooleanArray(key, java_array); 
+               self.putBooleanArray(key, java_array);
        `}
        fun put_byte_array(key: JavaString, value: Array[Int])
          import Array[Int].length, Array[Int].[] in "Java" `{
                byte[] java_array = new byte[(int)Array_of_Int_length(value)];
-               
+
                for(int i=0; i < java_array.length; ++i)
                        java_array[i] = (byte) Array_of_Int__index(value, i);
 
-               recv.putByteArray(key, java_array); 
+               self.putByteArray(key, java_array);
        `}
        fun put_short_array(key: JavaString, value: Array[Int])
          import Array[Int].length, Array[Int].[] in "Java" `{
                short[] java_array = new short[(int)Array_of_Int_length(value)];
-               
+
                for(int i=0; i < java_array.length; ++i)
                        java_array[i] = (short) Array_of_Int__index(value, i);
 
-               recv.putShortArray(key, java_array); 
+               self.putShortArray(key, java_array);
        `}
        # FIXME: Java's `char` are encoded on 16-bits whereas Nit's are on 8-bits.
        fun put_char_array(key: JavaString, value: Array[Char])
          import Array[Char].length, Array[Char].[] in "Java" `{
                char[] java_array = new char[(int)Array_of_Char_length(value)];
-               
+
                for(int i=0; i < java_array.length; ++i)
                        java_array[i] = Array_of_Char__index(value, i);
 
-               recv.putCharArray(key, java_array); 
+               self.putCharArray(key, java_array);
        `}
        fun put_int_array(key: JavaString, value: Array[Int])
          import Array[Int].length, Array[Int].[] in "Java" `{
                int[] java_array = new int[(int)Array_of_Int_length(value)];
-               
+
                for(int i=0; i < java_array.length; ++i)
                        java_array[i] = (int) Array_of_Int__index(value, i);
 
-               recv.putIntArray(key, java_array); 
+               self.putIntArray(key, java_array);
        `}
        fun put_long_array(key: JavaString, value: Array[Int])
          import Array[Int].length, Array[Int].[] in "Java" `{
                long[] java_array = new long[(int)Array_of_Int_length(value)];
-               
+
                for(int i=0; i < java_array.length; ++i)
                        java_array[i] = Array_of_Int__index(value, i);
 
-               recv.putLongArray(key, java_array); 
+               self.putLongArray(key, java_array);
        `}
        fun put_float_array(key: JavaString, value: Array[Float])
          import Array[Float].length, Array[Float].[] in "Java" `{
                float[] java_array = new float[(int)Array_of_Float_length(value)];
-               
+
                for(int i=0; i < java_array.length; ++i)
                        java_array[i] = (float) Array_of_Float__index(value, i);
 
-               recv.putFloatArray(key, java_array); 
+               self.putFloatArray(key, java_array);
        `}
        fun put_double_array(key: JavaString, value: Array[Float])
          import Array[Float].length, Array[Float].[] in "Java" `{
                double[] java_array = new double[(int)Array_of_Float_length(value)];
-               
+
                for(int i=0; i < java_array.length; ++i)
                        java_array[i] = Array_of_Float__index(value, i);
 
-               recv.putDoubleArray(key, java_array); 
+               self.putDoubleArray(key, java_array);
        `}
        fun put_string_array(key: JavaString, value: Array[JavaString])
          import Array[JavaString].length, Array[JavaString].[] in "Java" `{
                String[] java_array = new String[(int)Array_of_JavaString_length(value)];
-               
+
                for(int i=0; i < java_array.length; ++i)
                        java_array[i] = Array_of_JavaString__index(value, i);
 
-               recv.putStringArray(key, java_array); 
+               self.putStringArray(key, java_array);
        `}
        fun put_char_sequence_array(key: JavaString, value: Array[JavaString])
          import Array[JavaString].length, Array[JavaString].[] in "Java" `{
                CharSequence[] java_array = new CharSequence[(int)Array_of_JavaString_length(value)];
-               
+
                for(int i=0; i < java_array.length; ++i)
                        java_array[i] = Array_of_JavaString__index(value, i);
 
-               recv.putCharSequenceArray(key, java_array); 
+               self.putCharSequenceArray(key, java_array);
        `}
-       fun put_bundle(key: JavaString, value: NativeBundle) in "Java" `{ 
-               recv.putBundle(key, value); 
+       fun put_bundle(key: JavaString, value: NativeBundle) in "Java" `{
+               self.putBundle(key, value);
        `}
-       fun get_boolean(key: JavaString): Bool in "Java" `{ return recv.getBoolean(key); `}
+       fun get_boolean(key: JavaString): Bool in "Java" `{ return self.getBoolean(key); `}
        fun get_boolean_with_def_value(key: JavaString, def_value: Bool): Bool in "Java" `{
-               return recv.getBoolean(key, def_value); 
+               return self.getBoolean(key, def_value);
        `}
-       fun get_byte(key: JavaString): Int in "Java" `{ return recv.getByte(key); `}
-       fun get_byte_with_def_value(key: JavaString, def_value: Int): Int in "Java" `{ 
-               return recv.getByte(key, (byte) def_value); 
+       fun get_byte(key: JavaString): Int in "Java" `{ return self.getByte(key); `}
+       fun get_byte_with_def_value(key: JavaString, def_value: Int): Int in "Java" `{
+               return self.getByte(key, (byte) def_value);
        `}
        # FIXME: Java's `char` are encoded on 16-bits whereas Nit's are on 8-bits.
-       fun get_char(key: JavaString): Char in "Java" `{ return recv.getChar(key); `}
+       fun get_char(key: JavaString): Char in "Java" `{ return self.getChar(key); `}
        # FIXME: Java's `char` are encoded on 16-bits whereas Nit's are on 8-bits.
        fun get_char_with_def_value(key: JavaString, def_value: Char): Char in "Java" `{
-               return recv.getChar(key, def_value); 
+               return self.getChar(key, def_value);
        `}
-       fun get_short(key: JavaString): Int in "Java" `{ return (short) recv.getShort(key); `}
+       fun get_short(key: JavaString): Int in "Java" `{ return (short) self.getShort(key); `}
        fun get_short_with_def_value(key: JavaString, def_value: Int): Int in "Java" `{
-               return (short) recv.getShort(key, (short) def_value); 
+               return (short) self.getShort(key, (short) def_value);
        `}
-       fun get_int(key: JavaString): Int in "Java" `{ return recv.getInt(key); `}
+       fun get_int(key: JavaString): Int in "Java" `{ return self.getInt(key); `}
        fun get_int_with_def_value(key: JavaString, def_value: Int): Int in "Java" `{
-               return recv.getInt(key, (int) def_value);
+               return self.getInt(key, (int) def_value);
        `}
-       fun get_long(key: JavaString): Int in "Java" `{ return recv.getLong(key); `}
+       fun get_long(key: JavaString): Int in "Java" `{ return self.getLong(key); `}
        fun get_long_with_def_value(key: JavaString, def_value: Int): Int in "Java" `{
-               return recv.getLong(key); 
+               return self.getLong(key);
        `}
        fun get_float(key: JavaString): Float in "Java" `{
-               return (float) recv.getFloat(key); 
+               return (float) self.getFloat(key);
        `}
        fun get_float_with_def_value(key: JavaString, def_value: Float): Float in "Java" `{
-               return (float) recv.getFloat(key, (float) def_value);
+               return (float) self.getFloat(key, (float) def_value);
        `}
-       fun get_double(key: JavaString): Float in "Java" `{ return recv.getDouble(key); `}
-       fun get_double_with_def_value(key: JavaString, def_value: Float): Float in "Java" `{ 
-               return recv.getDouble(key, def_value); 
+       fun get_double(key: JavaString): Float in "Java" `{ return self.getDouble(key); `}
+       fun get_double_with_def_value(key: JavaString, def_value: Float): Float in "Java" `{
+               return self.getDouble(key, def_value);
        `}
        fun get_string(key: JavaString): JavaString in "Java" `{
-               return recv.getString(key);
+               return self.getString(key);
        `}
        fun get_char_sequence(key: JavaString): JavaString in "Java" `{
-               return (String) recv.getCharSequence(key); 
+               return (String) self.getCharSequence(key);
        `}
        fun get_bundle(key: JavaString): NativeBundle in "Java" `{
-               return recv.getBundle(key); 
+               return self.getBundle(key);
        `}
        fun get_integer_array_list(key: JavaString): Array[Int]
                import Array[Int], Array[Int].add in "Java" `{
-               ArrayList<Integer> java_array = recv.getIntegerArrayList(key); 
+               ArrayList<Integer> java_array = self.getIntegerArrayList(key);
                int nit_array = new_Array_of_Int();
 
                if (java_array == null) return nit_array;
@@ -268,7 +268,7 @@ extern class NativeBundle in "Java" `{ android.os.Bundle `}
        `}
        fun get_string_array_list(key: JavaString): Array[String]
                import StringCopyArray, StringCopyArray.add, StringCopyArray.collection in "Java" `{
-               ArrayList<String> java_array = recv.getStringArrayList(key); 
+               ArrayList<String> java_array = self.getStringArrayList(key);
                int nit_array = new_StringCopyArray();
 
                if (java_array == null) return nit_array;
@@ -280,7 +280,7 @@ extern class NativeBundle in "Java" `{ android.os.Bundle `}
        `}
        fun get_char_sequence_array_list(key: JavaString): Array[String]
                import StringCopyArray, StringCopyArray.add, StringCopyArray.collection in "Java" `{
-               ArrayList<CharSequence> java_array = recv.getCharSequenceArrayList(key); 
+               ArrayList<CharSequence> java_array = self.getCharSequenceArrayList(key);
                int nit_array = new_StringCopyArray();
 
                if (java_array == null) return nit_array;
@@ -291,8 +291,8 @@ extern class NativeBundle in "Java" `{ android.os.Bundle `}
                return StringCopyArray_collection(nit_array);
        `}
        fun get_boolean_array(key: JavaString): Array[Bool]
-               import Array[Bool], Array[Bool].add in "Java" `{ 
-               boolean[] java_array = recv.getBooleanArray(key); 
+               import Array[Bool], Array[Bool].add in "Java" `{
+               boolean[] java_array = self.getBooleanArray(key);
                int nit_array = new_Array_of_Bool();
 
                if (java_array == null) return nit_array;
@@ -303,123 +303,123 @@ extern class NativeBundle in "Java" `{ android.os.Bundle `}
                return nit_array;
        `}
        fun get_byte_array(key: JavaString): Array[Int]
-               import Array[Int], Array[Int].add in "Java" `{ 
-               byte[] java_array = recv.getByteArray(key); 
+               import Array[Int], Array[Int].add in "Java" `{
+               byte[] java_array = self.getByteArray(key);
                int nit_array = new_Array_of_Int();
-               
+
                if (java_array == null) return nit_array;
 
                for(int i=0; i < java_array.length; ++i)
                        Array_of_Int_add(nit_array, java_array[i]);
-                       
+
                return nit_array;
        `}
        fun get_short_array(key: JavaString): Array[Int]
-               import Array[Int], Array[Int].add in "Java" `{ 
-               short[] java_array = recv.getShortArray(key); 
+               import Array[Int], Array[Int].add in "Java" `{
+               short[] java_array = self.getShortArray(key);
                int nit_array = new_Array_of_Int();
-               
+
                if (java_array == null) return nit_array;
 
                for(int i=0; i < java_array.length; ++i)
                        Array_of_Int_add(nit_array, java_array[i]);
-                       
+
                return nit_array;
        `}
        # FIXME: Java's `char` are encoded on 16-bits whereas Nit's are on 8-bits.
        fun get_char_array(key: JavaString): Array[Char]
-               import Array[Char], Array[Char].add in "Java" `{ 
-               char[] java_array = recv.getCharArray(key); 
+               import Array[Char], Array[Char].add in "Java" `{
+               char[] java_array = self.getCharArray(key);
                int nit_array = new_Array_of_Char();
-               
+
                if (java_array == null) return nit_array;
 
                for(int i=0; i < java_array.length; ++i)
                        Array_of_Char_add(nit_array, java_array[i]);
-                       
+
                return nit_array;
        `}
        fun get_int_array(key: JavaString): Array[Int]
-               import Array[Int], Array[Int].add in "Java" `{ 
-               int[] java_array = recv.getIntArray(key); 
+               import Array[Int], Array[Int].add in "Java" `{
+               int[] java_array = self.getIntArray(key);
                int nit_array = new_Array_of_Int();
-               
+
                if (java_array == null) return nit_array;
 
                for(int i=0; i < java_array.length; ++i)
                        Array_of_Int_add(nit_array, java_array[i]);
-                       
+
                return nit_array;
        `}
        # FIXME: Get rid of the int cast as soon as the ffi is fixed
        fun get_long_array(key: JavaString): Array[Int]
-               import Array[Int], Array[Int].add in "Java" `{ 
-               long[] java_array = recv.getLongArray(key); 
+               import Array[Int], Array[Int].add in "Java" `{
+               long[] java_array = self.getLongArray(key);
                int nit_array = new_Array_of_Int();
-               
+
                if (java_array == null) return nit_array;
 
                for(int i=0; i < java_array.length; ++i)
                        Array_of_Int_add(nit_array, java_array[i]);
-                       
+
                return nit_array;
        `}
        fun get_float_array(key: JavaString): Array[Float]
-               import Array[Float], Array[Float].add in "Java" `{ 
-               float[] java_array = recv.getFloatArray(key); 
+               import Array[Float], Array[Float].add in "Java" `{
+               float[] java_array = self.getFloatArray(key);
                int nit_array = new_Array_of_Float();
-               
+
                if (java_array == null) return nit_array;
 
                for(int i=0; i < java_array.length; ++i)
                Array_of_Float_add(nit_array, (double) java_array[i]);
-                       
+
                return nit_array;
        `}
        fun get_double_array(key: JavaString): Array[Float]
-               import Array[Float], Array[Float].add in "Java" `{ 
-               double[] java_array = recv.getDoubleArray(key); 
+               import Array[Float], Array[Float].add in "Java" `{
+               double[] java_array = self.getDoubleArray(key);
                int nit_array = new_Array_of_Float();
-               
+
                if (java_array == null) return nit_array;
 
                for(int i=0; i < java_array.length; ++i)
                        Array_of_Float_add(nit_array, java_array[i]);
-                       
+
                return nit_array;
        `}
        fun get_string_array(key: JavaString): Array[String]
                import StringCopyArray, StringCopyArray.add, StringCopyArray.collection in "Java" `{
-               String[] java_array = recv.getStringArray(key); 
+               String[] java_array = self.getStringArray(key);
                int nit_array = new_StringCopyArray();
-               
+
                if (java_array == null) return nit_array;
 
                for(int i=0; i < java_array.length; ++i)
                        StringCopyArray_add(nit_array, java_array[i]);
-                       
+
                return StringCopyArray_collection(nit_array);
        `}
        fun get_char_sequence_array(key: JavaString): Array[String]
                import StringCopyArray, StringCopyArray.add, StringCopyArray.collection in "Java" `{
-               CharSequence[] java_array = recv.getCharSequenceArray(key); 
+               CharSequence[] java_array = self.getCharSequenceArray(key);
                int nit_array = new_StringCopyArray();
-               
+
                if (java_array == null) return nit_array;
 
                for(int i=0; i < java_array.length; ++i)
                        StringCopyArray_add(nit_array, (String)java_array[i]);
-                       
+
                return StringCopyArray_collection(nit_array);
        `}
-       fun describe_contents: Int in "Java" `{ return recv.describeContents(); `}
-       fun to_string: JavaString in "Java" `{ return recv.toString(); `}
+       fun describe_contents: Int in "Java" `{ return self.describeContents(); `}
+       fun to_string: JavaString in "Java" `{ return self.toString(); `}
 
        # HACK for bug #845
        redef fun new_global_ref import sys, Sys.jni_env `{
-               Sys sys = NativeBundle_sys(recv);
+               Sys sys = NativeBundle_sys(self);
                JNIEnv *env = Sys_jni_env(sys);
-               return (*env)->NewGlobalRef(env, recv);
+               return (*env)->NewGlobalRef(env, self);
        `}
 end
 
@@ -438,7 +438,7 @@ class Bundle
                sys.jni_env.pop_local_frame
                return return_value
        end
-               
+
        # Returns the number of entries in the current `Bundle`
        fun size: Int do return native_bundle.size
 
@@ -470,27 +470,27 @@ class Bundle
                return string_set
        end
 
-       # Add key-value information by dynamically choosing the appropriate 
+       # Add key-value information by dynamically choosing the appropriate
        # java method according to value type
-       # If there's already a value associated with this key, the new value 
+       # If there's already a value associated with this key, the new value
        # overwrites it
        #
        # To retrieve entries, you'll have to call the type corresponding method
-       # conforming to these rules :
+       # conforming to these rules:
        #
        # | Nit type              | corresponding getter            |
        # |:----------------------|:--------------------------------|
-       # ! `Int`                 | `long`                          |
+       # | `Int`                 | `long`                          |
        # | `Float`               | `double`                        |
        # | `Bool`                | `bool`                          |
        # | `Char`                | `char`                          |
-       # ! `String`              | `string`                        |
-       # ! `Serializable`        | `deserialize`                   |
-       # ! `Array[Int]`          | `array_of_long`                 |
-       # ! `Array[Float]`        | `array_of_double`               |
-       # ! `Array[Bool]`         | `array_of_bool`                 |
-       # ! `Array[Char]`         | `array_of_char`                 |
-       # ! `Array[String]`       | `array_of_string`               |
+       # | `String`              | `string`                        |
+       # | `Serializable`        | `deserialize`                   |
+       # | `Array[Int]`          | `array_of_long`                 |
+       # | `Array[Float]`        | `array_of_double`               |
+       # | `Array[Bool]`         | `array_of_bool`                 |
+       # | `Array[Char]`         | `array_of_char`                 |
+       # | `Array[String]`       | `array_of_string`               |
        # | `Array[Serializable]` | `deserialize_array`             |
        fun []=(key: String, value: Serializable): Bundle
        do
@@ -503,7 +503,7 @@ class Bundle
        # Retrieve an `Object` serialized via `[]=` function
        # Returns `null` if there's no serialized object corresponding to the given key
        # or if it's the wrong value type
-       # Make sure that the serialized object is `auto_serializable` or that it 
+       # Make sure that the serialized object is `auto_serializable` or that it
        # redefines the appropriate methods. Refer to `Serializable` documentation
        # for further details
        fun deserialize(key: String): nullable Object
@@ -520,7 +520,7 @@ class Bundle
        # Retrieve an `Array` of `Object` serialized via `[]=` function
        # Returns `null` if there's no serialized `Array` corresponding to the given key
        # or if it's the wrong value type
-       # Make sure that the serialized objects are `auto_serializable` or that they 
+       # Make sure that the serialized objects are `auto_serializable` or that they
        # redefine the appropriate methods. Refer to `Serializable` documentation
        # for further details
        fun deserialize_array(key: String): nullable Array[nullable Object]
@@ -557,7 +557,7 @@ class Bundle
        fun bool(key: String, def_value: Bool): Bool
        do
                sys.jni_env.push_local_frame(1)
-               var return_value = 
+               var return_value =
                        native_bundle.get_boolean_with_def_value(key.to_java_string, def_value)
                sys.jni_env.pop_local_frame
                return return_value
@@ -569,7 +569,7 @@ class Bundle
        fun char(key: String, def_value: Char): Char
        do
                sys.jni_env.push_local_frame(1)
-               var return_value = 
+               var return_value =
                        native_bundle.get_char_with_def_value(key.to_java_string, def_value)
                sys.jni_env.pop_local_frame
                return return_value
@@ -580,18 +580,18 @@ class Bundle
        fun int(key: String, def_value: Int): Int
        do
                sys.jni_env.push_local_frame(1)
-               var return_value = 
+               var return_value =
                        native_bundle.get_long_with_def_value(key.to_java_string, def_value)
                sys.jni_env.pop_local_frame
                return return_value
        end
-       
+
        # Retrieves the `Float` value corresponding to the given key
        # Returns the `def_value` if none or if it's the wrong value type
        fun float(key: String, def_value: Float): Float
        do
                sys.jni_env.push_local_frame(1)
-               var return_value = 
+               var return_value =
                        native_bundle.get_double_with_def_value(key.to_java_string, def_value)
                sys.jni_env.pop_local_frame
                return return_value
@@ -657,7 +657,7 @@ class Bundle
 
                var return_value = native_bundle.get_string_array(key.to_java_string)
                sys.jni_env.pop_local_frame
-               
+
                if return_value.is_empty then return null
 
                return return_value
@@ -728,7 +728,7 @@ redef class Array[E]
                        bundle.put_char_array(key, self)
                else if self isa Array[String] then
                        sys.jni_env.push_local_frame(self.length)
-                       var java_string_array = new Array[JavaString] 
+                       var java_string_array = new Array[JavaString]
 
                        for element in self do
                                java_string_array.push(element.to_s.to_java_string)
index 30ec5eb..b599a37 100644 (file)
@@ -46,25 +46,25 @@ extern class NativeHeadTracker in "Java" `{ com.google.vrtoolkit.cardboard.senso
        `}
 
        # Start tracking head movement
-       fun start_tracking in "Java" `{ recv.startTracking(); `}
+       fun start_tracking in "Java" `{ self.startTracking(); `}
 
        # Stop tracking head movement
-       fun stop_tracking in "Java" `{ recv.stopTracking(); `}
+       fun stop_tracking in "Java" `{ self.stopTracking(); `}
 
        # Apply correction to the gyroscope values
        fun gyro_bias=(matrix: JavaFloatArray) in "Java" `{
-               recv.setGyroBias(matrix);
+               self.setGyroBias(matrix);
        `}
 
        # Enable finer analysis using the neck as center of movement
        fun neck_model_enabled=(value: Bool) in "Java" `{
-               recv.setNeckModelEnabled(value);
+               self.setNeckModelEnabled(value);
        `}
 
        # Fill `matrix` with the last rotation matrix calculated from head movements
        #
        # Require: matrix.length >= offset + 16
        fun last_head_view(matrix: JavaFloatArray, offset: Int) in "Java" `{
-               recv.getLastHeadView(matrix, (int)offset);
+               self.getLastHeadView(matrix, (int)offset);
        `}
 end
index 48603dc..dc335dc 100644 (file)
@@ -55,7 +55,7 @@ redef class Sys
        end
 
        private fun find_class_loader(native_activity: NativeActivity) import jni_env, class_loader=, JavaObject.as nullable, class_loader_method=, JMethodID.as nullable `{
-               JNIEnv *env = Sys_jni_env(recv);
+               JNIEnv *env = Sys_jni_env(self);
 
                // Retrieve main activity
                jclass class_activity = (*env)->GetObjectClass(env, native_activity);
@@ -96,8 +96,8 @@ redef class Sys
                }
 
                // Return the values to Nit
-               Sys_class_loader__assign(recv, JavaObject_as_nullable((*env)->NewGlobalRef(env, instance_class_loader)));
-               Sys_class_loader_method__assign(recv, JMethodID_as_nullable(class_class_loader_findClass));
+               Sys_class_loader__assign(self, JavaObject_as_nullable((*env)->NewGlobalRef(env, instance_class_loader)));
+               Sys_class_loader_method__assign(self, JMethodID_as_nullable(class_class_loader_findClass));
 
                // Clean up
                (*env)->DeleteLocalRef(env, class_activity);
@@ -106,7 +106,7 @@ redef class Sys
        `}
 
        private fun load_jclass_intern(instance_class_loader: JavaObject, class_loader_findClass: JMethodID, name: NativeString): JClass import jni_env `{
-               JNIEnv *env = Sys_jni_env(recv);
+               JNIEnv *env = Sys_jni_env(self);
                jobject class_name = (*env)->NewStringUTF(env, name);
 
                jclass java_class = (*env)->CallObjectMethod(env, instance_class_loader, class_loader_findClass, class_name);
index 55f21a5..351040e 100644 (file)
@@ -54,31 +54,31 @@ in "C" `{
 private extern class NativeAndroidMotionEvent `{AInputEvent *`}
 
        fun pointers_count: Int `{
-               return AMotionEvent_getPointerCount(recv);
+               return AMotionEvent_getPointerCount(self);
        `}
 
        # Did this motion event just started?
        fun just_went_down: Bool `{
-               return (AMotionEvent_getAction(recv) & AMOTION_EVENT_ACTION_MASK) == AMOTION_EVENT_ACTION_DOWN;
+               return (AMotionEvent_getAction(self) & AMOTION_EVENT_ACTION_MASK) == AMOTION_EVENT_ACTION_DOWN;
        `}
 
        fun edge: Int `{
-               return AMotionEvent_getEdgeFlags(recv);
+               return AMotionEvent_getEdgeFlags(self);
        `}
 
        # Get the non-primary pointer id that just went down (returns -1 or > 0)
        fun index_down_pointer: Int `{
-               int a = AMotionEvent_getAction(recv);
+               int a = AMotionEvent_getAction(self);
                if ((a & AMOTION_EVENT_ACTION_MASK) == AMOTION_EVENT_ACTION_POINTER_DOWN)
                        return (a & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
                else return -1;
        `}
 
-       fun action: AMotionEventAction `{ return AMotionEvent_getAction(recv); `}
+       fun action: AMotionEventAction `{ return AMotionEvent_getAction(self); `}
 end
 
 private extern class AMotionEventAction `{ int32_t `}
-       fun action: Int `{ return recv & AMOTION_EVENT_ACTION_MASK; `}
+       fun action: Int `{ return self & AMOTION_EVENT_ACTION_MASK; `}
 
        fun is_down: Bool do return action == 0
        fun is_up: Bool do return action == 1
@@ -199,16 +199,16 @@ extern class AndroidKeyEvent `{AInputEvent *`}
        super KeyEvent
        super AndroidInputEvent
 
-       private fun action: Int `{ return AKeyEvent_getAction(recv); `}
+       private fun action: Int `{ return AKeyEvent_getAction(self); `}
 
        redef fun is_down: Bool do return action == 0
        redef fun is_up: Bool do return action == 1
 
        # Hardware code of the key raising this event
-       fun key_code: Int `{ return AKeyEvent_getKeyCode(recv); `}
+       fun key_code: Int `{ return AKeyEvent_getKeyCode(self); `}
 
        redef fun to_c `{
-               int code = AKeyEvent_getKeyCode(recv);
+               int code = AKeyEvent_getKeyCode(self);
                if (code >= AKEYCODE_0 && code <= AKEYCODE_9)
                        return '0'+code-AKEYCODE_0;
                if (code >= AKEYCODE_A && code <= AKEYCODE_Z)
index 5312c15..2d536fd 100644 (file)
@@ -36,15 +36,15 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
 
        new in "Java" `{ return new Intent(); `}
 
-       fun add_category(category: JavaString) in "Java" `{ recv.addCategory(category); `}
-       fun add_flags(flags: Int) in "Java" `{ recv.addFlags((int)flags); `}
+       fun add_category(category: JavaString) in "Java" `{ self.addCategory(category); `}
+       fun add_flags(flags: Int) in "Java" `{ self.addFlags((int)flags); `}
        fun filter_equals(other: NativeIntent): Bool in "Java" `{
-               return recv.filterEquals(other);
+               return self.filterEquals(other);
        `}
-       fun action: JavaString in "Java" `{ return recv.getAction(); `}
+       fun action: JavaString in "Java" `{ return self.getAction(); `}
        fun boolean_array_extra(name: JavaString): Array[Bool] import Array[Bool],
          Array[Bool].push in "Java" `{
-               boolean[] java_array = recv.getBooleanArrayExtra(name);
+               boolean[] java_array = self.getBooleanArrayExtra(name);
                int nit_array = new_Array_of_Bool();
 
                for(int i=0; i < java_array.length; ++i)
@@ -53,11 +53,11 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
                return nit_array;
        `}
        fun boolean_extra(name: JavaString, def_value: Bool): Bool in "Java" `{
-               return recv.getBooleanExtra(name, def_value);
+               return self.getBooleanExtra(name, def_value);
        `}
        fun byte_array_extra(name: JavaString): Array[Int] import Array[Int],
          Array[Int].add in "Java" `{
-               byte[] java_array = recv.getByteArrayExtra(name);
+               byte[] java_array = self.getByteArrayExtra(name);
                int nit_array = new_Array_of_Int();
 
                for (int i=0; i < java_array.length; ++i)
@@ -66,12 +66,12 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
                return nit_array;
        `}
        fun byte_extra(name: JavaString, def_value: Int): Int in "Java" `{
-               return (int) recv.getByteExtra(name, (byte) def_value);
+               return (int) self.getByteExtra(name, (byte) def_value);
        `}
        # FIXME: Java's `char` are encoded on 16-bits whereas Nit's are on 8-bits.
        fun char_array_extra(name: JavaString): Array[Char] import Array[Char],
          Array[Char].add in "Java" `{
-               char[] java_array = recv.getCharArrayExtra(name);
+               char[] java_array = self.getCharArrayExtra(name);
                int nit_array = new_Array_of_Char();
 
                for (int i = 0; i < java_array.length; ++i)
@@ -81,11 +81,11 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
        `}
        # FIXME: Java's `char` are encoded on 16-bits whereas Nit's are on 8-bits.
        fun char_extra(name: JavaString, def_value: Char): Char in "Java" `{
-               return recv.getCharExtra(name, def_value);
+               return self.getCharExtra(name, def_value);
        `}
        fun char_sequence_array_extra(name: JavaString): Array[String]
          import StringCopyArray, StringCopyArray.add, StringCopyArray.collection in "Java" `{
-               CharSequence[] java_array = recv.getCharSequenceArrayExtra(name);
+               CharSequence[] java_array = self.getCharSequenceArrayExtra(name);
                int nit_array = new_StringCopyArray();
 
                for (int i = 0; i < java_array.length; ++i)
@@ -95,7 +95,7 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
        `}
        fun char_sequence_array_list_extra(name: JavaString): Array[String]
          import StringCopyArray, StringCopyArray.add, StringCopyArray.collection in "Java" `{
-               ArrayList<CharSequence> java_array = recv.getCharSequenceArrayListExtra(name);
+               ArrayList<CharSequence> java_array = self.getCharSequenceArrayListExtra(name);
                int nit_array = new_StringCopyArray();
 
                if (java_array == null) return nit_array;
@@ -106,11 +106,11 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
                return StringCopyArray_collection(nit_array);
        `}
        fun char_sequence_extra(name: JavaString): JavaString in "Java" `{
-               return (String) recv.getCharSequenceExtra(name);
+               return (String) self.getCharSequenceExtra(name);
        `}
        fun categories: HashSet[String] import StringCopyHashSet,
          StringCopyHashSet.add, StringCopyHashSet.collection  in "Java" `{
-               Set<String> java_set = recv.getCategories();
+               Set<String> java_set = self.getCategories();
                int nit_hashset = new_StringCopyHashSet();
 
                if (java_set == null) return nit_hashset;
@@ -121,10 +121,10 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
                return StringCopyHashSet_collection(nit_hashset);
        `}
        # Returns the Uri as an encoded String
-       fun data: JavaString in "Java" `{ return recv.getDataString(); `}
+       fun data: JavaString in "Java" `{ return self.getDataString(); `}
        fun double_array_extra(name: JavaString): Array[Float] import Array[Float],
          Array[Float].push in "Java" `{
-               double[] java_array = recv.getDoubleArrayExtra(name);
+               double[] java_array = self.getDoubleArrayExtra(name);
                int nit_array = new_Array_of_Float();
 
                for(int i=0; i < java_array.length; ++i)
@@ -133,12 +133,12 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
                return nit_array;
        `}
        fun double_extra(name: JavaString, def_value: Float): Float in "Java" `{
-               return recv.getDoubleExtra(name, def_value);
+               return self.getDoubleExtra(name, def_value);
        `}
-       fun flags: Int in "Java" `{ return recv.getFlags(); `}
+       fun flags: Int in "Java" `{ return self.getFlags(); `}
        fun float_array_extra(name: JavaString): Array[Float] import Array[Float],
          Array[Float].push in "Java" `{
-               float[] java_array = recv.getFloatArrayExtra(name);
+               float[] java_array = self.getFloatArrayExtra(name);
                int nit_array = new_Array_of_Float();
 
                for(int i=0; i < java_array.length; ++i)
@@ -147,11 +147,11 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
                return nit_array;
        `}
        fun float_extra(name: JavaString, def_value: Float): Float in "Java" `{
-               return recv.getFloatExtra(name, (float) def_value);
+               return self.getFloatExtra(name, (float) def_value);
        `}
        fun int_array_extra(name: JavaString): Array[Int] import Array[Int],
          Array[Int].push in "Java" `{
-               int[] java_array = recv.getIntArrayExtra(name);
+               int[] java_array = self.getIntArrayExtra(name);
                int nit_array = new_Array_of_Int();
 
                for(int i=0; i < java_array.length; ++i)
@@ -160,11 +160,11 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
                return nit_array;
        `}
        fun int_extra(name: JavaString, def_value: Int): Int in "Java" `{
-               return recv.getIntExtra(name, (int)def_value);
+               return self.getIntExtra(name, (int)def_value);
        `}
        fun long_array_extra(name: JavaString): Array[Int] import Array[Int],
          Array[Int].push in "Java" `{
-               long[] java_array = recv.getLongArrayExtra(name);
+               long[] java_array = self.getLongArrayExtra(name);
                int nit_array = new_Array_of_Int();
 
                for(int i=0; i < java_array.length; ++i)
@@ -173,13 +173,13 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
                return nit_array;
        `}
        fun long_extra(name: JavaString, def_value: Int): Int in "Java" `{
-               return (int) recv.getLongExtra(name, def_value);
+               return (int) self.getLongExtra(name, def_value);
        `}
-       fun get_package: JavaString in "Java" `{ return recv.getPackage(); `}
-       fun scheme: JavaString in "Java" `{ return recv.getScheme(); `}
+       fun get_package: JavaString in "Java" `{ return self.getPackage(); `}
+       fun scheme: JavaString in "Java" `{ return self.getScheme(); `}
        fun short_array_extra(name: JavaString): Array[Int] import Array[Int],
          Array[Int].push in "Java" `{
-               short[] java_array = recv.getShortArrayExtra(name);
+               short[] java_array = self.getShortArrayExtra(name);
                int nit_array = new_Array_of_Int();
 
                for(int i=0; i < java_array.length; ++i)
@@ -188,11 +188,11 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
                return nit_array;
        `}
        fun short_extra(name: JavaString, def_value: Int): Int in "Java" `{
-               return recv.getShortExtra(name, (short) def_value);
+               return self.getShortExtra(name, (short) def_value);
        `}
        fun string_array_extra(name: JavaString): Array[String]
          import StringCopyArray, StringCopyArray.add, StringCopyArray.collection in "Java" `{
-               String[] java_array = recv.getStringArrayExtra(name);
+               String[] java_array = self.getStringArrayExtra(name);
                int nit_array = new_StringCopyArray();
 
                for(int i=0; i < java_array.length; ++i)
@@ -202,7 +202,7 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
        `}
        fun string_array_list_extra(name: JavaString): Array[String]
          import StringCopyArray, StringCopyArray.add, StringCopyArray.collection in "Java" `{
-               ArrayList<String> java_array = recv.getStringArrayListExtra(name);
+               ArrayList<String> java_array = self.getStringArrayListExtra(name);
                int nit_array = new_StringCopyArray();
 
                for (String element: java_array)
@@ -211,19 +211,19 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
                return StringCopyArray_collection(nit_array);
        `}
        fun string_extra(name: JavaString): JavaString in "Java" `{
-               String return_value = recv.getStringExtra(name);
+               String return_value = self.getStringExtra(name);
                if (return_value == null) return "";
 
                return return_value;
        `}
-       fun get_type: JavaString in "Java" `{ return recv.getType(); `}
+       fun get_type: JavaString in "Java" `{ return self.getType(); `}
        fun has_category(category: JavaString): Bool in "Java" `{
-               return recv.hasCategory(category);
+               return self.hasCategory(category);
        `}
-       fun has_extra(extra: JavaString): Bool in "Java" `{ return recv.hasExtra(extra); `}
-       fun has_file_descriptors: Bool in "Java" `{ return recv.hasFileDescriptors(); `}
+       fun has_extra(extra: JavaString): Bool in "Java" `{ return self.hasExtra(extra); `}
+       fun has_file_descriptors: Bool in "Java" `{ return self.hasFileDescriptors(); `}
        fun add_extra_double(name: JavaString, value: Float): NativeIntent in "Java" `{
-               return recv.putExtra(name, value);
+               return self.putExtra(name, value);
        `}
        fun add_extra_array_of_double(name: JavaString, value: Array[Float]): NativeIntent
          import Array[Float].length, Array[Float].[] in "Java" `{
@@ -232,11 +232,11 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
                for (int i=0; i < java_array.length; ++i)
                        java_array[i] = Array_of_Float__index(value, i);
 
-               return recv.putExtra(name, java_array);
+               return self.putExtra(name, java_array);
        `}
        # FIXME: Java's `char` are encoded on 16-bits whereas Nit's are on 8-bits.
        fun add_extra_char(name: JavaString, value: Char): NativeIntent in "Java" `{
-               return recv.putExtra(name, value);
+               return self.putExtra(name, value);
        `}
        # FIXME: Java's `char` are encoded on 16-bits whereas Nit's are on 8-bits.
        fun add_extra_array_of_char(name: JavaString, value: Array[Char]): NativeIntent
@@ -246,11 +246,11 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
                for (int i=0; i < java_array.length; ++i)
                        java_array[i] = Array_of_Char__index(value, i);
 
-               return recv.putExtra(name, java_array);
+               return self.putExtra(name, java_array);
        `}
        fun add_extra_char_sequence(name: JavaString, value: JavaString): NativeIntent
          in "Java" `{
-               return recv.putExtra(name, value);
+               return self.putExtra(name, value);
        `}
        fun add_extra_array_of_char_sequence(name: JavaString, value: Array[JavaString]):
          NativeIntent import Array[JavaString].length, Array[JavaString].[] in "Java" `{
@@ -259,14 +259,14 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
                for (int i=0; i < java_array.length; ++i)
                        java_array[i] = Array_of_JavaString__index(value, i);
 
-               return recv.putExtra(name, java_array);
+               return self.putExtra(name, java_array);
        `}
        fun add_extra_bundle(name: JavaString, value: NativeBundle): NativeIntent
          in "Java" `{
-               return recv.putExtra(name, value);
+               return self.putExtra(name, value);
        `}
        fun add_extra_int(name: JavaString, value: Int): NativeIntent in "Java" `{
-               return recv.putExtra(name, value);
+               return self.putExtra(name, value);
        `}
        fun add_extra_array_of_int(name: JavaString, value: Array[Int]): NativeIntent
          import Array[Int].length, Array[Int].[] in "Java" `{
@@ -275,7 +275,7 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
                for (int i=0; i < java_array.length; ++i)
                        java_array[i] = (int)Array_of_Int__index(value, i);
 
-               return recv.putExtra(name, java_array);
+               return self.putExtra(name, java_array);
        `}
        fun add_extra_array_list_of_int(name: JavaString, value: Array[Int]): NativeIntent
          import Array[Int].length, Array[Int].[] in "Java" `{
@@ -285,16 +285,16 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
                for (int i=0; i < length; ++i)
                        java_array.add((int)Array_of_Int__index(value, i));
 
-               return recv.putExtra(name, java_array);
+               return self.putExtra(name, java_array);
        `}
        fun add_extra_byte(name: JavaString, value: Int): NativeIntent in "Java" `{
-               return recv.putExtra(name, (byte) value);
+               return self.putExtra(name, (byte) value);
        `}
        fun add_extra_array_of_byte(name: JavaString, value: Int): NativeIntent in "Java" `{
-               return recv.putExtra(name, (byte) value);
+               return self.putExtra(name, (byte) value);
        `}
        fun add_extra_long(name: JavaString, value: Int): NativeIntent in "Java" `{
-               return recv.putExtra(name, value);
+               return self.putExtra(name, value);
        `}
        fun add_extra_array_of_long(name: JavaString, value: Array[Int]): NativeIntent
          import Array[Int].length, Array[Int].[] in "Java" `{
@@ -303,10 +303,10 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
                for (int i=0; i < java_array.length; ++i)
                        java_array[i] = Array_of_Int__index(value, i);
 
-               return recv.putExtra(name, java_array);
+               return self.putExtra(name, java_array);
        `}
        fun add_extra_float(name: JavaString, value: Float): NativeIntent in "Java" `{
-               return recv.putExtra(name, value);
+               return self.putExtra(name, value);
        `}
        fun add_extra_array_of_float(name: JavaString, value: Array[Float]): NativeIntent
          import Array[Float].length, Array[Float].[] in "Java" `{
@@ -315,10 +315,10 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
                for (int i=0; i < java_array.length; ++i)
                        java_array[i] = (float) Array_of_Float__index(value, i);
 
-               return recv.putExtra(name, java_array);
+               return self.putExtra(name, java_array);
        `}
        fun add_extra_string(name: JavaString, value: JavaString): NativeIntent in "Java" `{
-               return recv.putExtra(name, value);
+               return self.putExtra(name, value);
        `}
        fun add_extra_array_of_string(name: JavaString, value: Array[JavaString]): NativeIntent
          import Array[JavaString].length, Array[JavaString].[] in "Java" `{
@@ -327,7 +327,7 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
                for (int i=0; i < java_array.length; ++i)
                        java_array[i] = Array_of_JavaString__index(value, i);
 
-               return recv.putExtra(name, java_array);
+               return self.putExtra(name, java_array);
        `}
        fun add_extra_array_list_of_string(name: JavaString, value: Array[JavaString]): NativeIntent
          import Array[JavaString].length, Array[JavaString].[] in "Java" `{
@@ -338,10 +338,10 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
                        java_array.add(Array_of_JavaString__index(value, i));
                }
 
-               return recv.putExtra(name, java_array);
+               return self.putExtra(name, java_array);
        `}
        fun add_extra_bool(name: JavaString, value: Bool): NativeIntent in "Java" `{
-               return recv.putExtra(name, value);
+               return self.putExtra(name, value);
        `}
        fun add_extra_array_of_bool(name: JavaString, value: Array[Bool]): NativeIntent
          import Array[Bool].length, Array[Bool].[] in "Java" `{
@@ -350,10 +350,10 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
                for (int i=0; i < java_array.length; ++i)
                        java_array[i] = Array_of_Bool__index(value, i);
 
-               return recv.putExtra(name, java_array);
+               return self.putExtra(name, java_array);
        `}
        fun add_extra_short(name: JavaString, value: Int): NativeIntent in "Java" `{
-               return recv.putExtra(name, value);
+               return self.putExtra(name, value);
        `}
        fun add_extra_array_of_short(name: JavaString, value: Array[Int]): NativeIntent
          import Array[Int].length, Array[Int].[] in "Java" `{
@@ -362,22 +362,22 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
                for (int i=0; i < java_array.length; ++i)
                        java_array[i] = (short) Array_of_Int__index(value, i);
 
-               return recv.putExtra(name, java_array);
+               return self.putExtra(name, java_array);
        `}
-       fun copy_extras(src: NativeIntent): NativeIntent in "Java" `{ return recv.putExtras(src); `}
-       fun add_extras(src: NativeBundle): NativeIntent in "Java" `{ return recv.putExtras(src); `}
-       fun remove_category(category: JavaString) in "Java" `{ recv.removeCategory(category); `}
-       fun remove_extra(name: JavaString) in "Java" `{ recv.removeExtra(name); `}
+       fun copy_extras(src: NativeIntent): NativeIntent in "Java" `{ return self.putExtras(src); `}
+       fun add_extras(src: NativeBundle): NativeIntent in "Java" `{ return self.putExtras(src); `}
+       fun remove_category(category: JavaString) in "Java" `{ self.removeCategory(category); `}
+       fun remove_extra(name: JavaString) in "Java" `{ self.removeExtra(name); `}
        fun replace_extras(src: NativeIntent): NativeIntent in "Java" `{
-               return recv.replaceExtras(src);
+               return self.replaceExtras(src);
        `}
        fun resolve_activity(pm: NativePackageManager): NativeComponentName in "Java" `{
-               return recv.resolveActivity(pm);
+               return self.resolveActivity(pm);
        `}
        fun resolve_type(context: NativeActivity): JavaString in "Java" `{
-               return recv.resolveType(context);
+               return self.resolveType(context);
        `}
-       fun action=(action: JavaString): NativeIntent in "Java" `{ return recv.setAction(action); `}
+       fun action=(action: JavaString): NativeIntent in "Java" `{ return self.setAction(action); `}
        fun class_=(package_context: NativeActivity, class_name: JavaString): NativeIntent
          in "Java" `{
                Class<?> java_class = null;
@@ -386,40 +386,40 @@ extern class NativeIntent in "Java" `{ android.content.Intent `}
                } catch (Exception e) {
                        e.getStackTrace();
                }
-               return recv.setClass(package_context, java_class);
+               return self.setClass(package_context, java_class);
        `}
        fun class_name=(package_context: NativeActivity, class_name: JavaString): NativeIntent
          in "Java" `{
-               return recv.setClassName(package_context, class_name);
+               return self.setClassName(package_context, class_name);
        `}
        fun set_class_name(package_name: JavaString, class_name: JavaString): NativeIntent
          in "Java" `{
-               return recv.setClassName(package_name, class_name);
+               return self.setClassName(package_name, class_name);
        `}
        fun data=(data_uri: JavaString): NativeIntent in "Java" `{
-               return recv.setData(Uri.parse(data_uri));
+               return self.setData(Uri.parse(data_uri));
        `}
        fun data_and_type=(data_uri: JavaString, type_: JavaString): NativeIntent in "Java" `{
-               return recv.setDataAndType(Uri.parse(data_uri), type_);
+               return self.setDataAndType(Uri.parse(data_uri), type_);
        `}
-       fun flags=(flags: Int): NativeIntent in "Java" `{ return recv.setFlags((int)flags); `}
+       fun flags=(flags: Int): NativeIntent in "Java" `{ return self.setFlags((int)flags); `}
        fun package_name=(package_name: JavaString): NativeIntent in "Java" `{
-               return recv.setPackage(package_name);
+               return self.setPackage(package_name);
        `}
        fun source_bounds=(left, top, right, bottom: Int) in "Java" `{
-               recv.setSourceBounds(new Rect((int)left, (int)top, (int)right, (int)bottom));
+               self.setSourceBounds(new Rect((int)left, (int)top, (int)right, (int)bottom));
        `}
        fun mime_type=(mime_type: JavaString): NativeIntent in "Java" `{
-               return recv.setType(mime_type);
+               return self.setType(mime_type);
        `}
-       fun to_native_s: JavaString in "Java" `{ return recv.toString(); `}
-       fun to_uri(flags: Int): JavaString in "Java" `{ return recv.toUri((int)flags); `}
+       fun to_native_s: JavaString in "Java" `{ return self.toString(); `}
+       fun to_uri(flags: Int): JavaString in "Java" `{ return self.toUri((int)flags); `}
 
        # HACK for bug #845
        redef fun new_global_ref import sys, Sys.jni_env `{
-               Sys sys = NativeIntent_sys(recv);
+               Sys sys = NativeIntent_sys(self);
                JNIEnv *env = Sys_jni_env(sys);
-               return (*env)->NewGlobalRef(env, recv);
+               return (*env)->NewGlobalRef(env, self);
        `}
 end
 
@@ -1306,9 +1306,9 @@ class Intent
 end
 
 redef extern class NativeActivity
-       private fun start_activity(intent: NativeIntent) in "Java" `{ recv.startActivity(intent); `}
-       private fun start_service(intent: NativeIntent) in "Java" `{ recv.startService(intent); `}
-       private fun stop_service(intent: NativeIntent) in "Java" `{ recv.stopService(intent); `}
+       private fun start_activity(intent: NativeIntent) in "Java" `{ self.startActivity(intent); `}
+       private fun start_service(intent: NativeIntent) in "Java" `{ self.startService(intent); `}
+       private fun stop_service(intent: NativeIntent) in "Java" `{ self.stopService(intent); `}
 end
 
 # Allows user to get values with enum-like syntax : `intent_action.main`
index cab60aa..f948e3d 100644 (file)
@@ -24,7 +24,7 @@ in "Java" `{
 `}
 
 redef extern class NativeIntent
-       fun selector=(selector: NativeIntent) in "Java" `{ recv.setSelector(selector); `}
+       fun selector=(selector: NativeIntent) in "Java" `{ self.setSelector(selector); `}
 end
 
 redef class Category
index 1513ab8..f63359c 100644 (file)
@@ -25,9 +25,9 @@ in "Java" `{
 `}
 
 redef extern class NativeIntent
-       fun set_data_and_normalize(data_uri: JavaString): NativeIntent in "Java" `{ return recv.setDataAndNormalize(Uri.parse(data_uri)); `}
-       fun set_data_and_type_and_normalize(data_uri: JavaString, type_: JavaString): NativeIntent in "Java" `{ return recv.setDataAndTypeAndNormalize(Uri.parse(data_uri), type_); `}
-       fun set_mime_type_and_normalize(mime_type: JavaString): NativeIntent in "Java" `{ return recv.setTypeAndNormalize(mime_type); `}
+       fun set_data_and_normalize(data_uri: JavaString): NativeIntent in "Java" `{ return self.setDataAndNormalize(Uri.parse(data_uri)); `}
+       fun set_data_and_type_and_normalize(data_uri: JavaString, type_: JavaString): NativeIntent in "Java" `{ return self.setDataAndTypeAndNormalize(Uri.parse(data_uri), type_); `}
+       fun set_mime_type_and_normalize(mime_type: JavaString): NativeIntent in "Java" `{ return self.setTypeAndNormalize(mime_type); `}
 end
 
 redef class Extra
index 826eef2..2202827 100644 (file)
@@ -221,7 +221,7 @@ redef class App
                int event;
                void* source;
                while ((ident=ALooper_pollAll(timeout_ms, NULL, &event, &source)) >= 0) {
-                       App_handle_looper_event(recv, ident, event, source);
+                       App_handle_looper_event(self, ident, event, source);
                }
        `}
 
@@ -231,7 +231,7 @@ redef class App
                destroy, start, resume, low_memory, config_changed, input_changed,
                window_resized, window_redraw_needed, content_rect_changed `{
 
-               struct android_app *app_glue = App_native_app_glue(recv);
+               struct android_app *app_glue = App_native_app_glue(self);
                struct android_poll_source* source = (struct android_poll_source*)data;
 
                // Process this event.
@@ -251,33 +251,33 @@ extern class NdkNativeActivity `{ ANativeActivity * `}
        #fun set_callbacks_handler(handler: App) or callbacks= ...
 
        # Java VM associated to `self`
-       fun vm: JavaVM `{ return recv->vm; `}
+       fun vm: JavaVM `{ return self->vm; `}
 
        # JNI environmnet associated to `self`
-       fun env: JniEnv `{ return recv->env; `}
+       fun env: JniEnv `{ return self->env; `}
 
        # The `NativeActivity`, as in the Java object, associated to `self`
-       fun java_native_activity: NativeActivity `{ return recv->clazz; `}
+       fun java_native_activity: NativeActivity `{ return self->clazz; `}
 
        # Path to this application's internal data directory.
-       fun internal_data_path: NativeString `{ return (char*)recv->internalDataPath; `}
+       fun internal_data_path: NativeString `{ return (char*)self->internalDataPath; `}
 
        # Path to this application's external (removable/mountable) data directory.
-       fun external_data_path: NativeString `{ return (char*)recv->externalDataPath; `}
+       fun external_data_path: NativeString `{ return (char*)self->externalDataPath; `}
 
        # The platform's SDK version code.
-       fun sdk_version: Int `{ return recv->sdkVersion; `}
+       fun sdk_version: Int `{ return self->sdkVersion; `}
 
        # This is the native instance of the application.  It is not used by
        # the framework, but can be set by the application to its own instance
        # state.
-       fun instance: Pointer `{ return recv->instance; `}
+       fun instance: Pointer `{ return self->instance; `}
 
        # Pointer to the Asset Manager instance for the application.  The application
        # uses this to access binary assets bundled inside its own .apk file.
        #
        # TODO activate in a future `asset_manager` module if it cannot be done in Java
-       #fun asset_manager: AssetManager `{ return recv->assetManager; `}
+       #fun asset_manager: AssetManager `{ return self->assetManager; `}
 
        # Available starting with Honeycomb: path to the directory containing
        # the application's OBB files (if any).  If the app doesn't have any
@@ -285,7 +285,7 @@ extern class NdkNativeActivity `{ ANativeActivity * `}
        # api?
        #
        # TODO activate in a future module at API 11
-       #fun obb_path: NativeString `{ return (char*)recv->obbPath; `}
+       #fun obb_path: NativeString `{ return (char*)self->obbPath; `}
 end
 
 # This is the interface for the standard glue code of a threaded
@@ -297,10 +297,10 @@ end
 extern class NativeAppGlue `{ struct android_app* `}
        # We use the `userData` field of the C structure to store an handle to
        # the associated App
-       private fun user_data: App `{ return recv->userData; `}
+       private fun user_data: App `{ return self->userData; `}
        private fun user_data=(val: App) `{
                App_incr_ref(val);
-               recv->userData = val;
+               self->userData = val;
        `}
 
        # Fill this in with the function to process input events.  At this point
@@ -311,10 +311,10 @@ extern class NativeAppGlue `{ struct android_app* `}
        #fun set_input_event_handler(handler: App) `{  `}
 
        # The ANativeActivity object instance that this app is running in.
-       fun ndk_native_activity: NdkNativeActivity `{ return recv->activity; `}
+       fun ndk_native_activity: NdkNativeActivity `{ return self->activity; `}
 
        # The current configuration the app is running in.
-       fun config: AConfiguration `{ return recv->config; `}
+       fun config: AConfiguration `{ return self->config; `}
 
        # This is the last instance's saved state, as provided at creation time.
        # It is NULL if there was no state.  You can use this as you need; the
@@ -324,32 +324,32 @@ extern class NativeAppGlue `{ struct android_app* `}
        # at which point they will be initialized to NULL and you can malloc your
        # state and place the information here.  In that case the memory will be
        # freed for you later.
-       fun saved_state: Pointer `{ return recv->savedState; `}
-       fun saved_state_size: Int `{ return recv->savedStateSize; `}
+       fun saved_state: Pointer `{ return self->savedState; `}
+       fun saved_state_size: Int `{ return self->savedStateSize; `}
 
        # The ALooper associated with the app's thread.
-       fun looper: ALooper `{ return recv->looper; `}
+       fun looper: ALooper `{ return self->looper; `}
 
        # When non-NULL, this is the input queue from which the app will
        # receive user input events.
-       fun input_queue: AInputQueue `{ return recv->inputQueue; `}
+       fun input_queue: AInputQueue `{ return self->inputQueue; `}
 
        # When non-NULL, this is the window surface that the app can draw in.
-       fun window: ANativeWindow `{ return recv->window; `}
+       fun window: ANativeWindow `{ return self->window; `}
 
        # Current content rectangle of the window; this is the area where the
        # window's content should be placed to be seen by the user.
        #
        # TODO activate when we know what to return (returns a struct not a pointer)
-       #fun content_recv: ARect `{ return recv->contentRect; `}
+       #fun content_self: ARect `{ return self->contentRect; `}
 
        # Current state of the app's activity.  May be either APP_CMD_START,
        # APP_CMD_RESUME, APP_CMD_PAUSE, or APP_CMD_STOP; see below.
-       fun activity_state: Int `{ return recv->activityState; `}
+       fun activity_state: Int `{ return self->activityState; `}
 
        # This is non-zero when the application's NativeActivity is being
        # destroyed and waiting for the app thread to complete.
-       fun detroy_request: Bool `{ return recv->destroyRequested; `}
+       fun detroy_request: Bool `{ return self->destroyRequested; `}
 end
 
 # Android NDK's struture holding configurations of the native app
index d41e04c..87d9d22 100644 (file)
@@ -159,8 +159,8 @@ redef class App
        Activity.on_start, Activity.on_restart, Activity.on_stop,
        Activity.on_pause, Activity.on_resume,
        Activity.on_save_instance_state, Activity.on_restore_instance_state `{
-               App_incr_ref(recv);
-               global_app = recv;
+               App_incr_ref(self);
+               global_app = self;
        `}
 
        # Create the Nit side to this new `native` Java activity, and return it to Java
index 82c873f..8de56eb 100644 (file)
@@ -27,19 +27,19 @@ in "Java" `{
 
 redef class NativeActivity
        fun notification_manager: NativeNotificationManager in "Java" `{
-               return (NotificationManager)recv.getSystemService(Context.NOTIFICATION_SERVICE);
+               return (NotificationManager)self.getSystemService(Context.NOTIFICATION_SERVICE);
        `}
 end
 
 extern class NativeNotificationManager in "Java" `{ android.app.NotificationManager `}
 
        fun notify(tag: JavaString, id: Int, notif: NativeNotification) in "Java" `{
-               recv.notify(tag, (int)id, notif);
+               self.notify(tag, (int)id, notif);
        `}
 
-       fun cancel(tag: JavaString, id: Int) in "Java" `{ recv.cancel(tag, (int)id); `}
+       fun cancel(tag: JavaString, id: Int) in "Java" `{ self.cancel(tag, (int)id); `}
 
-       fun cancel_all in "Java" `{ recv.cancelAll(); `}
+       fun cancel_all in "Java" `{ self.cancelAll(); `}
 end
 
 extern class NativeNotification in "Java" `{ android.app.Notification `}
@@ -52,20 +52,20 @@ extern class NativeNotificationBuilder in "Java" `{ android.app.Notification$Bui
        fun create: NativeNotification in "Java" `{
                // Deprecated since API 16, which introduces `build`,
                // refinement and global compilation should prevent warnings.
-               return recv.getNotification();
+               return self.getNotification();
        `}
 
-       fun title=(value: JavaString) in "Java" `{ recv.setContentTitle(value); `}
+       fun title=(value: JavaString) in "Java" `{ self.setContentTitle(value); `}
 
-       fun text=(value: JavaString) in "Java" `{ recv.setContentText(value); `}
+       fun text=(value: JavaString) in "Java" `{ self.setContentText(value); `}
 
-       fun ticker=(value: JavaString) in "Java" `{ recv.setTicker(value); `}
+       fun ticker=(value: JavaString) in "Java" `{ self.setTicker(value); `}
 
-       fun small_icon=(value: Int) in "Java" `{ recv.setSmallIcon((int)value); `}
+       fun small_icon=(value: Int) in "Java" `{ self.setSmallIcon((int)value); `}
 
-       fun auto_cancel=(value: Bool) in "Java" `{ recv.setAutoCancel(value); `}
+       fun auto_cancel=(value: Bool) in "Java" `{ self.setAutoCancel(value); `}
 
-       fun number=(value: Int) in "Java" `{ recv.setNumber((int)value); `}
+       fun number=(value: Int) in "Java" `{ self.setNumber((int)value); `}
 
-       fun ongoing=(value: Bool) in "Java" `{ recv.setOngoing(value); `}
+       fun ongoing=(value: Bool) in "Java" `{ self.setOngoing(value); `}
 end
index a38dd60..3ee9765 100644 (file)
@@ -45,15 +45,15 @@ in "C header" `{
 
 extern class ASensorType `{int`}
        new accelerometer: ASensorType `{return ASENSOR_TYPE_ACCELEROMETER;`}
-       fun is_accelerometer: Bool `{return recv == ASENSOR_TYPE_ACCELEROMETER;`}
+       fun is_accelerometer: Bool `{return self == ASENSOR_TYPE_ACCELEROMETER;`}
        new magnetic_field: ASensorType `{return ASENSOR_TYPE_MAGNETIC_FIELD;`}
-       fun is_magnetic_field: Bool `{return recv == ASENSOR_TYPE_MAGNETIC_FIELD;`}
+       fun is_magnetic_field: Bool `{return self == ASENSOR_TYPE_MAGNETIC_FIELD;`}
        new gyroscope:ASensorType `{return ASENSOR_TYPE_GYROSCOPE;`}
-       fun is_gyroscope: Bool `{ return recv == ASENSOR_TYPE_GYROSCOPE;`}
+       fun is_gyroscope: Bool `{ return self == ASENSOR_TYPE_GYROSCOPE;`}
        new light: ASensorType `{return ASENSOR_TYPE_LIGHT;`}
-       fun is_light: Bool `{return recv == ASENSOR_TYPE_LIGHT;`}
+       fun is_light: Bool `{return self == ASENSOR_TYPE_LIGHT;`}
        new proximity: ASensorType `{return ASENSOR_TYPE_PROXIMITY;`}
-       fun is_proximity:Bool `{return recv == ASENSOR_TYPE_PROXIMITY;`}
+       fun is_proximity:Bool `{return self == ASENSOR_TYPE_PROXIMITY;`}
 end
 
 # Manages the sensors
@@ -64,23 +64,23 @@ extern class ASensorManager `{ASensorManager*`}
        # Returns the list of available sensors
        fun get_sensor_list: Pointer `{
                ASensorList *list;
-               ASensorManager_getSensorList(recv, list);
+               ASensorManager_getSensorList(self, list);
                return list;
        `}
 
        # Create a new sensor event queue and associate it with a looper
        fun create_event_queue(app: NativeAppGlue): ASensorEventQueue `{
-               return ASensorManager_createEventQueue(recv, app->looper, LOOPER_ID_USER, NULL, NULL);
+               return ASensorManager_createEventQueue(self, app->looper, LOOPER_ID_USER, NULL, NULL);
        `}
 
        # Returns the default sensor of the given type
        fun get_default_sensor(sensortype: ASensorType): ASensor `{
-               return ASensorManager_getDefaultSensor(recv, sensortype);
+               return ASensorManager_getDefaultSensor(self, sensortype);
        `}
 
        # Destroys the event queue and free all resources associated to it
        fun destroy_event_queue(queue: ASensorEventQueue) `{
-               ASensorManager_destroyEventQueue(recv, queue);
+               ASensorManager_destroyEventQueue(self, queue);
        `}
 end
 
@@ -89,29 +89,29 @@ extern class ASensorEventQueue `{ASensorEventQueue*`}
 
        # Enable the selected sensor, returns a negative value on error
        fun enable_sensor(sensor: ASensor): Int `{
-               return ASensorEventQueue_enableSensor(recv, sensor);
+               return ASensorEventQueue_enableSensor(self, sensor);
        `}
 
        # Disable the selected sensor, returns a negative value on error
        fun disable_sensor(sensor: ASensor): Int `{
-               return ASensorEventQueue_disableSensor(recv, sensor);
+               return ASensorEventQueue_disableSensor(self, sensor);
        `}
 
        # Set the delivery rate of events in microseconds for the given sensor
        fun set_event_rate(sensor: ASensor, usec: Int): Int `{
-               return ASensorEventQueue_setEventRate(recv, sensor, usec);
+               return ASensorEventQueue_setEventRate(self, sensor, usec);
        `}
        # Returns 1 if the queue has events, 0 if it does not have events,
        # and a negative value if there is an error
        fun has_events: Int `{
-               return ASensorEventQueue_hasEvents(recv);
+               return ASensorEventQueue_hasEvents(self);
        `}
 
        # Returns the next available events from the queue.
        # Returns a negative value if no events are available or an error has occured
        # otherwise the number of events returned
        fun get_events(events: ASensorEvents, count: Int): Int `{
-               return ASensorEventQueue_getEvents(recv, events, (size_t)count);
+               return ASensorEventQueue_getEvents(self, events, (size_t)count);
        `}
 end
 
@@ -119,11 +119,11 @@ end
 extern class ASensor `{ASensorRef`}
 
        new  `{return malloc(sizeof(ASensorRef));`}
-       fun name: NativeString `{return (char*)ASensor_getName(recv);`}
-       fun vendor: NativeString `{return (char*)ASensor_getVendor(recv);`}
-       fun sensor_type: ASensorType `{return ASensor_getType(recv);`}
-       fun resolution: Float `{return ASensor_getResolution(recv);`}
-       fun min_delay: Int `{return ASensor_getMinDelay(recv);`}
+       fun name: NativeString `{return (char*)ASensor_getName(self);`}
+       fun vendor: NativeString `{return (char*)ASensor_getVendor(self);`}
+       fun sensor_type: ASensorType `{return ASensor_getType(self);`}
+       fun resolution: Float `{return ASensor_getResolution(self);`}
+       fun min_delay: Int `{return ASensor_getMinDelay(self);`}
 end
 
 # NIT representation of an Android Sensor used in android_app to initialize sensors
@@ -144,77 +144,77 @@ end
 extern class ASensorEvent `{ASensorEvent*`}
                super SensorEvent
 
-       fun version: Int `{return recv->version;`}
-       fun sensor: ASensor `{return (ASensorRef)recv->sensor;`}
-       fun sensor_type: ASensorType `{return recv->type;`}
-       fun timestamp: Int `{return recv->timestamp;`}
+       fun version: Int `{return self->version;`}
+       fun sensor: ASensor `{return (ASensorRef)self->sensor;`}
+       fun sensor_type: ASensorType `{return self->type;`}
+       fun timestamp: Int `{return self->timestamp;`}
 end
 
 extern class FullSensor `{ASensorEvent*`}
                super ASensorLight
                super ASensorProximity
 
-       fun temperature: Float `{return recv->temperature;`}
-       fun pressure: Float `{return recv->pressure;`}
-       fun data: Pointer `{return recv->data;`}
-       fun vector: ASensorVector `{return &(recv->vector);`}
-       fun acceleration: ASensorVector `{return &(recv->acceleration);`}
-       fun magnetic: ASensorVector `{return &(recv->magnetic);`}
+       fun temperature: Float `{return self->temperature;`}
+       fun pressure: Float `{return self->pressure;`}
+       fun data: Pointer `{return self->data;`}
+       fun vector: ASensorVector `{return &(self->vector);`}
+       fun acceleration: ASensorVector `{return &(self->acceleration);`}
+       fun magnetic: ASensorVector `{return &(self->magnetic);`}
 end
 
 # Extern class referencing a ASensorVector, attribute of ASensorRef
 extern class ASensorVector `{ASensorVector*`}
 
-       fun v: Pointer `{return recv->v;`}
-       fun x: Float `{ return recv->x;`}
-       fun y: Float `{return recv->y;`}
-       fun z: Float `{return recv->z;`}
-       fun azimuth: Float `{return recv->azimuth;`}
-       fun pitch: Float `{return recv->pitch;`}
-       fun roll: Float `{return recv->roll;`}
-       fun status: Int `{return recv->status;`}
-       fun reserved: Pointer `{return recv->reserved;`}
+       fun v: Pointer `{return self->v;`}
+       fun x: Float `{ return self->x;`}
+       fun y: Float `{return self->y;`}
+       fun z: Float `{return self->z;`}
+       fun azimuth: Float `{return self->azimuth;`}
+       fun pitch: Float `{return self->pitch;`}
+       fun roll: Float `{return self->roll;`}
+       fun status: Int `{return self->status;`}
+       fun reserved: Pointer `{return self->reserved;`}
 end
 
 # Sensor event returned by the Accelerometer sensor
 extern class ASensorAccelerometer `{ASensorEvent*`}
        super ASensorEvent
 
-       fun x: Float `{return recv->acceleration.x;`}
-       fun y: Float `{return recv->acceleration.y;`}
-       fun z: Float `{return recv->acceleration.z;`}
+       fun x: Float `{return self->acceleration.x;`}
+       fun y: Float `{return self->acceleration.y;`}
+       fun z: Float `{return self->acceleration.z;`}
 end
 
 # Sensor event returned by the Magnetic Field sensor
 extern class ASensorMagneticField `{ASensorEvent*`}
        super ASensorEvent
 
-       fun x: Float `{return recv->magnetic.x;`}
-       fun y: Float `{return recv->magnetic.y;`}
-       fun z: Float `{ return recv->magnetic.z;`}
+       fun x: Float `{return self->magnetic.x;`}
+       fun y: Float `{return self->magnetic.y;`}
+       fun z: Float `{ return self->magnetic.z;`}
 end
 
 # Sensor event returned by the gyroscope sensor
 extern class ASensorGyroscope `{ASensorEvent*`}
        super ASensorEvent
 
-       fun x: Float `{return recv->vector.x;`}
-       fun y: Float `{return recv->vector.y;`}
-       fun z: Float `{return recv->vector.y;`}
+       fun x: Float `{return self->vector.x;`}
+       fun y: Float `{return self->vector.y;`}
+       fun z: Float `{return self->vector.y;`}
 end
 
 # Sensor event returned by the Light sensor
 extern class ASensorLight `{ASensorEvent*`}
        super ASensorEvent
 
-       fun light: Float `{return recv->light;`}
+       fun light: Float `{return self->light;`}
 end
 
 # sensor event returned by the Proximity Sensor
 extern class ASensorProximity `{ASensorEvent*`}
        super ASensorEvent
 
-       fun distance: Float `{return recv->distance;`}
+       fun distance: Float `{return self->distance;`}
 end
 
 # Array of SensorEvents
@@ -223,7 +223,7 @@ extern class ASensorEvents `{ASensorEvent*`}
        new (length: Int) `{return malloc(sizeof(ASensorEvent)*length);`}
 
        fun [](index: Int): ASensorEvent `{
-               return recv+index;
+               return self+index;
        `}
 end
 
@@ -341,26 +341,26 @@ redef class App
                        //maybe add a boolean to the app to know if we want to use Sensor API or ASensorEvent directly ...
                        ASensorEvent* events = malloc(sizeof(ASensorEvent)*10);
                        int nbevents;
-                       ASensorEventQueue* queue = App_eventqueue(recv);
+                       ASensorEventQueue* queue = App_eventqueue(self);
                        while((nbevents = ASensorEventQueue_getEvents(queue, events, 10)) > 0) {
                                int i;
                                for(i = 0; i < nbevents; i++){
                                        ASensorEvent event = events[i];
                                        switch (event.type) {
                                                case ASENSOR_TYPE_ACCELEROMETER:
-                                                       App_extern_input_sensor_accelerometer(recv, &event);
+                                                       App_extern_input_sensor_accelerometer(self, &event);
                                                        break;
                                                case ASENSOR_TYPE_MAGNETIC_FIELD:
-                                                       App_extern_input_sensor_magnetic_field(recv, &event);
+                                                       App_extern_input_sensor_magnetic_field(self, &event);
                                                        break;
                                                case ASENSOR_TYPE_GYROSCOPE:
-                                                       App_extern_input_sensor_gyroscope(recv, &event);
+                                                       App_extern_input_sensor_gyroscope(self, &event);
                                                        break;
                                                case ASENSOR_TYPE_LIGHT:
-                                                       App_extern_input_sensor_light(recv, &event);
+                                                       App_extern_input_sensor_light(self, &event);
                                                        break;
                                                case ASENSOR_TYPE_PROXIMITY:
-                                                       App_extern_input_sensor_proximity(recv, &event);
+                                                       App_extern_input_sensor_proximity(self, &event);
                                                        break;
                                        }
                                }
index 84d213d..d4e71a8 100644 (file)
@@ -33,38 +33,38 @@ in "Java" `{
 
 extern class NativeSharedPreferences in "Java" `{ android.content.SharedPreferences `}
        super JavaObject
-       
-       fun contains(key: JavaString): Bool in "Java" `{ return recv.contains(key); `}
+
+       fun contains(key: JavaString): Bool in "Java" `{ return self.contains(key); `}
        fun get_all: HashMap[JavaString, JavaObject] import HashMap[JavaString, JavaObject],
-               HashMap[JavaString, JavaObject].[]= in "Java" `{ 
+               HashMap[JavaString, JavaObject].[]= in "Java" `{
                Map<String, ?> java_map = null;
                int nit_hashmap = new_HashMap_of_JavaString_JavaObject();
                try {
-                       java_map = recv.getAll();
+                       java_map = self.getAll();
                } catch (NullPointerException e) {
                        return nit_hashmap;
                }
 
                for (Map.Entry<String, ?> entry: java_map.entrySet())
-                       HashMap_of_JavaString_JavaObject__index_assign(nit_hashmap, 
+                       HashMap_of_JavaString_JavaObject__index_assign(nit_hashmap,
                                entry.getKey(), entry.getValue());
 
                return nit_hashmap;
        `}
-       fun get_boolean(key: JavaString, def_value: Bool): Bool in "Java" `{ 
+       fun get_boolean(key: JavaString, def_value: Bool): Bool in "Java" `{
                boolean return_value;
                try {
-                       return_value = recv.getBoolean(key, def_value); 
+                       return_value = self.getBoolean(key, def_value);
                } catch (ClassCastException e) {
                        return def_value;
                }
 
                return return_value;
        `}
-       fun get_float(key: JavaString, def_value: Float): Float in "Java" `{ 
+       fun get_float(key: JavaString, def_value: Float): Float in "Java" `{
                float return_value;
                try {
-                       return_value = recv.getFloat(key, (float) def_value); 
+                       return_value = self.getFloat(key, (float) def_value);
                } catch (ClassCastException e) {
                        return def_value;
                }
@@ -74,7 +74,7 @@ extern class NativeSharedPreferences in "Java" `{ android.content.SharedPreferen
        fun get_int(key: JavaString, def_value: Int): Int in "Java" `{
                int return_value;
                try {
-                       return_value = recv.getInt(key, (int)def_value); 
+                       return_value = self.getInt(key, (int)def_value);
                } catch (ClassCastException e) {
                        return def_value;
                }
@@ -84,7 +84,7 @@ extern class NativeSharedPreferences in "Java" `{ android.content.SharedPreferen
        fun get_long(key: JavaString, def_value: Int): Int in "Java" `{
                long return_value;
                try {
-                       return_value = recv.getLong(key, def_value); 
+                       return_value = self.getLong(key, def_value);
                } catch (ClassCastException e) {
                        return def_value;
                }
@@ -94,7 +94,7 @@ extern class NativeSharedPreferences in "Java" `{ android.content.SharedPreferen
        fun get_string(key: JavaString, def_value: JavaString): JavaString in "Java" `{
                String return_value = null;
                try {
-                       return_value = recv.getString(key, def_value); 
+                       return_value = self.getString(key, def_value);
                } catch (ClassCastException e) {
                        return def_value;
                }
@@ -104,41 +104,41 @@ extern class NativeSharedPreferences in "Java" `{ android.content.SharedPreferen
 
        # HACK for bug #845
        redef fun new_global_ref import sys, Sys.jni_env `{
-               Sys sys = NativeSharedPreferences_sys(recv);
+               Sys sys = NativeSharedPreferences_sys(self);
                JNIEnv *env = Sys_jni_env(sys);
-               return (*env)->NewGlobalRef(env, recv);
+               return (*env)->NewGlobalRef(env, self);
        `}
 end
 
 extern class NativeSharedPreferencesEditor in "Java" `{ android.content.SharedPreferences$Editor `}
        super JavaObject
 
-       fun clear: NativeSharedPreferencesEditor in "Java" `{ return recv.clear(); `}
-       fun commit: Bool in "Java" `{ return recv.commit(); `}
-       fun put_boolean(key: JavaString, value: Bool ): NativeSharedPreferencesEditor in "Java" `{ 
-               return recv.putBoolean (key, value); 
+       fun clear: NativeSharedPreferencesEditor in "Java" `{ return self.clear(); `}
+       fun commit: Bool in "Java" `{ return self.commit(); `}
+       fun put_boolean(key: JavaString, value: Bool): NativeSharedPreferencesEditor in "Java" `{
+               return self.putBoolean (key, value);
        `}
        fun put_float(key: JavaString, value: Float): NativeSharedPreferencesEditor in "Java" `{
-               return recv.putFloat(key, (float) value); 
+               return self.putFloat(key, (float) value);
        `}
        fun put_int(key: JavaString, value: Int): NativeSharedPreferencesEditor in "Java" `{
-               return recv.putInt(key, (int)value); 
+               return self.putInt(key, (int)value);
        `}
        fun put_long(key: JavaString, value: Int): NativeSharedPreferencesEditor in "Java" `{
-               return recv.putLong(key, value); 
+               return self.putLong(key, value);
        `}
        fun put_string(key: JavaString, value: JavaString): NativeSharedPreferencesEditor in "Java" `{
-               return recv.putString(key, value); 
+               return self.putString(key, value);
        `}
-       fun remove(key: JavaString): NativeSharedPreferencesEditor in "Java" `{ 
-               return recv.remove(key); 
+       fun remove(key: JavaString): NativeSharedPreferencesEditor in "Java" `{
+               return self.remove(key);
        `}
 
        # HACK for bug #845
        redef fun new_global_ref import sys, Sys.jni_env `{
-               Sys sys = NativeSharedPreferencesEditor_sys(recv);
+               Sys sys = NativeSharedPreferencesEditor_sys(self);
                JNIEnv *env = Sys_jni_env(sys);
-               return (*env)->NewGlobalRef(env, recv);
+               return (*env)->NewGlobalRef(env, self);
        `}
 end
 
@@ -150,8 +150,8 @@ class SharedPreferences
 
        # Automatically commits every saving/removing instructions (`true` by default)
        var auto_commit = true
-       
-       protected init(app: App, file_name: String, mode: Int) 
+
+       protected init(app: App, file_name: String, mode: Int)
        do
                self.context = app.native_activity
                sys.jni_env.push_local_frame(1)
@@ -160,7 +160,7 @@ class SharedPreferences
        end
 
        # Restricts file access to the current application
-       init privately(app: App, file_name: String) 
+       init privately(app: App, file_name: String)
        do
                self.init(app, file_name, private_mode)
        end
@@ -175,28 +175,28 @@ class SharedPreferences
        end
 
        private fun setup(file_name: JavaString, mode: Int) import context, set_vars in "Java" `{
-               Activity context = (Activity) SharedPreferences_context(recv);
+               Activity context = (Activity) SharedPreferences_context(self);
                SharedPreferences sp;
 
                // Uses default SharedPreferences if file_name is an empty String
                if (file_name.equals("")) {
                        sp = context.getPreferences((int)mode);
-               } else { 
+               } else {
                        sp = context.getSharedPreferences(file_name, (int)mode);
                }
 
                SharedPreferences.Editor editor = sp.edit();
-               
-               SharedPreferences_set_vars(recv, sp, editor);
+
+               SharedPreferences_set_vars(self, sp, editor);
        `}
 
        private fun commit_if_auto do if auto_commit then self.commit
 
        # Returns true if there's an entry corresponding the given key
-       fun has(key: String): Bool 
+       fun has(key: String): Bool
        do
                sys.jni_env.push_local_frame(2)
-               var return_value = shared_preferences.contains(key.to_java_string) 
+               var return_value = shared_preferences.contains(key.to_java_string)
                sys.jni_env.pop_local_frame
                return return_value
        end
@@ -209,13 +209,13 @@ class SharedPreferences
        # var foo = new HashMap[JavaString, JavaObject]
        # # ...
        # for key, value in foo do
-       #      key.delete_local_ref
-       #      value.delete_local_ref
+       #         key.delete_local_ref
+       #         value.delete_local_ref
        # end
        # ~~~
-       # *You should use Nit getters instead and get each value one by one* 
+       # *You should use Nit getters instead and get each value one by one*
        fun all: nullable HashMap[JavaString, JavaObject]
-       do 
+       do
                var hashmap = shared_preferences.get_all
                if hashmap.is_empty then return null
                return hashmap
@@ -223,8 +223,8 @@ class SharedPreferences
 
        # Returns the `Bool` value corresponding the given key or `def_value` if none
        # or if the value isn't of correct type
-       fun bool(key: String, def_value: Bool): Bool 
-       do 
+       fun bool(key: String, def_value: Bool): Bool
+       do
                sys.jni_env.push_local_frame(2)
                var return_value = shared_preferences.get_boolean(key.to_java_string, def_value)
                sys.jni_env.pop_local_frame
@@ -233,8 +233,8 @@ class SharedPreferences
 
        # Returns the `Float` value corresponding the given key or `def_value` if none
        # or if the value isn't of correct type
-       fun float(key: String, def_value: Float): Float 
-       do 
+       fun float(key: String, def_value: Float): Float
+       do
                sys.jni_env.push_local_frame(2)
                var return_value = shared_preferences.get_float(key.to_java_string, def_value)
                sys.jni_env.pop_local_frame
@@ -243,10 +243,10 @@ class SharedPreferences
 
        # Returns the `Int` value corresponding the given key or `def_value` if none
        # or if the value isn't of correct type
-       # Be aware of possible `def_value` integer overflow as the Nit `Int` corresponds 
+       # Be aware of possible `def_value` integer overflow as the Nit `Int` corresponds
        # to Java `long`
-       fun int(key: String, def_value: Int): Int 
-       do 
+       fun int(key: String, def_value: Int): Int
+       do
                sys.jni_env.push_local_frame(2)
                var return_value = shared_preferences.get_int(key.to_java_string, def_value)
                sys.jni_env.pop_local_frame
@@ -257,8 +257,8 @@ class SharedPreferences
        # or if the value isn't of correct type
        # Calls `getLong(key, value)` java method
        # Nit `Int` is equivalent to Java `long` so that no integer overflow will occur
-       fun long(key: String, def_value: Int): Int 
-       do 
+       fun long(key: String, def_value: Int): Int
+       do
                sys.jni_env.push_local_frame(2)
                var return_value = shared_preferences.get_long(key.to_java_string, def_value)
                sys.jni_env.pop_local_frame
@@ -267,29 +267,29 @@ class SharedPreferences
 
        # Returns the `String` value corresponding the given key or `def_value` if none
        # or if the value isn't of correct type
-       fun string(key: String, def_value: String): String 
-       do 
+       fun string(key: String, def_value: String): String
+       do
                sys.jni_env.push_local_frame(3)
-               var java_return_value = shared_preferences.get_string(key.to_java_string, 
+               var java_return_value = shared_preferences.get_string(key.to_java_string,
                        def_value.to_java_string)
                var nit_return_value = java_return_value.to_s
                sys.jni_env.pop_local_frame
                return nit_return_value
        end
 
-       # Clears all the dictionnary entries in the specified file or the default file 
+       # Clears all the dictionnary entries in the specified file or the default file
        # if none specified at instanciation
        # Returns `self` allowing fluent programming
-       fun clear: SharedPreferences 
-       do 
+       fun clear: SharedPreferences
+       do
                editor.clear
                commit_if_auto
                return self
        end
-       
+
        # If auto_commit is `false`, has to be called to save the data to persistant memory
-       fun commit: Bool 
-       do 
+       fun commit: Bool
+       do
                sys.jni_env.push_local_frame(1)
                var return_value = editor.commit
                sys.jni_env.pop_local_frame
@@ -298,8 +298,8 @@ class SharedPreferences
 
        # Set a key-value pair using a `Bool` value
        # Returns `self` allowing fluent programming
-       fun add_bool(key: String, value: Bool ): SharedPreferences 
-       do 
+       fun add_bool(key: String, value: Bool): SharedPreferences
+       do
                sys.jni_env.push_local_frame(1)
                editor.put_boolean(key.to_java_string, value)
                sys.jni_env.pop_local_frame
@@ -312,8 +312,8 @@ class SharedPreferences
        #
        # Be aware of possible loss of precision as Nit `Float` corresponds to Java `double`
        # and the methods stores a Java `float`
-       fun add_float(key: String, value: Float): SharedPreferences 
-       do 
+       fun add_float(key: String, value: Float): SharedPreferences
+       do
                sys.jni_env.push_local_frame(1)
                editor.put_float(key.to_java_string, value)
                sys.jni_env.pop_local_frame
@@ -327,8 +327,8 @@ class SharedPreferences
        # Be aware of possible integer overflow as the Nit `Int` corresponds to Java `long`
        # and the methods stores a Java `int`
        # *You might want to use add_long instead*
-       fun add_int(key: String, value: Int): SharedPreferences 
-       do 
+       fun add_int(key: String, value: Int): SharedPreferences
+       do
                sys.jni_env.push_local_frame(1)
                editor.put_int(key.to_java_string, value)
                sys.jni_env.pop_local_frame
@@ -338,8 +338,8 @@ class SharedPreferences
 
        # Set a key-value pair using a `Int` type value
        # Returns `self` allowing fluent programming
-       fun add_long(key: String, value: Int): SharedPreferences 
-       do 
+       fun add_long(key: String, value: Int): SharedPreferences
+       do
                sys.jni_env.push_local_frame(1)
                editor.put_long(key.to_java_string, value)
                sys.jni_env.pop_local_frame
@@ -349,8 +349,8 @@ class SharedPreferences
 
        # Set a key-value pair using a `String` type value
        # Returns `self` allowing fluent programming
-       fun add_string(key: String, value: String): SharedPreferences 
-       do 
+       fun add_string(key: String, value: String): SharedPreferences
+       do
                sys.jni_env.push_local_frame(2)
                editor.put_string(key.to_java_string, value.to_java_string)
                sys.jni_env.pop_local_frame
@@ -360,8 +360,8 @@ class SharedPreferences
 
        # Removes the corresponding entry in the file
        # Returns `self` allowing fluent programming
-       fun remove(key: String): SharedPreferences 
-       do 
+       fun remove(key: String): SharedPreferences
+       do
                sys.jni_env.push_local_frame(1)
                editor.remove(key.to_java_string)
                sys.jni_env.pop_local_frame
@@ -370,7 +370,7 @@ class SharedPreferences
        end
 
        # Deallocate global references allocated by the SharedPreferences instance
-       fun destroy 
+       fun destroy
        do
                self.shared_preferences.delete_global_ref
                self.editor.delete_global_ref
index 48d600a..85623d8 100644 (file)
@@ -19,19 +19,19 @@ module shared_preferences_api11 is android_api_min 11
 
 import shared_preferences
 
-in "Java" `{ 
+in "Java" `{
        import java.util.HashSet;
-       import java.util.Set;
-       import android.content.Context; 
+       import java.util.Set;
+       import android.content.Context;
 `}
 
 redef extern class NativeSharedPreferences
-       
+
        # Default value to null instead of Set<String>
-       fun get_string_set(key: JavaString): HashSet[JavaString] import HashSet[JavaString], 
-               HashSet[JavaString].add in "Java" `{ 
+       fun get_string_set(key: JavaString): HashSet[JavaString] import HashSet[JavaString],
+               HashSet[JavaString].add in "Java" `{
                Set<String> def_value = new HashSet<String>();
-               Set<String> java_set = recv.getStringSet(key, def_value);
+               Set<String> java_set = self.getStringSet(key, def_value);
                int nit_hashset = new_HashSet_of_JavaString();
 
                for (String element: java_set)
@@ -41,23 +41,23 @@ redef extern class NativeSharedPreferences
        `}
 end
 
-redef extern class NativeSharedPreferencesEditor 
-       
-       fun put_string_set(key: JavaString, value: HashSet[JavaString]): NativeSharedPreferencesEditor 
-               import HashSet[JavaString], HashSet[JavaString].iterator, Iterator[JavaString].is_ok, 
-               Iterator[JavaString].item, Iterator[JavaString].next in "Java" `{ 
+redef extern class NativeSharedPreferencesEditor
+
+       fun put_string_set(key: JavaString, value: HashSet[JavaString]): NativeSharedPreferencesEditor
+               import HashSet[JavaString], HashSet[JavaString].iterator, Iterator[JavaString].is_ok,
+               Iterator[JavaString].item, Iterator[JavaString].next in "Java" `{
                Set<String> java_set = new HashSet<String>();
                int itr = HashSet_of_JavaString_iterator(value);
-               
+
                while (Iterator_of_JavaString_is_ok(itr)) {
                        java_set.add(Iterator_of_JavaString_item(itr));
                        Iterator_of_JavaString_next(itr);
                }
 
-               return recv.putStringSet(key, java_set); 
+               return self.putStringSet(key, java_set);
        `}
 end
-       
+
 redef class SharedPreferences
 
        # Allows multiple processes to write into the same `SharedPreferences` file
@@ -78,8 +78,8 @@ redef class SharedPreferences
        # # ...
        # for element in a_hash_set do element.delete_local_ref
        # ~~~
-       fun string_set(key: String): HashSet[JavaString] 
-       do 
+       fun string_set(key: String): HashSet[JavaString]
+       do
                sys.jni_env.push_local_frame(3)
                var return_value = shared_preferences.get_string_set(key.to_java_string)
                sys.jni_env.pop_local_frame
@@ -97,7 +97,7 @@ redef class SharedPreferences
        # for element in foo do element.delete_local_ref
        # ~~~
        fun add_string_set(key: String, value: HashSet[JavaString]): SharedPreferences
-       do 
+       do
                editor.put_string_set(key.to_java_string, value)
                return self
        end
index 954a380..21c2cf9 100644 (file)
@@ -34,7 +34,7 @@ redef class App
 
        private fun native_toast(message: JavaString, is_long: Bool)
        import native_activity in "Java" `{
-               final android.app.Activity context = App_native_activity(recv);
+               final android.app.Activity context = App_native_activity(self);
                final CharSequence final_message = message;
                final int duration = is_long? Toast.LENGTH_LONG: Toast.LENGTH_SHORT;
 
index 79b75a5..9450ab2 100644 (file)
@@ -42,12 +42,12 @@ redef extern class NativeActivity
        # Set the main layout of this activity
        fun content_view=(layout: NativeViewGroup) in "Java" `{
                final ViewGroup final_layout = layout;
-               final Activity final_recv = recv;
+               final Activity final_self = self;
 
-               recv.runOnUiThread(new Runnable() {
+               self.runOnUiThread(new Runnable() {
                        @Override
                        public void run()  {
-                               final_recv.setContentView(final_layout);
+                               final_self.setContentView(final_layout);
 
                                final_layout.requestFocus();
                        }
@@ -59,18 +59,18 @@ end
 extern class NativeView in "Java" `{ android.view.View `}
        super JavaObject
 
-       fun minimum_width=(val: Int) in "Java" `{ recv.setMinimumWidth((int)val); `}
-       fun minimum_height=(val: Int) in "Java" `{ recv.setMinimumHeight((int)val); `}
+       fun minimum_width=(val: Int) in "Java" `{ self.setMinimumWidth((int)val); `}
+       fun minimum_height=(val: Int) in "Java" `{ self.setMinimumHeight((int)val); `}
 
-       fun enabled: Bool in "Java" `{ return recv.isEnabled(); `}
+       fun enabled: Bool in "Java" `{ return self.isEnabled(); `}
        fun enabled=(value: Bool) in "Java" `{
-               final View final_recv = recv;
+               final View final_self = self;
                final boolean final_value = value;
 
-               ((Activity)recv.getContext()).runOnUiThread(new Runnable() {
+               ((Activity)self.getContext()).runOnUiThread(new Runnable() {
                        @Override
                        public void run()  {
-                               final_recv.setEnabled(final_value);
+                               final_self.setEnabled(final_value);
                        }
                });
        `}
@@ -80,11 +80,11 @@ end
 extern class NativeViewGroup in "Java" `{ android.view.ViewGroup `}
        super NativeView
 
-       fun add_view(view: NativeView) in "Java" `{ recv.addView(view); `}
+       fun add_view(view: NativeView) in "Java" `{ self.addView(view); `}
 
        fun add_view_with_weight(view: NativeView, weight: Float)
        in "Java" `{
-               recv.addView(view, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, (float)weight));
+               self.addView(view, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, (float)weight));
        `}
 end
 
@@ -94,15 +94,15 @@ extern class NativeLinearLayout in "Java" `{ android.widget.LinearLayout `}
 
        new(context: NativeActivity) in "Java" `{ return new LinearLayout(context); `}
 
-       fun set_vertical in "Java" `{ recv.setOrientation(LinearLayout.VERTICAL); `}
-       fun set_horizontal in "Java" `{ recv.setOrientation(LinearLayout.HORIZONTAL); `}
+       fun set_vertical in "Java" `{ self.setOrientation(LinearLayout.VERTICAL); `}
+       fun set_horizontal in "Java" `{ self.setOrientation(LinearLayout.HORIZONTAL); `}
 
        redef fun add_view(view) in "Java"
        `{
                MarginLayoutParams params = new MarginLayoutParams(
                        LinearLayout.LayoutParams.MATCH_PARENT,
                        LinearLayout.LayoutParams.WRAP_CONTENT);
-               recv.addView(view, params);
+               self.addView(view, params);
        `}
 end
 
@@ -112,25 +112,25 @@ extern class NativeGridLayout in "Java" `{ android.widget.GridLayout `}
 
        new(context: NativeActivity) in "Java" `{ return new android.widget.GridLayout(context); `}
 
-       fun row_count=(val: Int) in "Java" `{ recv.setRowCount((int)val); `}
+       fun row_count=(val: Int) in "Java" `{ self.setRowCount((int)val); `}
 
-       fun column_count=(val: Int) in "Java" `{ recv.setColumnCount((int)val); `}
+       fun column_count=(val: Int) in "Java" `{ self.setColumnCount((int)val); `}
 
-       redef fun add_view(view) in "Java" `{ recv.addView(view); `}
+       redef fun add_view(view) in "Java" `{ self.addView(view); `}
 end
 
 extern class NativePopupWindow in "Java" `{ android.widget.PopupWindow `}
        super NativeView
 
        new (context: NativeActivity) in "Java" `{
-               PopupWindow recv = new PopupWindow(context);
-               recv.setWindowLayoutMode(LinearLayout.LayoutParams.MATCH_PARENT,
+               PopupWindow self = new PopupWindow(context);
+               self.setWindowLayoutMode(LinearLayout.LayoutParams.MATCH_PARENT,
                        LinearLayout.LayoutParams.MATCH_PARENT);
-               recv.setClippingEnabled(false);
-               return recv;
+               self.setClippingEnabled(false);
+               return self;
        `}
 
-       fun content_view=(layout: NativeViewGroup) in "Java" `{ recv.setContentView(layout); `}
+       fun content_view=(layout: NativeViewGroup) in "Java" `{ self.setContentView(layout); `}
 end
 
 extern class NativeTextView in "Java" `{ android.widget.TextView `}
@@ -138,30 +138,30 @@ extern class NativeTextView in "Java" `{ android.widget.TextView `}
 
        new (context: NativeActivity) in "Java" `{ return new TextView(context); `}
 
-       fun text: JavaString in "Java" `{ return recv.getText().toString(); `}
+       fun text: JavaString in "Java" `{ return self.getText().toString(); `}
 
        fun text=(value: JavaString) in "Java" `{
 
-               final TextView final_recv = recv;
+               final TextView final_self = self;
                final String final_value = value;
 
-               ((Activity)recv.getContext()).runOnUiThread(new Runnable() {
+               ((Activity)self.getContext()).runOnUiThread(new Runnable() {
                        @Override
                        public void run()  {
-                               final_recv.setText(final_value);
+                               final_self.setText(final_value);
                        }
                });
        `}
 
        fun gravity_center in "Java" `{
-               recv.setGravity(Gravity.CENTER);
+               self.setGravity(Gravity.CENTER);
        `}
 
        fun text_size: Float in "Java" `{
-               return recv.getTextSize();
+               return self.getTextSize();
        `}
        fun text_size=(dpi: Float) in "Java" `{
-               recv.setTextSize(android.util.TypedValue.COMPLEX_UNIT_DIP, (float)dpi);
+               self.setTextSize(android.util.TypedValue.COMPLEX_UNIT_DIP, (float)dpi);
        `}
 end
 
@@ -172,14 +172,14 @@ extern class NativeEditText in "Java" `{ android.widget.EditText `}
 
        new (context: NativeActivity) in "Java" `{ return new android.widget.EditText(context); `}
 
-       fun width=(val: Int) in "Java" `{ recv.setWidth((int)val); `}
+       fun width=(val: Int) in "Java" `{ self.setWidth((int)val); `}
 
-       fun input_type_text in "Java" `{ recv.setInputType(android.text.InputType.TYPE_CLASS_TEXT); `}
+       fun input_type_text in "Java" `{ self.setInputType(android.text.InputType.TYPE_CLASS_TEXT); `}
 
        redef fun new_global_ref: SELF import sys, Sys.jni_env `{
-               Sys sys = NativeEditText_sys(recv);
+               Sys sys = NativeEditText_sys(self);
                JNIEnv *env = Sys_jni_env(sys);
-               return (*env)->NewGlobalRef(env, recv);
+               return (*env)->NewGlobalRef(env, self);
        `}
 end
 
@@ -189,8 +189,8 @@ extern class NativeButton in "Java" `{ android.widget.Button `}
        redef type SELF: NativeButton
 
        redef fun new_global_ref: SELF import sys, Sys.jni_env `{
-               Sys sys = NativeButton_sys(recv);
+               Sys sys = NativeButton_sys(self);
                JNIEnv *env = Sys_jni_env(sys);
-               return (*env)->NewGlobalRef(env, recv);
+               return (*env)->NewGlobalRef(env, self);
        `}
 end
index 430e047..99ff7ad 100644 (file)
@@ -28,21 +28,21 @@ extern class Vibrator in "Java" `{ android.os.Vibrator `}
        super JavaObject
 
        # Vibrate for `n` miliseconds
-       fun vibrate(n: Int) in "Java" `{ recv.vibrate(n); `}
+       fun vibrate(n: Int) in "Java" `{ self.vibrate(n); `}
 
        # Does this devices has a vibrator
        #
        # TODO activate in API 11
-       #fun exists: Bool in "Java" `{ return recv.hasVibrator(); `}
+       #fun exists: Bool in "Java" `{ return self.hasVibrator(); `}
 
        # Turn off the vibration
-       fun cancel in "Java" `{ recv.cancel(); `}
+       fun cancel in "Java" `{ self.cancel(); `}
 
        # HACK for bug #845
        redef fun new_global_ref import sys, Sys.jni_env `{
-               Sys sys = Vibrator_sys(recv);
+               Sys sys = Vibrator_sys(self);
                JNIEnv *env = Sys_jni_env(sys);
-               return (*env)->NewGlobalRef(env, recv);
+               return (*env)->NewGlobalRef(env, self);
        `}
 end
 
index aac7352..99fd4a4 100644 (file)
@@ -57,39 +57,39 @@ extern class RPiPin `{ RPiGPIOPin `}
        new p1_26 `{ return RPI_GPIO_P1_26; `}
 
        # Select mode: input, output or alts
-       fun fsel=(mode: FunctionSelect) `{ bcm2835_gpio_fsel(recv, mode); `}
+       fun fsel=(mode: FunctionSelect) `{ bcm2835_gpio_fsel(self, mode); `}
 
        # Set output
-       redef fun write(high) `{ bcm2835_gpio_write(recv, high? HIGH: LOW); `}
+       redef fun write(high) `{ bcm2835_gpio_write(self, high? HIGH: LOW); `}
 
        # Set pull up mode
-       fun pud=(pud: PUDControl) `{ bcm2835_gpio_set_pud(recv, pud); `}
+       fun pud=(pud: PUDControl) `{ bcm2835_gpio_set_pud(self, pud); `}
 
        # Falling edge detect
        # Do not use on raspbian, it is bugged!
-       fun fen `{ bcm2835_gpio_fen(recv); `}
-       fun clr_fen `{ bcm2835_gpio_clr_fen(recv); `}
+       fun fen `{ bcm2835_gpio_fen(self); `}
+       fun clr_fen `{ bcm2835_gpio_clr_fen(self); `}
 
        # Raising edge detect
        # Do not use on raspbian, it is bugged!
-       fun ren `{ bcm2835_gpio_ren(recv); `}
-       fun clr_ren `{ bcm2835_gpio_clr_ren(recv); `}
+       fun ren `{ bcm2835_gpio_ren(self); `}
+       fun clr_ren `{ bcm2835_gpio_clr_ren(self); `}
 
        # High edge detect
        # Do not use on raspbian, it is bugged!
-       fun hen `{ bcm2835_gpio_hen(recv); `}
-       fun clr_hen `{ bcm2835_gpio_clr_hen(recv); `}
+       fun hen `{ bcm2835_gpio_hen(self); `}
+       fun clr_hen `{ bcm2835_gpio_clr_hen(self); `}
 
        # Low edge detect
        # Do not use on raspbian, it is bugged!
-       fun len `{ bcm2835_gpio_len(recv); `}
-       fun clr_len `{ bcm2835_gpio_clr_len(recv); `}
+       fun len `{ bcm2835_gpio_len(self); `}
+       fun clr_len `{ bcm2835_gpio_clr_len(self); `}
 
-       fun set_eds `{ bcm2835_gpio_set_eds(recv); `}
-       fun eds: Bool `{ return bcm2835_gpio_eds(recv); `}
+       fun set_eds `{ bcm2835_gpio_set_eds(self); `}
+       fun eds: Bool `{ return bcm2835_gpio_eds(self); `}
 
        # Return input on pin, true for high and false for low
-       fun lev: Bool `{ return bcm2835_gpio_lev(recv); `}
+       fun lev: Bool `{ return bcm2835_gpio_lev(self); `}
 end
 
 extern class FunctionSelect `{ bcm2835FunctionSelect `}
@@ -115,8 +115,8 @@ extern class PUDControl `{ bcm2835PUDControl `}
 end
 
 redef universal Int
-       fun bcm2835_delay `{ bcm2835_delay(recv); `}
-       fun bcm2835_delay_micros `{ bcm2835_delayMicroseconds(recv); `}
+       fun bcm2835_delay `{ bcm2835_delay(self); `}
+       fun bcm2835_delay_micros `{ bcm2835_delayMicroseconds(self); `}
 end
 
 class RotaryEncoder
index 28ddf32..59ec88d 100644 (file)
@@ -325,7 +325,7 @@ redef class Int
                        uint64_t conv;
                } u;
 
-               u.val = recv;
+               u.val = self;
 
                if (big_endian)
                        u.conv = htobe64(u.conv);
@@ -344,7 +344,7 @@ redef class Float
                        uint32_t conv;
                } u;
 
-               u.val = recv;
+               u.val = self;
 
                if (big_endian)
                        u.conv = htobe32(u.conv);
@@ -361,7 +361,7 @@ redef class Float
                        uint64_t conv;
                } u;
 
-               u.val = recv;
+               u.val = self;
 
                if (big_endian)
                        u.conv = htobe64(u.conv);
index 32bd967..a8e0c2f 100644 (file)
--- a/lib/c.nit
+++ b/lib/c.nit
@@ -111,10 +111,10 @@ extern class NativeCIntArray `{ int* `}
        # Initialize a new NativeCIntArray of `size` elements.
        new(size: Int) `{ return calloc(size, sizeof(int)); `}
 
-       redef fun [](index) `{ return recv[index]; `}
-       redef fun []=(index, val) `{ recv[index] = val; `}
+       redef fun [](index) `{ return self[index]; `}
+       redef fun []=(index, val) `{ self[index] = val; `}
 
-       redef fun +(offset) `{ return recv + offset; `}
+       redef fun +(offset) `{ return self + offset; `}
 end
 
 # Wrapper around an array of `unsigned char` in C (`unsigned char*`) with length and destroy state
@@ -147,10 +147,10 @@ extern class NativeCByteArray `{ unsigned char* `}
        # Allocate a new array of `size`
        new(size: Int) `{ return calloc(size, sizeof(unsigned char)); `}
 
-       redef fun [](index) `{ return recv[index]; `}
-       redef fun []=(index, val) `{ recv[index] = val; `}
+       redef fun [](index) `{ return self[index]; `}
+       redef fun []=(index, val) `{ self[index] = val; `}
 
-       redef fun +(offset) `{ return recv + offset; `}
+       redef fun +(offset) `{ return self + offset; `}
 end
 
 # Wrapper around an array of `NativeString` in C (`char**`) with length and destroy state.
@@ -185,14 +185,14 @@ extern class NativeCStringArray `{ char** `}
        # Initialize a new NativeCStringArray of `size` elements.
        new(size: Int) `{ return calloc(size, sizeof(char*)); `}
 
-       redef fun [](index) `{ return recv[index]; `}
-       redef fun []=(index, val) `{ recv[index] = val; `}
-       redef fun +(offset) `{ return recv + offset; `}
+       redef fun [](index) `{ return self[index]; `}
+       redef fun []=(index, val) `{ self[index] = val; `}
+       redef fun +(offset) `{ return self + offset; `}
 end
 
 redef class NativeString
        super NativeCArray
        redef type E: Char
 
-       redef fun +(offset) `{ return recv + offset; `}
+       redef fun +(offset) `{ return self + offset; `}
 end
index 5fe0af2..91632db 100644 (file)
@@ -31,8 +31,8 @@ extern class NSAlert in "ObjC" `{ NSAlert * `}
        new in "ObjC" `{ return [[NSAlert alloc] init]; `}
 
        # Set the content of this message box
-       fun message_text=(text: NSString) in "ObjC" `{ [recv setMessageText:text]; `}
+       fun message_text=(text: NSString) in "ObjC" `{ [self setMessageText:text]; `}
 
        # Show this message box
-       fun run_modal in "ObjC" `{ [recv runModal]; `}
+       fun run_modal in "ObjC" `{ [self runModal]; `}
 end
index cbe8f08..06c8ffd 100644 (file)
@@ -35,7 +35,7 @@ end
 redef class NativeString
        # Get a `NSString` from `self` with the specified `length`
        fun to_nsstring(length: Int): NSString in "ObjC" `{
-               return [[NSString alloc] initWithBytes:recv
+               return [[NSString alloc] initWithBytes:self
                        length:length
                        encoding:NSASCIIStringEncoding];
        `}
index 78bb96c..a2896d3 100644 (file)
@@ -31,6 +31,6 @@ end
 redef class NativeString
        # Get `self` as a `CppString`
        fun to_cpp_string(length: Int): CppString in "C++" `{
-               return new std::string(recv, length);
+               return new std::string(self, length);
        `}
 end
index c087642..dbfc157 100644 (file)
@@ -377,8 +377,7 @@ class CurlResponseSuccess
        var status_code = 0
 
        # Receive body from request due to body callback registering
-       redef fun body_callback(line: String)
-       do
+       redef fun body_callback(line) do
                self.body_str = "{self.body_str}{line}"
        end
 end
index 287dbce..fe0a446 100644 (file)
@@ -78,11 +78,11 @@ extern class CCurl `{ CURL * `}
        # Constructor, CURL low level initializer
        new easy_init `{ return curl_easy_init(); `}
        # Check for correct initialization
-       fun is_init:Bool `{ return (recv != NULL); `}
+       fun is_init:Bool `{ return (self != NULL); `}
        # Easy Clean / Release CURL instance
-       fun easy_clean `{ curl_easy_cleanup( recv ); `}
+       fun easy_clean `{ curl_easy_cleanup( self ); `}
        # Perform the transfer described by setted options
-       fun easy_perform:CURLCode `{ return curl_easy_perform( recv ); `}
+       fun easy_perform:CURLCode `{ return curl_easy_perform( self ); `}
        # Set options to tell CURL how to behave. Obj parameter type can be Int, Bool, String, OFile, CURLSList.
        fun easy_setopt(opt: CURLOption, obj: Object):CURLCode
        do
@@ -95,15 +95,15 @@ extern class CCurl `{ CURL * `}
                return once new CURLCode.unknown_option
        end
        # Internal method to set options to CURL using OFile parameter.
-       private fun i_setopt_file(opt: CURLOption, fl: OFile):CURLCode `{ return curl_easy_setopt( recv, opt, fl); `}
+       private fun i_setopt_file(opt: CURLOption, fl: OFile):CURLCode `{ return curl_easy_setopt( self, opt, fl); `}
        # Internal method to set options to CURL using Int parameter.
-       private fun i_setopt_int(opt: CURLOption, num: Int):CURLCode `{ return curl_easy_setopt( recv, opt, num); `}
+       private fun i_setopt_int(opt: CURLOption, num: Int):CURLCode `{ return curl_easy_setopt( self, opt, num); `}
        # Internal method to set options to CURL using CURLSList parameter.
-       private fun i_setopt_slist(opt: CURLOption, list: CURLSList):CURLCode `{ return curl_easy_setopt( recv, opt, list); `}
+       private fun i_setopt_slist(opt: CURLOption, list: CURLSList):CURLCode `{ return curl_easy_setopt( self, opt, list); `}
        # Internal method to set options to CURL using String parameter.
        private fun i_setopt_string(opt: CURLOption, str: String):CURLCode import String.to_cstring `{
                char *rStr = String_to_cstring(str);
-               return curl_easy_setopt( recv, opt, rStr);
+               return curl_easy_setopt( self, opt, rStr);
        `}
        # Request Chars internal information from the CURL session
        fun easy_getinfo_chars(opt: CURLInfoChars):nullable CURLInfoResponseString
@@ -115,7 +115,7 @@ extern class CCurl `{ CURL * `}
        # Internal method used to get String object information initially knowns as C Chars type
        private fun i_getinfo_chars(opt: CURLInfoChars, res: CURLInfoResponseString):CURLCode import CURLInfoResponseString.response=, NativeString.to_s_with_copy `{
                char *r = NULL;
-               CURLcode c = curl_easy_getinfo( recv, opt, &r);
+               CURLcode c = curl_easy_getinfo( self, opt, &r);
                if((c == CURLE_OK) && r != NULL){
                        String ro = NativeString_to_s_with_copy(r);
                        CURLInfoResponseString_response__assign( res, ro);
@@ -133,7 +133,7 @@ extern class CCurl `{ CURL * `}
        private fun i_getinfo_long(opt: CURLInfoLong, res: CURLInfoResponseLong):CURLCode import CURLInfoResponseLong.response= `{
                long *r = NULL;
                r = malloc(sizeof(long));
-               CURLcode c = curl_easy_getinfo( recv, opt, r);
+               CURLcode c = curl_easy_getinfo( self, opt, r);
                if((c == CURLE_OK) && r != NULL) CURLInfoResponseLong_response__assign( res, *r);
                free(r);
                return c;
@@ -149,7 +149,7 @@ extern class CCurl `{ CURL * `}
        private fun i_getinfo_double(opt: CURLInfoDouble, res: CURLInfoResponseDouble):CURLCode import CURLInfoResponseDouble.response= `{
                double *r = NULL;
                r = malloc(sizeof(double));
-               CURLcode c = curl_easy_getinfo( recv, opt, r);
+               CURLcode c = curl_easy_getinfo( self, opt, r);
                if((c == CURLE_OK) && r != NULL) CURLInfoResponseDouble_response__assign( res, *r);
                free(r);
                return c;
@@ -166,7 +166,7 @@ extern class CCurl `{ CURL * `}
        # Internal method used to get Array[String] object information initially knowns as C SList type
        private fun i_getinfo_slist(opt: CURLInfoSList, res: CURLInfoResponseArray):CURLCode import CURLInfoResponseArray.prim_response=`{
                struct curl_slist* csl = NULL;
-               CURLcode ce = curl_easy_getinfo( recv, opt, &csl);
+               CURLcode ce = curl_easy_getinfo( self, opt, &csl);
                CURLInfoResponseArray_prim_response__assign(res, csl);
                return ce;
        `}
@@ -191,7 +191,7 @@ extern class CCurl `{ CURL * `}
                d->data = (char*)String_to_cstring(datas);
                d->len = size;
                d->pos = 0;
-               return curl_easy_setopt( recv, CURLOPT_READDATA, d);
+               return curl_easy_setopt( self, CURLOPT_READDATA, d);
        `}
        # Internal method used to configure callbacks in terms of given type
        private fun i_register_callback(delegate: CCurlCallbacks, cbtype: CURLCallbackType):CURLCode is extern import CCurlCallbacks.header_callback, CCurlCallbacks.body_callback, CCurlCallbacks.stream_callback, NativeString.to_s_with_copy, NativeString.to_s `{
@@ -202,18 +202,18 @@ extern class CCurl `{ CURL * `}
                CURLcode e;
                switch(cbtype){
                        case CURLcallbackTypeHeader:
-                               e = curl_easy_setopt( recv, CURLOPT_HEADERFUNCTION, (curl_write_callback)&nit_curl_callback_func);
+                               e = curl_easy_setopt( self, CURLOPT_HEADERFUNCTION, (curl_write_callback)&nit_curl_callback_func);
                                if(e != CURLE_OK) return e;
-                               e = curl_easy_setopt( recv, CURLOPT_WRITEHEADER, d);
+                               e = curl_easy_setopt( self, CURLOPT_WRITEHEADER, d);
                        break;
                        case CURLcallbackTypeBody:
                        case CURLcallbackTypeStream:
-                               e = curl_easy_setopt( recv, CURLOPT_WRITEFUNCTION, (curl_write_callback)&nit_curl_callback_func);
+                               e = curl_easy_setopt( self, CURLOPT_WRITEFUNCTION, (curl_write_callback)&nit_curl_callback_func);
                                if(e != CURLE_OK) return e;
-                               e = curl_easy_setopt( recv, CURLOPT_WRITEDATA, d);
+                               e = curl_easy_setopt( self, CURLOPT_WRITEDATA, d);
                        break;
                        case CURLcallbackTypeRead:
-                               e = curl_easy_setopt( recv, CURLOPT_READFUNCTION, (curl_write_callback)&nit_curl_callback_read_func);
+                               e = curl_easy_setopt( self, CURLOPT_READFUNCTION, (curl_write_callback)&nit_curl_callback_read_func);
                        default:
                        break;
                }
@@ -223,7 +223,7 @@ extern class CCurl `{ CURL * `}
        fun escape(url: String):String import String.to_cstring, NativeString.to_s_with_copy `{
                char *orig_url, *encoded_url = NULL;
                orig_url = String_to_cstring(url);
-               encoded_url = curl_easy_escape( recv, orig_url, strlen(orig_url));
+               encoded_url = curl_easy_escape( self, orig_url, strlen(orig_url));
                String b_url = NativeString_to_s_with_copy(encoded_url);
                curl_free(encoded_url);
                return b_url;
@@ -235,9 +235,9 @@ extern class OFile `{ FILE* `}
        # Open / Create a file from given name
        new open(str: NativeString) `{ return fopen(str, "wb"); `}
        # Check for File validity
-       fun is_valid:Bool `{ return recv != NULL; `}
+       fun is_valid:Bool `{ return self != NULL; `}
        # Internal method to write to the current file
-       private fun n_write(buffer: NativeString, size: Int, count: Int):Int `{ return fwrite(buffer, size, count, recv); `}
+       private fun n_write(buffer: NativeString, size: Int, count: Int):Int `{ return fwrite(buffer, size, count, self); `}
        # Write datas to the current file
        fun write(buffer: String, size: Int, count: Int):Int
        do
@@ -245,7 +245,7 @@ extern class OFile `{ FILE* `}
                return 0
        end
        # Internal method to close the current file
-       private fun n_close:Int `{ return fclose(recv); `}
+       private fun n_close:Int `{ return fclose(self); `}
        # Close the current file
        fun close:Bool
        do
@@ -267,7 +267,7 @@ extern class CURLCallbackType `{ CURLcallbackType `}
        new body `{ return CURLcallbackTypeBody; `}
        new stream `{ return CURLcallbackTypeStream; `}
        new read `{ return CURLcallbackTypeRead; `}
-       fun to_i:Int `{ return recv; `}
+       fun to_i:Int `{ return self; `}
 end
 
 # CURL Code binding and helpers
@@ -276,13 +276,13 @@ extern class CURLCode `{ CURLcode `}
        new unsupported_protocol `{ return CURLE_UNSUPPORTED_PROTOCOL; `}
        new ok `{ return CURLE_OK; `}
        new failed_init `{ return CURLE_FAILED_INIT; `}
-       fun code:Int `{ return recv; `}
-       fun is_ok:Bool `{ return recv == CURLE_OK; `}
-       fun is_valid_protocol:Bool `{ return recv == CURLE_UNSUPPORTED_PROTOCOL; `}
-       fun is_valid_init:Bool `{ return recv == CURLE_FAILED_INIT; `}
+       fun code:Int `{ return self; `}
+       fun is_ok:Bool `{ return self == CURLE_OK; `}
+       fun is_valid_protocol:Bool `{ return self == CURLE_UNSUPPORTED_PROTOCOL; `}
+       fun is_valid_init:Bool `{ return self == CURLE_FAILED_INIT; `}
        fun to_i:Int do return code end
        redef fun to_s import NativeString.to_s_with_copy `{
-               char *c = (char*)curl_easy_strerror(recv);
+               char *c = (char*)curl_easy_strerror(self);
                return NativeString_to_s_with_copy(c);
        `}
 end
@@ -298,11 +298,11 @@ extern class CURLSList `{ struct curl_slist * `}
                return l;
        `}
        # Check for initialization
-       fun is_init:Bool `{ return (recv != NULL); `}
+       fun is_init:Bool `{ return (self != NULL); `}
        # Append an element in the linked list
        fun append(key: String) import String.to_cstring `{
                 char *k = String_to_cstring(key);
-                curl_slist_append(recv, (char*)k);
+                curl_slist_append(self, (char*)k);
        `}
        # Internal method to check for reachability of current data
        private fun i_data_reachable(c: CURLSList):Bool `{ return (c != NULL && c->data != NULL); `}
@@ -325,7 +325,7 @@ extern class CURLSList `{ struct curl_slist * `}
                return r
        end
        # Release allocated memory
-       fun destroy `{ curl_slist_free_all(recv); `}
+       fun destroy `{ curl_slist_free_all(self); `}
 end
 
 redef class Collection[E]
@@ -391,7 +391,7 @@ extern class CURLInfoLong `{ CURLINFO `}
        new condition_unmet `{ return CURLINFO_CONDITION_UNMET; `}
        new rtsp_client_cseq `{ return CURLINFO_RTSP_CLIENT_CSEQ; `}
        new rtsp_server_cseq `{ return CURLINFO_RTSP_SERVER_CSEQ; `}
-       new rtsp_cseq_recv `{ return CURLINFO_RTSP_CSEQ_RECV; `}
+       new rtsp_cseq_self `{ return CURLINFO_RTSP_CSEQ_RECV; `}
 end
 
 # Reproduce Enum of available CURL Double information, used for CCurl.easy_getinfo
@@ -462,7 +462,7 @@ extern class CURLStatusCode `{ int `}
        new service_unavailable `{ return 503; `}
        new gateway_timeout `{ return 504; `}
        new http_version_not_supported `{ return 505; `}
-       fun to_i:Int `{ return recv; `}
+       fun to_i:Int `{ return self; `}
 end
 
 # Reproduce Enum of CURL Options usable, used for CCurl.easy_setopt
index 079f12c..948ba38 100644 (file)
@@ -32,16 +32,16 @@ class MyHttpFetcher
        fun destroy do self.curl.destroy
 
        # Header callback
-       redef fun header_callback(line: String) do
+       redef fun header_callback(line) do
                # We keep this callback silent for testing purposes
                #if not line.has_prefix("Date:") then print "Header_callback : {line}"
        end
 
        # Body callback
-       redef fun body_callback(line: String) do self.our_body = "{self.our_body}{line}"
+       redef fun body_callback(line) do self.our_body = "{self.our_body}{line}"
 
        # Stream callback - Cf : No one is registered
-       redef fun stream_callback(buffer: String, size: Int, count: Int) do print "Stream_callback : {buffer} - {size} - {count}"
+       redef fun stream_callback(buffer, size, count) do print "Stream_callback : {buffer} - {size} - {count}"
 end
 
 
index 084b68a..688493e 100644 (file)
@@ -49,12 +49,12 @@ extern class Window `{WINDOW *`}
 
        # Clear the entire window so it can be repainted from scratch with a refresh
        fun wclear `{
-               wclear(recv);
+               wclear(self);
        `}
 
        # Delete the window
        fun delwin `{
-               delwin(recv);
+               delwin(self);
        `}
 
        # Suspend the curses session and restore the previous terminal
index d062cfc..781c2a4 100644 (file)
@@ -40,10 +40,10 @@ extern class EGLDisplay `{ EGLDisplay `}
        new current `{ return eglGetCurrentDisplay(); `}
        new(handle: Pointer) `{ return eglGetDisplay(handle); `}
 
-       fun is_valid: Bool `{ return recv != EGL_NO_DISPLAY; `}
+       fun is_valid: Bool `{ return self != EGL_NO_DISPLAY; `}
 
        fun initialize: Bool `{
-               EGLBoolean r = eglInitialize(recv, NULL, NULL);
+               EGLBoolean r = eglInitialize(self, NULL, NULL);
                if (r == EGL_FALSE) {
                        fprintf(stderr, "Unable to eglInitialize");
                        return 0;
@@ -53,12 +53,12 @@ extern class EGLDisplay `{ EGLDisplay `}
 
        fun major_version: Int `{
                EGLint val;
-               eglInitialize(recv, &val, NULL);
+               eglInitialize(self, &val, NULL);
                return val;
        `}
        fun minor_version: Int `{
                EGLint val;
-               eglInitialize(recv, NULL, &val);
+               eglInitialize(self, NULL, &val);
                return val;
        `}
 
@@ -78,22 +78,22 @@ extern class EGLDisplay `{ EGLDisplay `}
                }
 
                // get number of configs
-               EGLBoolean r = eglChooseConfig(recv, c_attribs, NULL, 0, &n_configs);
+               EGLBoolean r = eglChooseConfig(self, c_attribs, NULL, 0, &n_configs);
 
                if (r == EGL_FALSE) {
-                       EGLDisplay_report_egl_error(recv, "failed to get number of available configs.");
+                       EGLDisplay_report_egl_error(self, "failed to get number of available configs.");
                        return null_Array_of_EGLConfig();
                } else if (n_configs == 0) {
-                       EGLDisplay_report_egl_error(recv, "no config available.");
+                       EGLDisplay_report_egl_error(self, "no config available.");
                        return null_Array_of_EGLConfig();
                }
 
                configs = (EGLConfig*)malloc(sizeof(EGLConfig)*n_configs);
  
-               r = eglChooseConfig(recv, c_attribs, configs, n_configs, &n_configs);
+               r = eglChooseConfig(self, c_attribs, configs, n_configs, &n_configs);
 
                if (r == EGL_FALSE) {
-                       EGLDisplay_report_egl_error(recv, "failed to load config.");
+                       EGLDisplay_report_egl_error(self, "failed to load config.");
                        return null_Array_of_EGLConfig();
                } else {
                        Array_of_EGLConfig array = new_Array_of_EGLConfig();
@@ -107,7 +107,7 @@ extern class EGLDisplay `{ EGLDisplay `}
        # Can be used directly, but it is preferable to use a `EGLConfigAttribs`
        fun config_attrib(config: EGLConfig, attribute: Int): Int `{
                EGLint val;
-               EGLBoolean r = eglGetConfigAttrib(recv, config, attribute, &val);
+               EGLBoolean r = eglGetConfigAttrib(self, config, attribute, &val);
                if (r == EGL_FALSE)
                        return -1;
                else
@@ -115,23 +115,23 @@ extern class EGLDisplay `{ EGLDisplay `}
        `}
 
        fun terminate: Bool `{
-               return eglTerminate(recv) == EGL_TRUE;
+               return eglTerminate(self) == EGL_TRUE;
        `}
 
        fun create_window_surface(config: EGLConfig, native_window: Pointer, attribs: Array[Int]): EGLSurface `{
-               EGLSurface surface = eglCreateWindowSurface(recv, config, (EGLNativeWindowType)native_window, NULL);
+               EGLSurface surface = eglCreateWindowSurface(self, config, (EGLNativeWindowType)native_window, NULL);
                return surface;
        `}
 
        # TODO add share_context
        fun create_context(config: EGLConfig): EGLContext `{
                EGLint context_attribs[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE}; // TODO move out!
-               EGLContext context = eglCreateContext(recv, config, EGL_NO_CONTEXT, context_attribs);
+               EGLContext context = eglCreateContext(self, config, EGL_NO_CONTEXT, context_attribs);
                return context;
        `}
 
        fun make_current(draw, read: EGLSurface, context: EGLContext): Bool `{
-               if (eglMakeCurrent(recv, draw, read, context) == EGL_FALSE) {
+               if (eglMakeCurrent(self, draw, read, context) == EGL_FALSE) {
                        fprintf(stderr, "Unable to eglMakeCurrent");
                        return 0;
                }
@@ -141,7 +141,7 @@ extern class EGLDisplay `{ EGLDisplay `}
        # Can be used directly, but it is preferable to use a `EGLSurfaceAttribs`
        fun query_surface(surface: EGLSurface, attribute: Int): Int `{
                int val;
-               EGLBoolean r = eglQuerySurface(recv, surface, attribute, &val);
+               EGLBoolean r = eglQuerySurface(self, surface, attribute, &val);
                if (r == EGL_FALSE)
                        return -1;
                else
@@ -149,11 +149,11 @@ extern class EGLDisplay `{ EGLDisplay `}
        `}
 
        fun destroy_context(context: EGLContext): Bool `{
-               return eglDestroyContext(recv, context);
+               return eglDestroyContext(self, context);
        `}
 
        fun destroy_surface(surface: EGLSurface): Bool `{
-               return eglDestroySurface(recv, surface);
+               return eglDestroySurface(self, surface);
        `}
 
        fun error: EGLError `{ return eglGetError(); `}
@@ -169,7 +169,7 @@ extern class EGLDisplay `{ EGLDisplay `}
        end
 
        private fun query_string(name: Int): String import NativeString.to_s `{
-               return NativeString_to_s((char *)eglQueryString(recv, name));
+               return NativeString_to_s((char *)eglQueryString(self, name));
        `}
 
        fun vendor: String do return query_string(0x3053)
@@ -180,7 +180,7 @@ extern class EGLDisplay `{ EGLDisplay `}
 
        fun client_apis: Array[String] do return query_string(0x308D).split_with(" ")
 
-       fun swap_buffers(surface: EGLSurface) `{ eglSwapBuffers(recv, surface); `}
+       fun swap_buffers(surface: EGLSurface) `{ eglSwapBuffers(self, surface); `}
 end
 
 extern class EGLConfig `{ EGLConfig `}
@@ -194,7 +194,7 @@ extern class EGLSurface `{ EGLSurface `}
        new current_read `{ return eglGetCurrentSurface(EGL_READ); `}
        new none `{ return EGL_NO_SURFACE; `}
 
-       fun is_ok: Bool `{ return recv != EGL_NO_SURFACE; `}
+       fun is_ok: Bool `{ return self != EGL_NO_SURFACE; `}
 
        fun attribs(display: EGLDisplay): EGLSurfaceAttribs do
                return new EGLSurfaceAttribs(display, self)
@@ -205,7 +205,7 @@ extern class EGLContext `{ EGLContext `}
        new current `{ return eglGetCurrentContext(); `}
        new none `{ return EGL_NO_CONTEXT; `}
 
-       fun is_ok: Bool `{ return recv != EGL_NO_CONTEXT; `}
+       fun is_ok: Bool `{ return self != EGL_NO_CONTEXT; `}
 end
 
 # Attributes of a config for a given EGL display
@@ -235,20 +235,20 @@ end
 
 extern class EGLConfigCaveat `{ EGLint `}
        new from_i(val: Int) `{ return (EGLint)val; `}
-       fun to_i: Int `{ return recv; `}
+       fun to_i: Int `{ return self; `}
 
        new none `{ return EGL_NONE; `}
-       fun is_none: Bool `{ return recv == EGL_NONE; `}
+       fun is_none: Bool `{ return self == EGL_NONE; `}
 
        new dont_care `{ return EGL_DONT_CARE; `}
-       fun is_dont_care: Bool `{ return recv == EGL_DONT_CARE; `}
+       fun is_dont_care: Bool `{ return self == EGL_DONT_CARE; `}
 
        new slow `{ return EGL_SLOW_CONFIG; `}
-       fun is_slow: Bool `{ return recv == EGL_SLOW_CONFIG; `}
+       fun is_slow: Bool `{ return self == EGL_SLOW_CONFIG; `}
 
        # Obselete since EGL 1.3, use EGL_CONFORMANT instead
        new non_conformant `{ return EGL_NON_CONFORMANT_CONFIG; `}
-       fun is_non_conformant: Bool `{ return recv == EGL_NON_CONFORMANT_CONFIG; `}
+       fun is_non_conformant: Bool `{ return self == EGL_NON_CONFORMANT_CONFIG; `}
 
        redef fun to_s
        do
@@ -263,19 +263,19 @@ end
 extern class EGLConformant `{ EGLint `}
        new `{ return (EGLint)0; `}
        new from_i(val: Int) `{ return (EGLint)val; `}
-       fun to_i: Int `{ return recv; `}
+       fun to_i: Int `{ return self; `}
 
-       fun opengl: Bool `{ return recv & EGL_OPENGL_BIT; `}
-       fun with_opengl: EGLConformant `{ return recv | EGL_OPENGL_BIT; `}
+       fun opengl: Bool `{ return self & EGL_OPENGL_BIT; `}
+       fun with_opengl: EGLConformant `{ return self | EGL_OPENGL_BIT; `}
 
-       fun opengl_es: Bool `{ return recv & EGL_OPENGL_ES_BIT; `}
-       fun with_opengl_es: EGLConformant `{ return recv | EGL_OPENGL_ES_BIT; `}
+       fun opengl_es: Bool `{ return self & EGL_OPENGL_ES_BIT; `}
+       fun with_opengl_es: EGLConformant `{ return self | EGL_OPENGL_ES_BIT; `}
 
-       fun opengl_es2: Bool `{ return recv & EGL_OPENGL_ES2_BIT; `}
-       fun with_opengl_es2: EGLConformant `{ return recv | EGL_OPENGL_ES2_BIT; `}
+       fun opengl_es2: Bool `{ return self & EGL_OPENGL_ES2_BIT; `}
+       fun with_opengl_es2: EGLConformant `{ return self | EGL_OPENGL_ES2_BIT; `}
 
-       fun openvg: Bool `{ return recv & EGL_OPENVG_BIT; `}
-       fun with_openvg: EGLConformant `{ return recv | EGL_OPENVG_BIT; `}
+       fun openvg: Bool `{ return self & EGL_OPENVG_BIT; `}
+       fun with_openvg: EGLConformant `{ return self | EGL_OPENVG_BIT; `}
 
        fun to_a: Array[String]
        do
@@ -313,22 +313,22 @@ class EGLSurfaceAttribs
 end
 
 extern class EGLError `{ EGLint `}
-       fun is_success: Bool `{ return recv == EGL_SUCCESS; `}
-
-       fun is_not_initialized: Bool `{ return recv == EGL_NOT_INITIALIZED; `}
-       fun is_bad_access: Bool `{ return recv == EGL_BAD_ACCESS; `}
-       fun is_bad_alloc: Bool `{ return recv == EGL_BAD_ALLOC; `}
-       fun is_bad_attribute: Bool `{ return recv == EGL_BAD_ATTRIBUTE; `}
-       fun is_bad_config: Bool `{ return recv == EGL_BAD_CONFIG; `}
-       fun is_bad_context: Bool `{ return recv == EGL_BAD_CONTEXT; `}
-       fun is_bad_current_surface: Bool `{ return recv == EGL_BAD_CURRENT_SURFACE; `}
-       fun is_bad_display: Bool `{ return recv == EGL_BAD_DISPLAY; `}
-       fun is_bad_match: Bool `{ return recv == EGL_BAD_MATCH; `}
-       fun is_bad_native_pixmap: Bool `{ return recv == EGL_BAD_NATIVE_PIXMAP; `}
-       fun is_bad_native_window: Bool `{ return recv == EGL_BAD_NATIVE_WINDOW; `}
-       fun is_bad_parameter: Bool `{ return recv == EGL_BAD_PARAMETER; `}
-       fun is_bad_surface: Bool `{ return recv == EGL_BAD_SURFACE; `}
-       fun is_context_lost: Bool `{ return recv == EGL_CONTEXT_LOST; `}
+       fun is_success: Bool `{ return self == EGL_SUCCESS; `}
+
+       fun is_not_initialized: Bool `{ return self == EGL_NOT_INITIALIZED; `}
+       fun is_bad_access: Bool `{ return self == EGL_BAD_ACCESS; `}
+       fun is_bad_alloc: Bool `{ return self == EGL_BAD_ALLOC; `}
+       fun is_bad_attribute: Bool `{ return self == EGL_BAD_ATTRIBUTE; `}
+       fun is_bad_config: Bool `{ return self == EGL_BAD_CONFIG; `}
+       fun is_bad_context: Bool `{ return self == EGL_BAD_CONTEXT; `}
+       fun is_bad_current_surface: Bool `{ return self == EGL_BAD_CURRENT_SURFACE; `}
+       fun is_bad_display: Bool `{ return self == EGL_BAD_DISPLAY; `}
+       fun is_bad_match: Bool `{ return self == EGL_BAD_MATCH; `}
+       fun is_bad_native_pixmap: Bool `{ return self == EGL_BAD_NATIVE_PIXMAP; `}
+       fun is_bad_native_window: Bool `{ return self == EGL_BAD_NATIVE_WINDOW; `}
+       fun is_bad_parameter: Bool `{ return self == EGL_BAD_PARAMETER; `}
+       fun is_bad_surface: Bool `{ return self == EGL_BAD_SURFACE; `}
+       fun is_context_lost: Bool `{ return self == EGL_CONTEXT_LOST; `}
 
        redef fun to_s
        do
index b8c9798..5ec269d 100644 (file)
@@ -211,7 +211,7 @@ interface Boxed3d[N: Numeric]
                        (self.back <= other.front and other.back <= self.front))
        end
 
-       redef fun padded(dist: N): Box3d[N] do return new Box3d[N].lrtbfb(left - dist, right + dist, top + dist, bottom - dist, front + dist, back - dist)
+       redef fun padded(dist): Box3d[N] do return new Box3d[N].lrtbfb(left - dist, right + dist, top + dist, bottom - dist, front + dist, back - dist)
 end
 
 # A 3d bounded object and an implementation of Boxed
@@ -344,8 +344,8 @@ class BoxedArray[E: Boxed[Numeric]]
 
        private var data: Array[E] = new Array[E]
 
-       redef fun add(item: E) do data.add(item)
-       redef fun items_overlapping(item: Boxed[Numeric]): SimpleCollection[E]
+       redef fun add(item) do data.add(item)
+       redef fun items_overlapping(item): SimpleCollection[E]
        do
                var arr = new Array[E]
                for i in data do
index 303aae1..6c7fda6 100644 (file)
@@ -71,8 +71,8 @@ end
 class Line[N: Numeric]
        super ILine[N]
 
-       redef var point_left: P
-       redef var point_right: P
+       redef var point_left
+       redef var point_right
 
        init
        do
index 089b6ee..0218406 100644 (file)
@@ -55,14 +55,14 @@ abstract class QuadTree[E: Boxed[Numeric]]
                self.parent_node = parent
        end
 
-       redef fun items_overlapping(region :Boxed[Numeric]): SimpleCollection[E] do
+       redef fun items_overlapping(region): SimpleCollection[E] do
                var res = new Array[E]
                items_overlapping_in(region,res)
                return res
        end
 
        # add the item to the tree, create children if the limit is reached
-       redef fun add(item: E) do if self.is_leaf then self.data.add(item) else add_to_children(item)
+       redef fun add(item) do if self.is_leaf then self.data.add(item) else add_to_children(item)
 
        private fun add_to_children(item: Boxed[Numeric])
        do
@@ -93,7 +93,7 @@ abstract class QuadTree[E: Boxed[Numeric]]
                end
        end
 
-       redef fun is_empty: Bool do return data.is_empty and (self.is_leaf or (child0.is_empty and child1.is_empty and child2.is_empty and child3.is_empty))
+       redef fun is_empty do return data.is_empty and (self.is_leaf or (child0.is_empty and child1.is_empty and child2.is_empty and child3.is_empty))
 
        # Return whether or not the Node is a leaf of the tree
        fun is_leaf: Bool do return child0 == null
index 946a87c..35b13d1 100644 (file)
@@ -38,7 +38,7 @@ redef class NativeString
        #
        # For more info, SEE setlocale manual
        fun set_locale `{
-               setlocale(LC_ALL, recv);
+               setlocale(LC_ALL, self);
        `}
 end
 
@@ -55,13 +55,13 @@ redef class String
        # Gettext `gettext`, SEE gettext manual for further info
        fun gettext: String
        import String.to_cstring, NativeString.to_s `{
-               return NativeString_to_s(gettext(String_to_cstring(recv)));
+               return NativeString_to_s(gettext(String_to_cstring(self)));
        `}
 
        # Gettext `dgettext`, SEE gettext manual for further info
        fun dgettext(domain: String): String
        import String.to_cstring, NativeString.to_s `{
-               return NativeString_to_s(dgettext(String_to_cstring(domain), String_to_cstring(recv)));
+               return NativeString_to_s(dgettext(String_to_cstring(domain), String_to_cstring(self)));
        `}
 end
 
index cbf851f..6389e09 100644 (file)
@@ -84,7 +84,7 @@ end
 var config = configs.first
 
 # TODO android part
-# Opengles1Display_midway_init(recv, format);
+# Opengles1Display_midway_init(self, format);
 
 var surface = egl_display.create_window_surface(config, x11_window_handle, [0])
 assert surface.is_ok else print egl_display.error
index 5b05f8b..4e71e1f 100644 (file)
@@ -50,15 +50,15 @@ extern class GLProgram `{GLuint`}
        new `{ return glCreateProgram(); `}
 
        # Is this a valid program?
-       fun is_ok: Bool `{ return glIsProgram(recv); `}
+       fun is_ok: Bool `{ return glIsProgram(self); `}
 
        # Attach a `shader` to this program
-       fun attach_shader(shader: GLShader) `{ glAttachShader(recv, shader); `}
+       fun attach_shader(shader: GLShader) `{ glAttachShader(self, shader); `}
 
        # Set the location for the attribute by `name`
        fun bind_attrib_location(index: Int, name: String) import String.to_cstring `{
                GLchar *c_name = String_to_cstring(name);
-               glBindAttribLocation(recv, index, c_name);
+               glBindAttribLocation(self, index, c_name);
        `}
 
        # Get the location of the attribute by `name`
@@ -66,7 +66,7 @@ extern class GLProgram `{GLuint`}
        # Returns `-1` if there is no active attribute named `name`.
        fun attrib_location(name: String): Int import String.to_cstring `{
                GLchar *c_name = String_to_cstring(name);
-               return glGetAttribLocation(recv, c_name);
+               return glGetAttribLocation(self, c_name);
        `}
 
        # Get the location of the uniform by `name`
@@ -74,29 +74,29 @@ extern class GLProgram `{GLuint`}
        # Returns `-1` if there is no active uniform named `name`.
        fun uniform_location(name: String): Int import String.to_cstring `{
                GLchar *c_name = String_to_cstring(name);
-               return glGetUniformLocation(recv, c_name);
+               return glGetUniformLocation(self, c_name);
        `}
 
        # Query information on this program
        fun query(pname: Int): Int `{
                int val;
-               glGetProgramiv(recv, pname, &val);
+               glGetProgramiv(self, pname, &val);
                return val;
        `}
 
        # Try to link this program
        #
        # Check result using `in_linked` and `info_log`.
-       fun link `{ glLinkProgram(recv); `}
+       fun link `{ glLinkProgram(self); `}
 
        # Is this program linked?
        fun is_linked: Bool do return query(0x8B82) != 0
 
        # Use this program for the following operations
-       fun use `{ glUseProgram(recv); `}
+       fun use `{ glUseProgram(self); `}
 
        # Delete this program
-       fun delete `{ glDeleteProgram(recv); `}
+       fun delete `{ glDeleteProgram(self); `}
 
        # Has this program been deleted?
        fun is_deleted: Bool do return query(0x8B80) != 0
@@ -104,7 +104,7 @@ extern class GLProgram `{GLuint`}
        # Validate whether this program can be executed in the current OpenGL state
        #
        # Check results using `is_validated` and `info_log`.
-       fun validate `{ glValidateProgram(recv); `}
+       fun validate `{ glValidateProgram(self); `}
 
        # Boolean result of `validate`, must be called after `validate`
        fun is_validated: Bool do return query(0x8B83) != 0
@@ -114,9 +114,9 @@ extern class GLProgram `{GLuint`}
        # Useful with `link` and `validate`
        fun info_log: String import NativeString.to_s `{
                int size;
-               glGetProgramiv(recv, GL_INFO_LOG_LENGTH, &size);
+               glGetProgramiv(self, GL_INFO_LOG_LENGTH, &size);
                GLchar *msg = malloc(size);
-               glGetProgramInfoLog(recv, size, NULL, msg);
+               glGetProgramInfoLog(self, size, NULL, msg);
                return NativeString_to_s(msg);
        `}
 
@@ -154,7 +154,7 @@ extern class GLProgram `{GLuint`}
                char *name = malloc(max_size);
                int size;
                GLenum type;
-               glGetActiveAttrib(recv, index, max_size, NULL, &size, &type, name);
+               glGetActiveAttrib(self, index, max_size, NULL, &size, &type, name);
                return name;
        `}
 
@@ -162,7 +162,7 @@ extern class GLProgram `{GLuint`}
        fun active_attrib_size(index: Int): Int `{
                int size;
                GLenum type;
-               glGetActiveAttrib(recv, index, 0, NULL, &size, &type, NULL);
+               glGetActiveAttrib(self, index, 0, NULL, &size, &type, NULL);
                return size;
        `}
 
@@ -172,7 +172,7 @@ extern class GLProgram `{GLuint`}
        fun active_attrib_type(index: Int): GLFloatDataType `{
                int size;
                GLenum type;
-               glGetActiveAttrib(recv, index, 0, NULL, &size, &type, NULL);
+               glGetActiveAttrib(self, index, 0, NULL, &size, &type, NULL);
                return type;
        `}
 
@@ -186,7 +186,7 @@ extern class GLProgram `{GLuint`}
                char *name = malloc(max_size);
                int size;
                GLenum type;
-               glGetActiveUniform(recv, index, max_size, NULL, &size, &type, name);
+               glGetActiveUniform(self, index, max_size, NULL, &size, &type, name);
                return name;
        `}
 
@@ -194,7 +194,7 @@ extern class GLProgram `{GLuint`}
        fun active_uniform_size(index: Int): Int `{
                int size;
                GLenum type;
-               glGetActiveUniform(recv, index, 0, NULL, &size, &type, NULL);
+               glGetActiveUniform(self, index, 0, NULL, &size, &type, NULL);
                return size;
        `}
 
@@ -204,7 +204,7 @@ extern class GLProgram `{GLuint`}
        fun active_uniform_type(index: Int): GLDataType `{
                int size;
                GLenum type = 0;
-               glGetActiveUniform(recv, index, 0, NULL, &size, &type, NULL);
+               glGetActiveUniform(self, index, 0, NULL, &size, &type, NULL);
                return type;
        `}
 end
@@ -213,7 +213,7 @@ end
 extern class GLShader `{GLuint`}
        # Set the source of the shader
        fun source=(code: NativeString) `{
-               glShaderSource(recv, 1, (GLchar const **)&code, NULL);
+               glShaderSource(self, 1, (GLchar const **)&code, NULL);
        `}
 
        # Source of the shader, if available
@@ -229,42 +229,42 @@ extern class GLShader `{GLuint`}
 
        private fun source_native(size: Int): NativeString `{
                GLchar *code = malloc(size);
-               glGetShaderSource(recv, size, NULL, code);
+               glGetShaderSource(self, size, NULL, code);
                return code;
        `}
 
        # Query information on this shader
        protected fun query(pname: Int): Int `{
                int val;
-               glGetShaderiv(recv, pname, &val);
+               glGetShaderiv(self, pname, &val);
                return val;
        `}
 
        # Try to compile `source` into a binary GPU program
        #
        # Check the result using `is_compiled` and `info_log`
-       fun compile `{ glCompileShader(recv); `}
+       fun compile `{ glCompileShader(self); `}
 
        # Has this shader been compiled?
        fun is_compiled: Bool do return query(0x8B81) != 0
 
        # Delete this shader
-       fun delete `{ glDeleteShader(recv); `}
+       fun delete `{ glDeleteShader(self); `}
 
        # Has this shader been deleted?
        fun is_deleted: Bool do return query(0x8B80) != 0
 
        # Is this a valid shader?
-       fun is_ok: Bool `{ return glIsShader(recv); `}
+       fun is_ok: Bool `{ return glIsShader(self); `}
 
        # Retrieve the information log of this shader
        #
        # Useful with `link` and `validate`
        fun info_log: String import NativeString.to_s `{
                int size;
-               glGetShaderiv(recv, GL_INFO_LOG_LENGTH, &size);
+               glGetShaderiv(self, GL_INFO_LOG_LENGTH, &size);
                GLchar *msg = malloc(size);
-               glGetShaderInfoLog(recv, size, NULL, msg);
+               glGetShaderInfoLog(self, size, NULL, msg);
                return NativeString_to_s(msg);
        `}
 end
@@ -333,7 +333,7 @@ end
 # General type for OpenGL enumerations
 extern class GLEnum `{ GLenum `}
 
-       redef fun hash `{ return recv; `}
+       redef fun hash `{ return self; `}
 
        redef fun ==(o) do return o != null and is_same_type(o) and o.hash == self.hash
 end
@@ -346,13 +346,13 @@ extern class GLError
        fun is_ok: Bool do return is_no_error
 
        # Is this not an error?
-       fun is_no_error: Bool `{ return recv == GL_NO_ERROR; `}
+       fun is_no_error: Bool `{ return self == GL_NO_ERROR; `}
 
-       fun is_invalid_enum: Bool `{ return recv == GL_INVALID_ENUM; `}
-       fun is_invalid_value: Bool `{ return recv == GL_INVALID_VALUE; `}
-       fun is_invalid_operation: Bool `{ return recv == GL_INVALID_OPERATION; `}
-       fun is_invalid_framebuffer_operation: Bool `{ return recv == GL_INVALID_FRAMEBUFFER_OPERATION; `}
-       fun is_out_of_memory: Bool `{ return recv == GL_OUT_OF_MEMORY; `}
+       fun is_invalid_enum: Bool `{ return self == GL_INVALID_ENUM; `}
+       fun is_invalid_value: Bool `{ return self == GL_INVALID_VALUE; `}
+       fun is_invalid_operation: Bool `{ return self == GL_INVALID_OPERATION; `}
+       fun is_invalid_framebuffer_operation: Bool `{ return self == GL_INVALID_FRAMEBUFFER_OPERATION; `}
+       fun is_out_of_memory: Bool `{ return self == GL_OUT_OF_MEMORY; `}
 
        redef fun to_s
        do
@@ -742,13 +742,13 @@ end
 extern class GLFloatDataType
        super GLEnum
 
-       fun is_float: Bool `{ return recv == GL_FLOAT; `}
-       fun is_float_vec2: Bool `{ return recv == GL_FLOAT_VEC2; `}
-       fun is_float_vec3: Bool `{ return recv == GL_FLOAT_VEC3; `}
-       fun is_float_vec4: Bool `{ return recv == GL_FLOAT_VEC4; `}
-       fun is_float_mat2: Bool `{ return recv == GL_FLOAT_MAT2; `}
-       fun is_float_mat3: Bool `{ return recv == GL_FLOAT_MAT3; `}
-       fun is_float_mat4: Bool `{ return recv == GL_FLOAT_MAT4; `}
+       fun is_float: Bool `{ return self == GL_FLOAT; `}
+       fun is_float_vec2: Bool `{ return self == GL_FLOAT_VEC2; `}
+       fun is_float_vec3: Bool `{ return self == GL_FLOAT_VEC3; `}
+       fun is_float_vec4: Bool `{ return self == GL_FLOAT_VEC4; `}
+       fun is_float_mat2: Bool `{ return self == GL_FLOAT_MAT2; `}
+       fun is_float_mat3: Bool `{ return self == GL_FLOAT_MAT3; `}
+       fun is_float_mat4: Bool `{ return self == GL_FLOAT_MAT4; `}
 
        # Instances of `GLFloatDataType` can be equal to instances of `GLDataType`
        redef fun ==(o)
@@ -764,16 +764,16 @@ end
 extern class GLDataType
        super GLFloatDataType
 
-       fun is_int: Bool `{ return recv == GL_INT; `}
-       fun is_int_vec2: Bool `{ return recv == GL_INT_VEC2; `}
-       fun is_int_vec3: Bool `{ return recv == GL_INT_VEC3; `}
-       fun is_int_vec4: Bool `{ return recv == GL_INT_VEC4; `}
-       fun is_bool: Bool `{ return recv == GL_BOOL; `}
-       fun is_bool_vec2: Bool `{ return recv == GL_BOOL_VEC2; `}
-       fun is_bool_vec3: Bool `{ return recv == GL_BOOL_VEC3; `}
-       fun is_bool_vec4: Bool `{ return recv == GL_BOOL_VEC4; `}
-       fun is_sampler_2d: Bool `{ return recv == GL_SAMPLER_2D; `}
-       fun is_sampler_cube: Bool `{ return recv == GL_SAMPLER_CUBE; `}
+       fun is_int: Bool `{ return self == GL_INT; `}
+       fun is_int_vec2: Bool `{ return self == GL_INT_VEC2; `}
+       fun is_int_vec3: Bool `{ return self == GL_INT_VEC3; `}
+       fun is_int_vec4: Bool `{ return self == GL_INT_VEC4; `}
+       fun is_bool: Bool `{ return self == GL_BOOL; `}
+       fun is_bool_vec2: Bool `{ return self == GL_BOOL_VEC2; `}
+       fun is_bool_vec3: Bool `{ return self == GL_BOOL_VEC3; `}
+       fun is_bool_vec4: Bool `{ return self == GL_BOOL_VEC4; `}
+       fun is_sampler_2d: Bool `{ return self == GL_SAMPLER_2D; `}
+       fun is_sampler_cube: Bool `{ return self == GL_SAMPLER_CUBE; `}
 end
 
 # Kind of primitives to render with `GLES::draw_arrays`
@@ -864,11 +864,11 @@ extern class GLBuffer `{ GLbitfield `}
        new `{ return 0; `}
 
        # Add the color buffer to the returned buffer set
-       fun color: GLBuffer `{ return recv | GL_COLOR_BUFFER_BIT; `}
+       fun color: GLBuffer `{ return self | GL_COLOR_BUFFER_BIT; `}
 
        # Add the depth buffer to the returned buffer set
-       fun depth: GLBuffer `{ return recv | GL_DEPTH_BUFFER_BIT; `}
+       fun depth: GLBuffer `{ return self | GL_DEPTH_BUFFER_BIT; `}
 
        # Add the stencil buffer to the returned buffer set
-       fun stencil: GLBuffer `{ return recv | GL_STENCIL_BUFFER_BIT; `}
+       fun stencil: GLBuffer `{ return self | GL_STENCIL_BUFFER_BIT; `}
 end
index 2ceb2f4..34319dc 100644 (file)
@@ -33,83 +33,83 @@ extern class GtkAssistant `{GtkAssistant *`}
        `}
 
        fun current_page: Int `{
-               return gtk_assistant_get_current_page (recv);
+               return gtk_assistant_get_current_page (self);
        `}
 
        fun current_page=(page_num: Int) `{
-               gtk_assistant_set_current_page(recv, page_num);
+               gtk_assistant_set_current_page(self, page_num);
        `}
 
        fun number_pages: Int `{
-               return gtk_assistant_get_n_pages(recv);
+               return gtk_assistant_get_n_pages(self);
        `}
 
        fun get_page(page_num: Int): GtkWidget `{
-               return gtk_assistant_get_nth_page(recv, page_num);
+               return gtk_assistant_get_nth_page(self, page_num);
        `}
 
        fun prepend(page: GtkWidget): Int `{
-               return gtk_assistant_prepend_page(recv, page);
+               return gtk_assistant_prepend_page(self, page);
        `}
 
        fun append(page: GtkWidget): Int `{
-               return gtk_assistant_append_page(recv, page);
+               return gtk_assistant_append_page(self, page);
        `}
 
        fun insert(page: GtkWidget, position: Int): Int `{
-               return gtk_assistant_insert_page(recv, page, position);
+               return gtk_assistant_insert_page(self, page, position);
        `}
 
        fun remove(page_num: Int) `{
-               gtk_assistant_remove_page(recv, page_num);
+               gtk_assistant_remove_page(self, page_num);
        `}
 
        fun get_page_type(page: GtkWidget): GtkAssistantPageType `{
-               return gtk_assistant_get_page_type(recv, page);
+               return gtk_assistant_get_page_type(self, page);
        `}
 
        fun set_page_type(page: GtkWidget, t: GtkAssistantPageType) `{
-               gtk_assistant_set_page_type(recv, page, t);
+               gtk_assistant_set_page_type(self, page, t);
        `}
 
        fun get_page_title(page: GtkWidget): String import NativeString.to_s `{
-               return NativeString_to_s((char *)gtk_assistant_get_page_title(recv, page));
+               return NativeString_to_s((char *)gtk_assistant_get_page_title(self, page));
        `}
 
        fun set_page_title(page: GtkWidget, title: String) import String.to_cstring `{
-               gtk_assistant_set_page_title(recv, page, String_to_cstring(title));
+               gtk_assistant_set_page_title(self, page, String_to_cstring(title));
        `}
 
        fun set_page_complete(page: GtkWidget, is_complete: Bool) `{
-               gtk_assistant_set_page_complete(recv, page, is_complete);
+               gtk_assistant_set_page_complete(self, page, is_complete);
        `}
 
        fun get_page_complete(page: GtkWidget): Bool `{
-               return gtk_assistant_get_page_complete(recv, page);
+               return gtk_assistant_get_page_complete(self, page);
        `}
 
        fun remove_action_widget(child: GtkWidget) `{
-               gtk_assistant_remove_action_widget(recv, child);
+               gtk_assistant_remove_action_widget(self, child);
        `}
 
        fun add_action_widget(child: GtkWidget) `{
-               gtk_assistant_add_action_widget(recv, child);
+               gtk_assistant_add_action_widget(self, child);
        `}
 
        fun update_buttons_state `{
-               gtk_assistant_update_buttons_state(recv);
+               gtk_assistant_update_buttons_state(self);
        `}
 
        fun commit `{
-               gtk_assistant_commit(recv);
+               gtk_assistant_commit(self);
        `}
 
        fun next_page `{
-               gtk_assistant_next_page(recv);
+               gtk_assistant_next_page(self);
        `}
 
        fun previous_page `{
-               gtk_assistant_previous_page(recv);
+               gtk_assistant_previous_page(self);
        `}
 end
 
index 88e373a..b9929f5 100644 (file)
@@ -62,7 +62,7 @@ end
 # Base class for all widgets
 # See: https://developer.gnome.org/gtk3/stable/GtkWidget.html
 extern class GtkWidget `{GtkWidget *`}
-       fun show_all `{ gtk_widget_show_all(recv); `}
+       fun show_all `{ gtk_widget_show_all(self); `}
 
        fun signal_connect(signal_name: String, to_call: GtkCallable, user_data: nullable Object) import String.to_cstring, GtkCallable.signal, Object.as not nullable `{
                NitGtkSignal *data = malloc(sizeof(NitGtkSignal));
@@ -74,7 +74,7 @@ extern class GtkWidget `{GtkWidget *`}
                data->user_data = user_data;
 
                /*Use G_CALLBACK() to cast the callback function to a GCallback*/
-               g_signal_connect(recv,
+               g_signal_connect(self,
                                 String_to_cstring(signal_name),
                                 G_CALLBACK(nit_gtk_callback_func),
                                 data);
@@ -83,54 +83,54 @@ extern class GtkWidget `{GtkWidget *`}
        redef fun ==(o) do return o isa GtkWidget and equal_to_gtk_widget(o)
 
        private fun equal_to_gtk_widget(o: GtkWidget): Bool `{
-               return recv == o;
+               return self == o;
        `}
 
        fun request_size(width, height: Int) `{
-               gtk_widget_set_size_request(recv, width, height);
+               gtk_widget_set_size_request(self, width, height);
        `}
 
        fun bg_color=(state: GtkStateType, color: GdkRGBA) `{
-               gtk_widget_override_background_color(recv, state, color);
+               gtk_widget_override_background_color(self, state, color);
        `}
 
        # with gtk it's possible to set fg_color to all widget: is it correct? is fg color inherited?
        # GdkColor color;
        fun fg_color=(state: GtkStateType, color: GdkRGBA) `{
-               gtk_widget_override_color(recv, state, color);
+               gtk_widget_override_color(self, state, color);
        `}
 
        # Sets the sensitivity of a widget. sensitive -> the user can interact with it.
        # Insensitive -> widget "grayed out" and the user can"t interact with them
        fun sensitive=(sensitive: Bool) `{
-               gtk_widget_set_sensitive(recv, sensitive);
+               gtk_widget_set_sensitive(self, sensitive);
        `}
 
        # return the sensitivity of the widget
        fun sensitive: Bool `{
-               return gtk_widget_get_sensitive(recv);
+               return gtk_widget_get_sensitive(self);
        `}
 
        # Set the visibility of the widget
        fun visible=(visible: Bool) `{
-               gtk_widget_set_visible(recv, visible);
+               gtk_widget_set_visible(self, visible);
        `}
 
        # Get the visibility of the widget only
        fun visible_self: Bool `{
-               return gtk_widget_get_visible(recv);
+               return gtk_widget_get_visible(self);
        `}
 
        # Destroy the widget
-       fun destroy `{ gtk_widget_destroy(recv); `}
+       fun destroy `{ gtk_widget_destroy(self); `}
 
        # Show the widget on screen
        #
        # See: `show_all` to recursively show this widget and contained widgets.
-       fun show `{ gtk_widget_show(recv); `}
+       fun show `{ gtk_widget_show(self); `}
 
        # Hide the widget (reverse the effects of `show`)
-       fun hide `{ gtk_widget_hide(recv); `}
+       fun hide `{ gtk_widget_hide(self); `}
 end
 
 # Base class for widgets which contain other widgets
@@ -140,21 +140,21 @@ extern class GtkContainer `{GtkContainer *`}
 
        # Add a widget to the container
        fun add(widget: GtkWidget) `{
-               gtk_container_add(recv, widget);
+               gtk_container_add(self, widget);
        `}
        # Remove the widget from the container
        fun remove_widget(widget: GtkWidget) `{
-               gtk_container_remove(recv, widget);
+               gtk_container_remove(self, widget);
        `}
 
        # Get the resize mode of the container
        fun resize_mode: GtkResizeMode `{
-               return gtk_container_get_resize_mode(recv);
+               return gtk_container_get_resize_mode(self);
        `}
 
        # Set the resize mode of the container
        fun resize_mode=(resize_mode: GtkResizeMode) `{
-               gtk_container_set_resize_mode(recv, resize_mode);
+               gtk_container_set_resize_mode(self, resize_mode);
        `}
 
 end
@@ -165,7 +165,7 @@ extern class GtkBin `{GtkBin *`}
        super GtkContainer
 
        fun child: GtkWidget `{
-               return gtk_bin_get_child(recv);
+               return gtk_bin_get_child(self);
        `}
 end
 
@@ -180,11 +180,11 @@ extern class GtkWindow `{GtkWindow *`}
 
        # Connect the "destroy" signal to `quit_gtk`
        fun connect_destroy_signal_to_quit `{
-               g_signal_connect(recv, "destroy", G_CALLBACK(gtk_main_quit), NULL);
+               g_signal_connect(self, "destroy", G_CALLBACK(gtk_main_quit), NULL);
        `}
 
        fun title=(title: String) import String.to_cstring `{
-               gtk_window_set_title(recv, String_to_cstring(title));
+               gtk_window_set_title(self, String_to_cstring(title));
        `}
 
        # The "destroy" signal is emitted when a widget is destroyed, either by explicitly calling gtk_widget_destroy() or when the widget is unparented. Top-level GtkWindows are also destroyed when the Close window control button is clicked.
@@ -194,22 +194,22 @@ extern class GtkWindow `{GtkWindow *`}
        end
 
        fun resizable: Bool `{
-               return gtk_window_get_resizable(recv);
+               return gtk_window_get_resizable(self);
        `}
 
        fun resizable=(is_resizable: Bool) `{
-               return gtk_window_set_resizable(recv, is_resizable);
+               return gtk_window_set_resizable(self, is_resizable);
        `}
 
        # Activates the current focused widget within the window.
        # returns TRUE if a widget got activated.
        fun activate_focus: Bool `{
-               return gtk_window_activate_focus(recv);
+               return gtk_window_activate_focus(self);
        `}
 
        # Sets a window modal or non-modal. Modal windows prevent interaction with other windows in the same application.
        fun modal=(is_modal: Bool) `{
-               gtk_window_set_modal(recv, is_modal);
+               gtk_window_set_modal(self, is_modal);
        `}
 
        # Windows can't actually be 0x0 in size, they must be at least 1x1
@@ -217,78 +217,78 @@ extern class GtkWindow `{GtkWindow *`}
        # params width in pixels, or -1 to unset the default width
        # params height in pixels, or -1 to unset the default height
        fun default_size(width: Int, height: Int) `{
-               gtk_window_set_default_size(recv, width, height);
+               gtk_window_set_default_size(self, width, height);
        `}
 
        # Activates the default widget for the window
        # unless the current focused widget has been configured to receive the default action (see gtk_widget_set_receives_default()), in which case the focused widget is activated.
        fun activate_default: Bool `{
-               return gtk_window_activate_default(recv);
+               return gtk_window_activate_default(self);
        `}
 
        fun gravity: GdkGravity `{
-               return gtk_window_get_gravity(recv);
+               return gtk_window_get_gravity(self);
        `}
 
        fun gravity=(window_grav: GdkGravity) `{
-               gtk_window_set_gravity(recv, window_grav);
+               gtk_window_set_gravity(self, window_grav);
        `}
 
 #      fun position: GtkWindowPosition `{
-#              return gtk_window_get_position(recv);
+#              return gtk_window_get_position(self);
 #      `}
 #
 #      fun position=(window_pos: GtkWindowPosition) `{
-#              gtk_window_set_position(recv, window_pos);
+#              gtk_window_set_position(self, window_pos);
 #      `}
 
        fun active: Bool `{
-               return gtk_window_is_active(recv);
+               return gtk_window_is_active(self);
        `}
 
        # Returns whether the input focus is within this GtkWindow. For real toplevel windows, this is identical to gtk_window_is_active(), but for embedded windows, like GtkPlug, the results will differ.
        fun has_toplevel_focus: Bool `{
-               return gtk_window_has_toplevel_focus(recv);
+               return gtk_window_has_toplevel_focus(self);
        `}
 
        fun get_focus: GtkWidget `{
-               return gtk_window_get_focus(recv);
+               return gtk_window_get_focus(self);
        `}
 
        fun set_focus(widget: GtkWidget) `{
-               return gtk_window_set_focus(recv, widget);
+               return gtk_window_set_focus(self, widget);
        `}
 
        fun get_default_widget: GtkWidget `{
-               return gtk_window_get_default_widget(recv);
+               return gtk_window_get_default_widget(self);
        `}
 
        fun set_default_widget(widget: GtkWidget) `{
-               return gtk_window_set_default(recv, widget);
+               return gtk_window_set_default(self, widget);
        `}
 
        fun maximize `{
-               return gtk_window_maximize(recv);
+               return gtk_window_maximize(self);
        `}
 
        fun unmaximize `{
-               return gtk_window_unmaximize(recv);
+               return gtk_window_unmaximize(self);
        `}
 
        fun fullscreen `{
-               return gtk_window_fullscreen(recv);
+               return gtk_window_fullscreen(self);
        `}
 
        fun unfullscreen `{
-               return gtk_window_unfullscreen(recv);
+               return gtk_window_unfullscreen(self);
        `}
 
        fun keep_above=(setting: Bool) `{
-               gtk_window_set_keep_above(recv, setting);
+               gtk_window_set_keep_above(self, setting);
        `}
 
        fun keep_below=(setting: Bool) `{
-               gtk_window_set_keep_below(recv, setting);
+               gtk_window_set_keep_below(self, setting);
        `}
 end
 
@@ -302,31 +302,31 @@ extern class GtkFrame `{GtkFrame *`}
        `}
 
        fun frame_label: String `{
-               return NativeString_to_s((char *)gtk_frame_get_label(recv));
+               return NativeString_to_s((char *)gtk_frame_get_label(self));
        `}
 
        fun frame_label=(lbl: String) import String.to_cstring `{
-               gtk_frame_set_label(recv, String_to_cstring(lbl));
+               gtk_frame_set_label(self, String_to_cstring(lbl));
        `}
 
        fun label_widget: GtkWidget `{
-               return gtk_frame_get_label_widget(recv);
+               return gtk_frame_get_label_widget(self);
        `}
 
        fun label_widget=(widget: GtkWidget) `{
-               gtk_frame_set_label_widget(recv, widget);
+               gtk_frame_set_label_widget(self, widget);
        `}
 
        fun shadow_type: GtkShadowType `{
-               return gtk_frame_get_shadow_type(recv);
+               return gtk_frame_get_shadow_type(self);
        `}
 
        fun shadow_type=(stype: GtkShadowType) `{
-               gtk_frame_set_shadow_type(recv, stype);
+               gtk_frame_set_shadow_type(self, stype);
        `}
 
        fun label_align=(xalign: Float, yalign: Float) `{
-               gtk_frame_set_label_align(recv, xalign, yalign);
+               gtk_frame_set_label_align(self, xalign, yalign);
        `}
 end
 
@@ -342,22 +342,22 @@ extern class GtkGrid `{GtkGrid *`}
 
        # Set a widget child inside the grid at a given position
        fun attach(child: GtkWidget, left, top, width, height: Int) `{
-               gtk_grid_attach(recv, child, left, top, width, height);
+               gtk_grid_attach(self, child, left, top, width, height);
        `}
 
        # Get the child of the Grid at the given position
        fun get_child_at(left: Int, top: Int): GtkWidget `{
-               return gtk_grid_get_child_at(recv, left, top);
+               return gtk_grid_get_child_at(self, left, top);
        `}
 
        # Insert a row at the specified position
        fun insert_row(position:Int) `{
-               gtk_grid_insert_row(recv, position);
+               gtk_grid_insert_row(self, position);
        `}
 
        # Insert a column at the specified position
        fun insert_column(position: Int) `{
-               gtk_grid_insert_column(recv, position);
+               gtk_grid_insert_column(self, position);
        `}
 end
 
@@ -367,12 +367,12 @@ extern class GtkOrientable `{GtkOrientable *`}
 
        # Get the orientation of this widget
        fun orientation: GtkOrientation `{
-               return gtk_orientable_get_orientation(recv);
+               return gtk_orientable_get_orientation(self);
        `}
 
        # Set the orientation of this widget
        fun orientation=(orientation: GtkOrientation) `{
-               gtk_orientable_set_orientation(recv, orientation);
+               gtk_orientable_set_orientation(self, orientation);
        `}
 end
 
@@ -389,26 +389,26 @@ extern class GtkBox `{ GtkBox * `}
        `}
 
        # Give the children of `self` equal space in the box?
-       fun homogeneous: Bool `{ return gtk_box_get_homogeneous(recv); `}
+       fun homogeneous: Bool `{ return gtk_box_get_homogeneous(self); `}
 
        # Give the children of `self` equal space in the box?
        fun homogeneous=(homogeneous: Bool) `{
-               gtk_box_set_homogeneous(recv, homogeneous);
+               gtk_box_set_homogeneous(self, homogeneous);
        `}
 
        # Add `child` and pack it at the start of the box
        fun pack_start(child: GtkWidget, expand, fill: Bool, padding: Int) `{
-               gtk_box_pack_start(recv, child, expand, fill, padding);
+               gtk_box_pack_start(self, child, expand, fill, padding);
        `}
 
        # Add `child` and pack it at the end of the box
        fun pack_end(child: GtkWidget, expand, fill: Bool, padding: Int) `{
-               gtk_box_pack_end(recv, child, expand, fill, padding);
+               gtk_box_pack_end(self, child, expand, fill, padding);
        `}
 
        # Set the way `child` is packed in `self`
        fun set_child_packing(child: GtkWidget, expand, fill: Bool, padding: Int, packing: GtkPackType) `{
-               gtk_box_set_child_packing(recv, child, expand, fill, padding, packing);
+               gtk_box_set_child_packing(self, child, expand, fill, padding, packing);
        `}
 end
 
@@ -430,13 +430,13 @@ extern class GtkMisc `{GtkMisc *`}
        fun alignment: GtkAlignment is abstract
 
        fun alignment=(x: Float, y: Float) `{
-               gtk_misc_set_alignment(recv, x, y);
+               gtk_misc_set_alignment(self, x, y);
        `}
 
        fun padding: GtkAlignment is abstract
 
        fun padding=(x: Float, y: Float) `{
-               gtk_misc_set_padding(recv, x, y);
+               gtk_misc_set_padding(self, x, y);
        `}
 
 end
@@ -451,30 +451,30 @@ extern class GtkEntry `{GtkEntry *`}
        `}
 
        fun text: String import NativeString.to_s_with_copy `{
-               return NativeString_to_s_with_copy((char *)gtk_entry_get_text(recv));
+               return NativeString_to_s_with_copy((char *)gtk_entry_get_text(self));
        `}
 
        fun text=(value: String) import String.to_cstring `{
-               gtk_entry_set_text(recv, String_to_cstring(value));
+               gtk_entry_set_text(self, String_to_cstring(value));
        `}
 
        # Is the text visible or is it the invisible char (such as '*')?
        fun visiblility: Bool `{
-               return gtk_entry_get_visibility(recv);
+               return gtk_entry_get_visibility(self);
        `}
 
        # Set the text visiblility
        # If false, will use the invisible char (such as '*')
        fun visibility=(is_visible: Bool) `{
-               gtk_entry_set_visibility(recv, is_visible);
+               gtk_entry_set_visibility(self, is_visible);
        `}
 
        fun max_length: Int `{
-               return gtk_entry_get_max_length(recv);
+               return gtk_entry_get_max_length(self);
        `}
 
        fun max_length=(max: Int) `{
-               gtk_entry_set_max_length(recv, max);
+               gtk_entry_set_max_length(self, max);
        `}
 end
 
@@ -485,93 +485,93 @@ extern class GtkRange `{GtkRange *`}
 
        # Gets the current position of the fill level indicator.
        fun fill_level: Float `{
-               return gtk_range_get_fill_level(recv);
+               return gtk_range_get_fill_level(self);
        `}
 
        fun fill_level=(level: Float) `{
-               gtk_range_set_fill_level(recv, level);
+               gtk_range_set_fill_level(self, level);
        `}
 
        # Gets whether the range is restricted to the fill level.
        fun restricted_to_fill_level: Bool `{
-               return gtk_range_get_restrict_to_fill_level(recv);
+               return gtk_range_get_restrict_to_fill_level(self);
        `}
 
        fun restricted_to_fill_level=(restricted: Bool) `{
-               gtk_range_set_restrict_to_fill_level(recv, restricted);
+               gtk_range_set_restrict_to_fill_level(self, restricted);
        `}
 
        # Gets whether the range displays the fill level graphically.
        fun show_fill_level: Bool `{
-               return gtk_range_get_show_fill_level(recv);
+               return gtk_range_get_show_fill_level(self);
        `}
 
        fun show_fill_level=(is_displayed: Bool) `{
-               gtk_range_set_show_fill_level(recv, is_displayed);
+               gtk_range_set_show_fill_level(self, is_displayed);
        `}
 
        fun adjustment: GtkAdjustment `{
-               return gtk_range_get_adjustment(recv);
+               return gtk_range_get_adjustment(self);
        `}
 
        fun adjustment=(value: GtkAdjustment) `{
-               gtk_range_set_adjustment(recv, value);
+               gtk_range_set_adjustment(self, value);
        `}
 
        fun inverted: Bool `{
-               return gtk_range_get_inverted(recv);
+               return gtk_range_get_inverted(self);
        `}
 
        fun inverted=(setting: Bool) `{
-               gtk_range_set_inverted(recv, setting);
+               gtk_range_set_inverted(self, setting);
        `}
 
        fun value: Float `{
-               return gtk_range_get_value(recv);
+               return gtk_range_get_value(self);
        `}
 
        fun value=(val: Float) `{
-               gtk_range_set_value(recv, val);
+               gtk_range_set_value(self, val);
        `}
 
        fun set_increments(step: Float, page: Float) `{
-               gtk_range_set_increments(recv, step, page);
+               gtk_range_set_increments(self, step, page);
        `}
 
        fun set_range(min: Float, max: Float) `{
-               gtk_range_set_range(recv, min, max);
+               gtk_range_set_range(self, min, max);
        `}
 
        fun round_digits: Int `{
-               return gtk_range_get_round_digits(recv);
+               return gtk_range_get_round_digits(self);
        `}
 
        fun round_digits=(nb: Int) `{
-               gtk_range_set_round_digits(recv, nb);
+               gtk_range_set_round_digits(self, nb);
        `}
 
        fun size_fixed: Bool `{
-               return gtk_range_get_slider_size_fixed(recv);
+               return gtk_range_get_slider_size_fixed(self);
        `}
 
        fun size_fixed=(is_fixed: Bool) `{
-               return gtk_range_set_slider_size_fixed(recv, is_fixed);
+               return gtk_range_set_slider_size_fixed(self, is_fixed);
        `}
 
        fun flippable: Bool `{
-               return gtk_range_get_flippable(recv);
+               return gtk_range_get_flippable(self);
        `}
 
        fun min_size=(is_flippable: Bool) `{
-               return gtk_range_set_flippable(recv, is_flippable);
+               return gtk_range_set_flippable(self, is_flippable);
        `}
 
        fun min_slider_size: Int `{
-               return gtk_range_get_min_slider_size(recv);
+               return gtk_range_get_min_slider_size(self);
        `}
 
        fun min_slider_size=(size: Int) `{
-               return gtk_range_set_min_slider_size(recv, size);
+               return gtk_range_set_min_slider_size(self, size);
        `}
 end
 
@@ -589,45 +589,45 @@ extern class GtkScale `{GtkScale *`}
        `}
 
        fun digits: Int `{
-               return gtk_scale_get_digits(recv);
+               return gtk_scale_get_digits(self);
        `}
 
        fun digits=(nb_digits: Int) `{
-               gtk_scale_set_digits(recv, nb_digits);
+               gtk_scale_set_digits(self, nb_digits);
        `}
 
        fun draw_value: Bool `{
-               return gtk_scale_get_draw_value(recv);
+               return gtk_scale_get_draw_value(self);
        `}
 
        fun draw_value=(is_displayed: Bool) `{
-               gtk_scale_set_draw_value(recv, is_displayed);
+               gtk_scale_set_draw_value(self, is_displayed);
        `}
 
        fun value_position: GtkPositionType `{
-               return gtk_scale_get_value_pos(recv);
+               return gtk_scale_get_value_pos(self);
        `}
 
        fun value_position=(pos: GtkPositionType) `{
-               gtk_scale_set_value_pos(recv, pos);
+               gtk_scale_set_value_pos(self, pos);
        `}
 
        fun has_origin: Bool `{
-               return gtk_scale_get_has_origin(recv);
+               return gtk_scale_get_has_origin(self);
        `}
 
        fun has_origin=(orig: Bool) `{
-               gtk_scale_set_has_origin(recv, orig);
+               gtk_scale_set_has_origin(self, orig);
        `}
 
        fun add_mark(value: Float, position: GtkPositionType, markup: String)
        import String.to_cstring `{
-               gtk_scale_add_mark(recv, value, position, String_to_cstring(markup));
+               gtk_scale_add_mark(self, value, position, String_to_cstring(markup));
        `}
 
        # Removes any marks that have been added with gtk_scale_add_mark().
        fun clear_marks `{
-               gtk_scale_clear_marks(recv);
+               gtk_scale_clear_marks(self);
        `}
 end
 
@@ -653,23 +653,23 @@ extern class GtkLabel `{GtkLabel *`}
 
        # Set the text of the label
        fun text=(text: String) import String.to_cstring `{
-               gtk_label_set_text(recv, String_to_cstring(text));
+               gtk_label_set_text(self, String_to_cstring(text));
        `}
 
        # Returns the text of the label
        fun text: String import NativeString.to_s `{
-               return NativeString_to_s((char*)gtk_label_get_text(recv));
+               return NativeString_to_s((char*)gtk_label_get_text(self));
        `}
 
        # Sets the angle of rotation for the label.
        # An angle of 90 reads from from bottom to top, an angle of 270, from top to bottom.
        fun angle=(degre: Float) `{
-               gtk_label_set_angle(recv, degre);
+               gtk_label_set_angle(self, degre);
        `}
 
        # Returns the angle of rotation for the label.
        fun angle: Float `{
-               return gtk_label_get_angle(recv);
+               return gtk_label_get_angle(self);
        `}
 
 end
@@ -690,15 +690,15 @@ extern class GtkImage `{GtkImage *`}
        `}
 
        fun pixel_size: Int `{
-               return gtk_image_get_pixel_size(recv);
+               return gtk_image_get_pixel_size(self);
        `}
 
        fun pixel_size=(size: Int) `{
-               gtk_image_set_pixel_size(recv, size);
+               gtk_image_set_pixel_size(self, size);
        `}
 
        fun clear `{
-               gtk_image_clear(recv);
+               gtk_image_clear(self);
        `}
 end
 
@@ -738,7 +738,7 @@ extern class GtkArrow `{GtkArrow *`}
        `}
 
        fun set(arrow_type: GtkArrowType, shadow_type: GtkShadowType) `{
-               gtk_arrow_set(recv, arrow_type, shadow_type);
+               gtk_arrow_set(self, arrow_type, shadow_type);
        `}
 end
 
@@ -761,11 +761,11 @@ extern class GtkButton `{GtkButton *`}
        `}
 
        fun text: String `{
-               return NativeString_to_s((char *)gtk_button_get_label(recv));
+               return NativeString_to_s((char *)gtk_button_get_label(self));
        `}
 
        fun text=(value: String) import String.to_cstring `{
-               gtk_button_set_label(recv, String_to_cstring(value));
+               gtk_button_set_label(self, String_to_cstring(value));
        `}
 
        fun on_click(to_call: GtkCallable, user_data: nullable Object) do
@@ -809,67 +809,67 @@ extern class GtkExpander `{GtkExpander *`}
        `}
 
        fun expanded: Bool `{
-               return gtk_expander_get_expanded(recv);
+               return gtk_expander_get_expanded(self);
        `}
 
        fun expanded=(is_expanded: Bool) `{
-               gtk_expander_set_expanded(recv, is_expanded);
+               gtk_expander_set_expanded(self, is_expanded);
        `}
 
        fun spacing: Int `{
-               return gtk_expander_get_spacing(recv);
+               return gtk_expander_get_spacing(self);
        `}
 
        fun spacing=(pixels: Int) `{
-               gtk_expander_set_spacing(recv, pixels);
+               gtk_expander_set_spacing(self, pixels);
        `}
 
        fun label_text: String `{
-               return NativeString_to_s((char *)gtk_expander_get_label(recv));
+               return NativeString_to_s((char *)gtk_expander_get_label(self));
        `}
 
        fun label_text=(lbl: String) import String.to_cstring `{
-               gtk_expander_set_label(recv, String_to_cstring(lbl));
+               gtk_expander_set_label(self, String_to_cstring(lbl));
        `}
 
        fun use_underline: Bool `{
-               return gtk_expander_get_use_underline(recv);
+               return gtk_expander_get_use_underline(self);
        `}
 
        fun use_underline=(used: Bool) `{
-               gtk_expander_set_use_underline(recv, used);
+               gtk_expander_set_use_underline(self, used);
        `}
 
        fun use_markup: Bool `{
-               return gtk_expander_get_use_markup(recv);
+               return gtk_expander_get_use_markup(self);
        `}
 
        fun use_markup=(used: Bool) `{
-                gtk_expander_set_use_markup(recv, used);
+                gtk_expander_set_use_markup(self, used);
        `}
 
        fun label_widget: GtkWidget `{
-               return gtk_expander_get_label_widget(recv);
+               return gtk_expander_get_label_widget(self);
        `}
 
        fun label_widget=(widget: GtkWidget) `{
-               gtk_expander_set_label_widget(recv, widget);
+               gtk_expander_set_label_widget(self, widget);
        `}
 
        fun label_fill: Bool `{
-               return gtk_expander_get_label_fill(recv);
+               return gtk_expander_get_label_fill(self);
        `}
 
        fun label_fill=(fill: Bool) `{
-               gtk_expander_set_label_fill(recv, fill);
+               gtk_expander_set_label_fill(self, fill);
        `}
 
        fun resize_toplevel: Bool `{
-               return gtk_expander_get_resize_toplevel(recv);
+               return gtk_expander_get_resize_toplevel(self);
        `}
 
        fun resize_toplevel=(resize: Bool) `{
-               gtk_expander_set_resize_toplevel(recv, resize);
+               gtk_expander_set_resize_toplevel(self, resize);
        `}
 
 end
@@ -904,87 +904,87 @@ extern class GtkComboBox `{GtkComboBox *`}
        `}
 
        fun wrap_width: Int `{
-               return gtk_combo_box_get_wrap_width(recv);
+               return gtk_combo_box_get_wrap_width(self);
        `}
 
        fun wrap_width=(width: Int) `{
-               gtk_combo_box_set_wrap_width(recv, width);
+               gtk_combo_box_set_wrap_width(self, width);
        `}
 
        fun row_span_col: Int `{
-               return gtk_combo_box_get_row_span_column(recv);
+               return gtk_combo_box_get_row_span_column(self);
        `}
 
        fun row_span_col=(row_span: Int) `{
-               gtk_combo_box_set_row_span_column(recv, row_span);
+               gtk_combo_box_set_row_span_column(self, row_span);
        `}
 
        fun col_span_col: Int `{
-               return gtk_combo_box_get_column_span_column(recv);
+               return gtk_combo_box_get_column_span_column(self);
        `}
 
        fun col_span_col=(col_span: Int) `{
-               gtk_combo_box_set_column_span_column(recv, col_span);
+               gtk_combo_box_set_column_span_column(self, col_span);
        `}
 
        fun active_item: Int `{
-               return gtk_combo_box_get_active(recv);
+               return gtk_combo_box_get_active(self);
        `}
 
        fun active_item=(active: Int) `{
-               gtk_combo_box_set_active(recv, active);
+               gtk_combo_box_set_active(self, active);
        `}
 
        fun column_id: Int `{
-               return gtk_combo_box_get_id_column(recv);
+               return gtk_combo_box_get_id_column(self);
        `}
 
        fun column_id=(id_column: Int) `{
-               gtk_combo_box_set_id_column(recv, id_column);
+               gtk_combo_box_set_id_column(self, id_column);
        `}
 
        fun active_id: String `{
-               return NativeString_to_s((char *)gtk_combo_box_get_active_id(recv));
+               return NativeString_to_s((char *)gtk_combo_box_get_active_id(self));
        `}
 
        fun active_id=(id_active: String) import String.to_cstring `{
-               gtk_combo_box_set_active_id(recv, String_to_cstring(id_active));
+               gtk_combo_box_set_active_id(self, String_to_cstring(id_active));
        `}
 
        fun model: GtkTreeModel `{
-               return gtk_combo_box_get_model(recv);
+               return gtk_combo_box_get_model(self);
        `}
 
        fun model=(model: GtkTreeModel) `{
-               gtk_combo_box_set_model(recv, model);
+               gtk_combo_box_set_model(self, model);
        `}
 
        fun popup `{
-               gtk_combo_box_popup(recv);
+               gtk_combo_box_popup(self);
        `}
 
        fun popdown `{
-               gtk_combo_box_popdown(recv);
+               gtk_combo_box_popdown(self);
        `}
 
        fun title: String `{
-               return NativeString_to_s((char *)gtk_combo_box_get_title(recv));
+               return NativeString_to_s((char *)gtk_combo_box_get_title(self));
        `}
 
        fun title=(t: String) import String.to_cstring `{
-               gtk_combo_box_set_title(recv, String_to_cstring(t));
+               gtk_combo_box_set_title(self, String_to_cstring(t));
        `}
 
        fun has_entry: Bool `{
-               return gtk_combo_box_get_has_entry(recv);
+               return gtk_combo_box_get_has_entry(self);
        `}
 
        fun with_fixed: Bool `{
-               return gtk_combo_box_get_popup_fixed_width(recv);
+               return gtk_combo_box_get_popup_fixed_width(self);
        `}
 
        fun with_fixed=(fixed: Bool) `{
-               gtk_combo_box_set_popup_fixed_width(recv, fixed);
+               gtk_combo_box_set_popup_fixed_width(self, fixed);
        `}
 end
 
@@ -998,11 +998,11 @@ extern class GtkSpinner `{GtkSpinner *`}
        `}
 
        fun start `{
-               return gtk_spinner_start(recv);
+               return gtk_spinner_start(self);
        `}
 
        fun stop `{
-               return gtk_spinner_stop(recv);
+               return gtk_spinner_stop(self);
        `}
 end
 
@@ -1016,11 +1016,11 @@ extern class GtkSwitch `{GtkSwitch *`}
        `}
 
        fun active: Bool `{
-               return gtk_switch_get_active(recv);
+               return gtk_switch_get_active(self);
        `}
 
        fun active=(is_active: Bool) `{
-               return gtk_switch_set_active(recv, is_active);
+               return gtk_switch_set_active(self, is_active);
        `}
 end
 
@@ -1034,7 +1034,7 @@ extern class GtkAlignment `{GtkAlignment *`}
        `}
 
        fun set (xalign: Float, yalign: Float, xscale: Float, yscale: Float) `{
-               gtk_alignment_set(recv, xalign, yalign, xscale, yscale);
+               gtk_alignment_set(self, xalign, yalign, xscale, yscale);
        `}
 
 end
index f97ce3a..d4ff95f 100644 (file)
@@ -39,7 +39,7 @@ extern class GtkDialog `{GtkDialog *`}
        `}
 
        fun run `{
-               gtk_dialog_run(recv);
+               gtk_dialog_run(self);
        `}
 end
 
@@ -53,71 +53,71 @@ extern class GtkAboutDialog `{GtkAboutDialog *`}
        `}
 
        fun program_name: String import NativeString.to_s `{
-               return NativeString_to_s((char *)gtk_about_dialog_get_program_name(recv));
+               return NativeString_to_s((char *)gtk_about_dialog_get_program_name(self));
        `}
 
        fun program_name=(name: String) import String.to_cstring `{
-               gtk_about_dialog_set_program_name(recv, String_to_cstring(name));
+               gtk_about_dialog_set_program_name(self, String_to_cstring(name));
        `}
 
        fun version: String import NativeString.to_s `{
-               return NativeString_to_s((char *)gtk_about_dialog_get_version(recv));
+               return NativeString_to_s((char *)gtk_about_dialog_get_version(self));
        `}
 
        fun version=(v: String) import String.to_cstring `{
-               gtk_about_dialog_set_version(recv, String_to_cstring(v));
+               gtk_about_dialog_set_version(self, String_to_cstring(v));
        `}
 
        fun copyright: String import NativeString.to_s `{
-               return NativeString_to_s((char *)gtk_about_dialog_get_copyright(recv));
+               return NativeString_to_s((char *)gtk_about_dialog_get_copyright(self));
        `}
 
        fun copyright=(c: String) import String.to_cstring `{
-               gtk_about_dialog_set_copyright(recv, String_to_cstring(c));
+               gtk_about_dialog_set_copyright(self, String_to_cstring(c));
        `}
 
        fun comments: String import NativeString.to_s `{
-               return NativeString_to_s((char *)gtk_about_dialog_get_comments(recv));
+               return NativeString_to_s((char *)gtk_about_dialog_get_comments(self));
        `}
 
        fun comments=(com: String) import String.to_cstring `{
-               gtk_about_dialog_set_comments(recv, String_to_cstring(com));
+               gtk_about_dialog_set_comments(self, String_to_cstring(com));
        `}
 
        fun license: String import NativeString.to_s `{
-               return NativeString_to_s((char *)gtk_about_dialog_get_license(recv));
+               return NativeString_to_s((char *)gtk_about_dialog_get_license(self));
        `}
 
        fun license=(li: String) import String.to_cstring `{
-               gtk_about_dialog_set_license(recv, String_to_cstring(li));
+               gtk_about_dialog_set_license(self, String_to_cstring(li));
        `}
 
        # license_type
 
        fun website: String import NativeString.to_s `{
-               return NativeString_to_s((char *)gtk_about_dialog_get_website(recv));
+               return NativeString_to_s((char *)gtk_about_dialog_get_website(self));
        `}
 
        fun website=(link: String) import String.to_cstring `{
-               gtk_about_dialog_set_website(recv, String_to_cstring(link));
+               gtk_about_dialog_set_website(self, String_to_cstring(link));
        `}
 
        fun website_label: String import NativeString.to_s `{
-               return NativeString_to_s((char *) gtk_about_dialog_get_website_label(recv));
+               return NativeString_to_s((char *) gtk_about_dialog_get_website_label(self));
        `}
 
        fun website_label=(link_label: String) import String.to_cstring `{
-               gtk_about_dialog_set_website_label(recv, String_to_cstring(link_label));
+               gtk_about_dialog_set_website_label(self, String_to_cstring(link_label));
        `}
 
        # TODO
        # fun authors: String`{
-       #               return NativeString_to_s(gtk_about_dialog_get_authors(recv));
+       #               return NativeString_to_s(gtk_about_dialog_get_authors(self));
        # `}
 
        # TODO
        # fun authors=(authors_list: String) import String.to_cstring`{
-       #       gtk_about_dialog_set_authors(recv, String_to_cstring(authors_list));
+       #       gtk_about_dialog_set_authors(self, String_to_cstring(authors_list));
        # `}
 
        fun show_about_dialog(parent: GtkWindow, params: String)
@@ -142,14 +142,14 @@ extern class GtkAppChooserDialog `{GtkAppChooserDialog *`}
                        parent, flags, String_to_cstring(content_type));
        `}
 
-       fun widget: GtkWidget `{ return gtk_app_chooser_dialog_get_widget(recv); `}
+       fun widget: GtkWidget `{ return gtk_app_chooser_dialog_get_widget(self); `}
 
        fun heading: String import NativeString.to_s `{
-               return NativeString_to_s((char *)gtk_app_chooser_dialog_get_heading(recv));
+               return NativeString_to_s((char *)gtk_app_chooser_dialog_get_heading(self));
        `}
 
        fun heading=(text: String) import String.to_cstring `{
-               gtk_app_chooser_dialog_set_heading(recv, String_to_cstring(text));
+               gtk_app_chooser_dialog_set_heading(self, String_to_cstring(text));
        `}
 
 end
index 2a98464..e114d9d 100644 (file)
@@ -29,36 +29,36 @@ extern class GtkCalendar `{GtkCalendar *`}
        `}
 
        fun month=(month: Int, year: Int) `{
-               gtk_calendar_select_month(recv, month, year);
+               gtk_calendar_select_month(self, month, year);
        `}
 
        fun day=(day: Int) `{
-               gtk_calendar_select_day(recv, day);
+               gtk_calendar_select_day(self, day);
        `}
 
        fun mark_day(day: Int) `{
-               gtk_calendar_mark_day(recv, day);
+               gtk_calendar_mark_day(self, day);
        `}
 
        fun unmark_day(day: Int) `{
-               gtk_calendar_unmark_day(recv, day);
+               gtk_calendar_unmark_day(self, day);
        `}
 
        fun is_marked(day: Int): Bool `{
-               return gtk_calendar_get_day_is_marked(recv, day);
+               return gtk_calendar_get_day_is_marked(self, day);
        `}
 
    fun clear_marks `{
-               gtk_calendar_clear_marks(recv);
+               gtk_calendar_clear_marks(self);
        `}
 
        fun display_options: GtkCalendarDisplayOptions `{
-               return gtk_calendar_get_display_options(recv);
+               return gtk_calendar_get_display_options(self);
        `}
 
 
        fun display_options=(options: GtkCalendarDisplayOptions) `{
-               gtk_calendar_set_display_options(recv, options);
+               gtk_calendar_set_display_options(self, options);
        `}
 
        # date en nit...
@@ -96,47 +96,47 @@ extern class GtkProgressBar `{GtkProgressBar *`}
        `}
 
        fun pulse `{
-               gtk_progress_bar_pulse(recv);
+               gtk_progress_bar_pulse(self);
        `}
 
        fun pulse_step: Float `{
-               return gtk_progress_bar_get_pulse_step(recv);
+               return gtk_progress_bar_get_pulse_step(self);
        `}
 
        fun pulse_step=(step: Float) `{
-               gtk_progress_bar_set_pulse_step(recv, step);
+               gtk_progress_bar_set_pulse_step(self, step);
        `}
 
        fun fraction: Float `{
-               return gtk_progress_bar_get_fraction(recv);
+               return gtk_progress_bar_get_fraction(self);
        `}
 
        fun fraction=(fraction: Float) `{
-               gtk_progress_bar_set_fraction(recv, fraction);
+               gtk_progress_bar_set_fraction(self, fraction);
        `}
 
        fun inverted: Bool `{
-               return gtk_progress_bar_get_inverted(recv);
+               return gtk_progress_bar_get_inverted(self);
        `}
 
        fun inverted=(is_inverted: Bool) `{
-               gtk_progress_bar_set_inverted(recv, is_inverted);
+               gtk_progress_bar_set_inverted(self, is_inverted);
        `}
 
        fun show_text: Bool `{
-               return gtk_progress_bar_get_show_text(recv);
+               return gtk_progress_bar_get_show_text(self);
        `}
 
        fun show_text=(show: Bool) `{
-               gtk_progress_bar_set_show_text(recv, show);
+               gtk_progress_bar_set_show_text(self, show);
        `}
 
        fun text: String import NativeString.to_s `{
-               return NativeString_to_s((char *)gtk_progress_bar_get_text(recv));
+               return NativeString_to_s((char *)gtk_progress_bar_get_text(self));
        `}
 
        fun text=(value: String) import String.to_cstring `{
-               gtk_progress_bar_set_text(recv, String_to_cstring(value));
+               gtk_progress_bar_set_text(self, String_to_cstring(value));
        `}
 
        fun ellipsize is abstract
@@ -150,11 +150,11 @@ extern class GtkColorSelectionDialog
        `}
 
        # fun color_selection:  `{
-       #       return gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(recv));
+       #       return gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(self));
        # `}
 
        # fun color: Float `{
-       #       return gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(recv));
+       #       return gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(self));
        # `}
 end
 
@@ -172,35 +172,35 @@ extern class GtkSpinButton `{GtkSpinButton *`}
        `}
 
        fun configure (adjustment: GtkAdjustment, climb_rate: Float, digits: Int) `{
-               gtk_spin_button_configure(recv, adjustment, climb_rate, digits);
+               gtk_spin_button_configure(self, adjustment, climb_rate, digits);
        `}
 
        fun adjustment: GtkAdjustment `{
-               return gtk_spin_button_get_adjustment(recv);
+               return gtk_spin_button_get_adjustment(self);
        `}
 
        fun adjustment=(value: GtkAdjustment) `{
-               gtk_spin_button_set_adjustment(recv, value);
+               gtk_spin_button_set_adjustment(self, value);
        `}
 
        fun digits: Int `{
-               return gtk_spin_button_get_digits(recv);
+               return gtk_spin_button_get_digits(self);
        `}
 
        fun digits=(nb_digits: Int) `{
-               gtk_spin_button_set_digits(recv, nb_digits);
+               gtk_spin_button_set_digits(self, nb_digits);
        `}
 
        fun value: Float `{
-               return gtk_spin_button_get_value(recv);
+               return gtk_spin_button_get_value(self);
        `}
 
        fun val=(val: Float) `{
-               gtk_spin_button_set_value(recv, val);
+               gtk_spin_button_set_value(self, val);
        `}
 
        fun spin(direction: GtkSpinType, increment: Float)`{
-               gtk_spin_button_spin(recv, direction, increment);
+               gtk_spin_button_spin(self, direction, increment);
        `}
 end
 
index ec2de93..be3cd50 100644 (file)
@@ -35,14 +35,14 @@ redef extern class GtkEntry
        #
        # Can be used by on-screen keyboards and other input methods to adjust their behaviour.
        fun input_purpose: GtkInputPurpose `{
-               return gtk_entry_get_input_purpose(recv);
+               return gtk_entry_get_input_purpose(self);
        `}
 
        # Input purpose, tweaks the behavior of this widget
        #
        # Can be used by on-screen keyboards and other input methods to adjust their behaviour.
        fun input_purpose=(purpose: GtkInputPurpose) `{
-               gtk_entry_set_input_purpose(recv, purpose);
+               gtk_entry_set_input_purpose(self, purpose);
        `}
 end
 
index 16b4167..71d481f 100644 (file)
@@ -22,6 +22,6 @@ import v3_6
 redef class GtkWidget
        # Get the visibility of the widget, check if it's parents are visible too
        fun visible: Bool `{
-               return gtk_widget_is_visible(recv);
+               return gtk_widget_is_visible(self);
        `}
 end
index 0e337bc..c90c05b 100644 (file)
@@ -115,8 +115,8 @@ redef class App
 
        # Register `self` globally in C so it can be retrieved from iOS callbacks
        private fun register_globally in "ObjC" `{
-               App_incr_ref(recv);
-               app_nit_ios_app = recv;
+               App_incr_ref(self);
+               app_nit_ios_app = self;
        `}
 
        # Entry point to the iOS framework
index 3269906..5a50230 100644 (file)
@@ -37,17 +37,17 @@ redef class AppDelegate
                NSLog(@"Hello World!");
 
                // Display "Hello world!" on the screen
-               recv.window = [[UIWindow alloc] initWithFrame:
+               self.window = [[UIWindow alloc] initWithFrame:
                [[UIScreen mainScreen] bounds]];
-               recv.window.backgroundColor = [UIColor whiteColor];
+               self.window.backgroundColor = [UIColor whiteColor];
 
                UILabel *label = [[UILabel alloc] init];
                label.text = @"Hello World!";
                label.center = CGPointMake(100, 100);
                [label sizeToFit];
 
-               [recv.window addSubview: label];
-               [recv.window makeKeyAndVisible];
+               [self.window addSubview: label];
+               [self.window makeKeyAndVisible];
 
                return YES;
        `}
index 4da0250..37f822e 100644 (file)
@@ -56,11 +56,11 @@ extern class JavaFloatArray in "Java" `{ float[] `}
        # Get a new array of the given `size`
        new(size: Int) in "Java" `{ return new float[(int)size]; `}
 
-       redef fun [](i) in "Java" `{ return (double)recv[(int)i]; `}
+       redef fun [](i) in "Java" `{ return (double)self[(int)i]; `}
 
-       redef fun []=(i, e) in "Java" `{ recv[(int)i] = (float)e; `}
+       redef fun []=(i, e) in "Java" `{ self[(int)i] = (float)e; `}
 
-       redef fun length in "Java" `{ return recv.length; `}
+       redef fun length in "Java" `{ return self.length; `}
 end
 
 # Java primitive array `double[]`
@@ -70,11 +70,11 @@ extern class JavaDoubleArray in "Java" `{ double[] `}
        # Get a new array of the given `size`
        new(size: Int) in "Java" `{ return new double[(int)size]; `}
 
-       redef fun [](i) in "Java" `{ return recv[(int)i]; `}
+       redef fun [](i) in "Java" `{ return self[(int)i]; `}
 
-       redef fun []=(i, e) in "Java" `{ recv[(int)i] = (float)e; `}
+       redef fun []=(i, e) in "Java" `{ self[(int)i] = (float)e; `}
 
-       redef fun length in "Java" `{ return recv.length; `}
+       redef fun length in "Java" `{ return self.length; `}
 end
 
 # Java primitive array `Object[]`
@@ -84,11 +84,11 @@ extern class JavaArray in "Java" `{ java.lang.Object[] `}
        # Get a new array of the given `size`
        new(size: Int) in "Java" `{ return new Object[(int)size]; `}
 
-       redef fun [](i) in "Java" `{ return recv[(int)i]; `}
+       redef fun [](i) in "Java" `{ return self[(int)i]; `}
 
-       redef fun []=(i, e) in "Java" `{ recv[(int)i] = e; `}
+       redef fun []=(i, e) in "Java" `{ self[(int)i] = e; `}
 
-       redef fun length in "Java" `{ return recv.length; `}
+       redef fun length in "Java" `{ return self.length; `}
 end
 
 # TODO other primitive arrays:
index 4ab4eab..6731c85 100644 (file)
@@ -33,45 +33,45 @@ in "Java" `{
 extern class NativeFile in "Java" `{ java.io.File `}
        super JavaObject
 
-       fun can_execute: Bool in "Java" `{ return recv.canExecute(); `}
-       fun can_read: Bool in "Java" `{ return recv.canRead(); `}
-       fun can_write: Bool in "Java" `{ return recv.canWrite(); `}
+       fun can_execute: Bool in "Java" `{ return self.canExecute(); `}
+       fun can_read: Bool in "Java" `{ return self.canRead(); `}
+       fun can_write: Bool in "Java" `{ return self.canWrite(); `}
        fun create_file: Bool in "Java" `{
                try {
-                       return recv.createNewFile();
+                       return self.createNewFile();
                }catch(IOException e){
                        e.printStackTrace();
                        return false;
                }
        `}
-       fun delete: Bool in "Java" `{ return recv.delete(); `}
-       fun delete_on_exit in "Java" `{ recv.deleteOnExit(); `}
-       fun exists: Bool in "Java" `{ return recv.exists(); `}
-       fun absolute_file: NativeFile in "Java" `{ return recv.getAbsoluteFile(); `}
-       fun absolute_path: JavaString in "Java" `{ return recv.getAbsolutePath(); `}
+       fun delete: Bool in "Java" `{ return self.delete(); `}
+       fun delete_on_exit in "Java" `{ self.deleteOnExit(); `}
+       fun exists: Bool in "Java" `{ return self.exists(); `}
+       fun absolute_file: NativeFile in "Java" `{ return self.getAbsoluteFile(); `}
+       fun absolute_path: JavaString in "Java" `{ return self.getAbsolutePath(); `}
        fun canonical_file: NativeFile in "Java" `{
                try {
-                       return recv.getCanonicalFile();
+                       return self.getCanonicalFile();
                }catch(IOException e){
                        e.printStackTrace();
                        return null;
                }
        `}
-       fun free_space: Int in "Java" `{ return (int)recv.getFreeSpace(); `}
-       fun name: JavaString in "Java" `{ return recv.getName(); `}
-       fun parent: JavaString in "Java" `{ return recv.getParent(); `}
-       fun parent_file: NativeFile in "Java" `{ return recv.getParentFile(); `}
-       fun path: JavaString in "Java" `{ return recv.getPath(); `}
-       fun total_space: Int in "Java" `{ return (int)recv.getTotalSpace(); `}
-       fun usable_space: Int in "Java" `{ return (int)recv.getUsableSpace(); `}
-       fun absolute: Bool in "Java" `{ return recv.isAbsolute(); `}
-       fun is_directory: Bool in "Java" `{ return recv.isDirectory(); `}
-       fun is_file: Bool in "Java" `{ return recv.isFile(); `}
-       fun is_hidden: Bool in "Java" `{ return recv.isHidden(); `}
-       fun last_modified: Int in "Java" `{ return (int)recv.lastModified(); `}
-       fun length: Int in "Java" `{ return (int)recv.length(); `}
-       fun set_readable(r: Bool, owner_only: Bool): Bool in "Java" `{ return recv.setReadable(r, owner_only); `}
-       fun set_writable(w: Bool, owner_only: Bool): Bool in "Java" `{ return recv.setWritable(w, owner_only); `}
+       fun free_space: Int in "Java" `{ return (int)self.getFreeSpace(); `}
+       fun name: JavaString in "Java" `{ return self.getName(); `}
+       fun parent: JavaString in "Java" `{ return self.getParent(); `}
+       fun parent_file: NativeFile in "Java" `{ return self.getParentFile(); `}
+       fun path: JavaString in "Java" `{ return self.getPath(); `}
+       fun total_space: Int in "Java" `{ return (int)self.getTotalSpace(); `}
+       fun usable_space: Int in "Java" `{ return (int)self.getUsableSpace(); `}
+       fun absolute: Bool in "Java" `{ return self.isAbsolute(); `}
+       fun is_directory: Bool in "Java" `{ return self.isDirectory(); `}
+       fun is_file: Bool in "Java" `{ return self.isFile(); `}
+       fun is_hidden: Bool in "Java" `{ return self.isHidden(); `}
+       fun last_modified: Int in "Java" `{ return (int)self.lastModified(); `}
+       fun length: Int in "Java" `{ return (int)self.length(); `}
+       fun set_readable(r: Bool, owner_only: Bool): Bool in "Java" `{ return self.setReadable(r, owner_only); `}
+       fun set_writable(w: Bool, owner_only: Bool): Bool in "Java" `{ return self.setWritable(w, owner_only); `}
 end
 
 extern class NativeFileInputStream in "Java" `{ java.io.FileInputStream `}
@@ -79,7 +79,7 @@ extern class NativeFileInputStream in "Java" `{ java.io.FileInputStream `}
 
        fun available: Int in "Java" `{
                try {
-                       return recv.available();
+                       return self.available();
                }catch(IOException e){
                        e.printStackTrace();
                        return -1;
@@ -87,14 +87,14 @@ extern class NativeFileInputStream in "Java" `{ java.io.FileInputStream `}
        `}
        fun close in "Java" `{
                try {
-                       recv.close();
+                       self.close();
                }catch(IOException e){
                        e.printStackTrace();
                }
        `}
        fun read: Int in "Java" `{
                try {
-                       return recv.read();
+                       return self.read();
                }catch(IOException e){
                        e.printStackTrace();
                        return -1;
@@ -102,7 +102,7 @@ extern class NativeFileInputStream in "Java" `{ java.io.FileInputStream `}
        `}
        fun skip(byte_count: Int): Int in "Java" `{
                try {
-                       return (int)recv.skip(byte_count);
+                       return (int)self.skip(byte_count);
                }catch(IOException e){
                        e.printStackTrace();
                        return -1;
@@ -115,21 +115,21 @@ extern class NativeFileOutputStream in "Java" `{ java.io.FileOutputStream `}
 
        fun close in "Java" `{
                try {
-                       recv.close();
+                       self.close();
                }catch(IOException e){
                        e.printStackTrace();
                }
        `}
        fun write(one_byte: Int) in "Java" `{
                try {
-                       recv.write((byte)one_byte);
+                       self.write((byte)one_byte);
                }catch(IOException e){
                        e.printStackTrace();
                }
        `}
        fun flush in "Java" `{
                try {
-                       recv.flush();
+                       self.flush();
                }catch(IOException e){
                        e.printStackTrace();
                }
@@ -141,12 +141,12 @@ extern class NativeFileDescriptor in "Java" `{ java.io.FileDescriptor `}
 
        fun sync in "Java" `{
                try{
-                       recv.sync();
+                       self.sync();
                }catch(SyncFailedException e){
                        e.printStackTrace();
                }
        `}
-       fun valid: Bool in "Java" `{ return recv.valid(); `}
+       fun valid: Bool in "Java" `{ return self.valid(); `}
 end
 
 extern class NativeInputStream in "Java" `{ java.io.InputStream `}
@@ -154,7 +154,7 @@ extern class NativeInputStream in "Java" `{ java.io.InputStream `}
 
        fun available: Int in "Java" `{
                try {
-                       return recv.available();
+                       return self.available();
                }catch(IOException e){
                        e.printStackTrace();
                        return -1;
@@ -163,7 +163,7 @@ extern class NativeInputStream in "Java" `{ java.io.InputStream `}
 
        fun close in "Java" `{
                try {
-                       recv.close();
+                       self.close();
                }catch(IOException e){
                        e.printStackTrace();
                }
index 6358430..cef7b22 100644 (file)
@@ -77,7 +77,7 @@ redef class Sys
 
        # Get a Java class by its name from the current `jni_env`
        fun load_jclass(name: NativeString): JClass import jni_env `{
-               JNIEnv *nit_ffi_jni_env = Sys_jni_env(recv);
+               JNIEnv *nit_ffi_jni_env = Sys_jni_env(self);
 
                // retrieve the implementation Java class
                jclass java_class = (*nit_ffi_jni_env)->FindClass(nit_ffi_jni_env, name);
@@ -100,12 +100,12 @@ extern class JavaString in "Java" `{ java.lang.String `}
 
        # Get the string from Java and copy it to Nit memory
        fun to_cstring: NativeString import sys, Sys.jni_env `{
-               Sys sys = JavaString_sys(recv);
+               Sys sys = JavaString_sys(self);
                JNIEnv *env = Sys_jni_env(sys);
 
                // Get the data from Java
-               const jbyte *java_cstr = (char*)(*env)->GetStringUTFChars(env, recv, NULL);
-               jsize len = (*env)->GetStringUTFLength(env, recv);
+               const jbyte *java_cstr = (char*)(*env)->GetStringUTFChars(env, self, NULL);
+               jsize len = (*env)->GetStringUTFLength(env, self);
 
                // Copy it in control of Nit
                char *nit_cstr = (char*)malloc(len+1);
@@ -113,7 +113,7 @@ extern class JavaString in "Java" `{ java.lang.String `}
                nit_cstr[len] = '\0';
 
                // Free JNI ref and return
-               (*env)->ReleaseStringUTFChars(env, recv, java_cstr);
+               (*env)->ReleaseStringUTFChars(env, self, java_cstr);
                return nit_cstr;
        `}
 
@@ -126,9 +126,9 @@ redef class NativeString
        # This instance is only valid until the next execution of Java code.
        # You can use `new_local_ref` to keep it longer.
        fun to_java_string: JavaString import sys, Sys.jni_env `{
-               Sys sys = JavaString_sys(recv);
+               Sys sys = JavaString_sys(self);
                JNIEnv *env = Sys_jni_env(sys);
-               return (*env)->NewStringUTF(env, recv);
+               return (*env)->NewStringUTF(env, self);
        `}
 end
 
@@ -144,23 +144,23 @@ redef extern class JavaObject
        # You must use a global reference when keeping a Java object
        # across execution of Java code, per JNI specification.
        fun new_global_ref: SELF import sys, Sys.jni_env `{
-               Sys sys = JavaObject_sys(recv);
+               Sys sys = JavaObject_sys(self);
                JNIEnv *env = Sys_jni_env(sys);
-               return (*env)->NewGlobalRef(env, recv);
+               return (*env)->NewGlobalRef(env, self);
        `}
 
        # Delete this global reference
        fun delete_global_ref import sys, Sys.jni_env `{
-               Sys sys = JavaObject_sys(recv);
+               Sys sys = JavaObject_sys(self);
                JNIEnv *env = Sys_jni_env(sys);
-               (*env)->DeleteGlobalRef(env, recv);
+               (*env)->DeleteGlobalRef(env, self);
        `}
 
        # Delete this local reference
        fun delete_local_ref import sys, Sys.jni_env `{
-               Sys sys = JavaObject_sys(recv);
+               Sys sys = JavaObject_sys(self);
                JNIEnv *env = Sys_jni_env(sys);
-               (*env)->DeleteLocalRef(env, recv);
+               (*env)->DeleteLocalRef(env, self);
        `}
 
        # Pops the current local reference frame and return a valid reference to self
@@ -173,7 +173,7 @@ redef extern class JavaObject
        end
 
        private fun pop_from_local_frame_with_env(jni_env: JniEnv): SELF `{
-               return (*jni_env)->PopLocalFrame(jni_env, recv);
+               return (*jni_env)->PopLocalFrame(jni_env, self);
        `}
 
        # Is `self` null in Java?
@@ -186,10 +186,10 @@ redef extern class JavaObject
        # the return of all extern methods implemented in Java to ensure the value
        # is not a Java null. In case it is, you should replace it by a normal Nit
        # `null`.
-       fun is_java_null: Bool in "Java" `{ return recv == null; `}
+       fun is_java_null: Bool in "Java" `{ return self == null; `}
 
        # `JavaString` representation of `self` using Java's `toString`
-       fun to_java_string: JavaString in "Java" `{ return recv.toString(); `}
+       fun to_java_string: JavaString in "Java" `{ return self.toString(); `}
 
        # Use Java's `toString` for any `JavaObject`
        redef fun to_s
index d0559e0..594aac6 100644 (file)
@@ -131,8 +131,7 @@ class JsonValue
        #     assert "123".to_json_value.to_s == "123"
        #     assert "true".to_json_value.to_s == "true"
        #     assert "[1, 2, 3]".to_json_value.to_s == "123"
-       redef fun to_s: String
-       do
+       redef fun to_s do
                if value == null then return "null"
                return value.to_s
        end
index 61c6f61..4b7cb15 100644 (file)
 # ~~~
 module serialization
 
-import ::serialization
+import ::serialization::caching
 private import ::serialization::engine_tools
 private import static
 
 # Serializer of Nit objects to Json string.
 class JsonSerializer
-       super Serializer
+       super CachingSerializer
 
        # Target writing stream
        var stream: Writer
@@ -143,9 +143,9 @@ class JsonSerializer
 
        redef fun serialize_reference(object)
        do
-               if not plain_json and refs_map.has_key(object) then
+               if not plain_json and cache.has_object(object) then
                        # if already serialized, add local reference
-                       var id = ref_id_for(object)
+                       var id = cache.id_for(object)
                        stream.write "\{\"__kind\": \"ref\", \"__id\": "
                        stream.write id.to_s
                        stream.write "\}"
@@ -154,26 +154,11 @@ class JsonSerializer
                        serialize object
                end
        end
-
-       # Map of references to already serialized objects.
-       private var refs_map = new StrictHashMap[Serializable,Int]
-
-       # Get the internal serialized reference for this `object`.
-       private fun ref_id_for(object: Serializable): Int
-       do
-               if refs_map.has_key(object) then
-                       return refs_map[object]
-               else
-                       var id = refs_map.length
-                       refs_map[object] = id
-                       return id
-               end
-       end
 end
 
 # Deserializer from a Json string.
 class JsonDeserializer
-       super Deserializer
+       super CachingDeserializer
 
        # Json text to deserialize from.
        private var text: Text
@@ -184,9 +169,6 @@ class JsonDeserializer
        # Depth-first path in the serialized object tree.
        private var path = new Array[JsonObject]
 
-       # Map of references to already deserialized objects.
-       private var id_to_object = new StrictHashMap[Int, Object]
-
        # Last encountered object reference id.
        #
        # See `id_to_object`.
@@ -215,7 +197,7 @@ class JsonDeserializer
        do
                var id = just_opened_id
                if id == null then return # Register `new_object` only once
-               id_to_object[id] = new_object
+               cache[id] = new_object
        end
 
        # Convert from simple Json object to Nit object
@@ -231,8 +213,8 @@ class JsonDeserializer
                                var id = object["__id"]
                                assert id isa Int
 
-                               assert id_to_object.has_key(id)
-                               return id_to_object[id]
+                               assert cache.has_id(id)
+                               return cache.object_for(id)
                        end
 
                        # obj?
@@ -245,7 +227,7 @@ class JsonDeserializer
                                var class_name = object["__class"]
                                assert class_name isa String
 
-                               assert not id_to_object.has_key(id) else print "Error: Object with id '{id}' of {class_name} is deserialized twice."
+                               assert not cache.has_id(id) else print "Error: Object with id '{id}' of {class_name} is deserialized twice."
 
                                # advance on path
                                path.push object
@@ -291,7 +273,7 @@ end
 redef class Serializable
        private fun serialize_to_json(v: JsonSerializer)
        do
-               var id = v.ref_id_for(self)
+               var id = v.cache.new_id_for(self)
                v.stream.write "\{"
                if not v.plain_json then
                        v.stream.write "\"__kind\": \"obj\", \"__id\": "
@@ -376,7 +358,7 @@ redef class SimpleCollection[E]
        do
                # Register as pseudo object
                if not v.plain_json then
-                       var id = v.ref_id_for(self)
+                       var id = v.cache.new_id_for(self)
                        v.stream.write """{"__kind": "obj", "__id": """
                        v.stream.write id.to_s
                        v.stream.write """, "__class": """"
@@ -395,6 +377,7 @@ redef class SimpleCollection[E]
 
        redef init from_deserializer(v: Deserializer)
        do
+               super
                if v isa JsonDeserializer then
                        v.notify_of_creation self
                        init
@@ -425,7 +408,7 @@ redef class Map[K, V]
        redef fun serialize_to_json(v)
        do
                # Register as pseudo object
-               var id = v.ref_id_for(self)
+               var id = v.cache.new_id_for(self)
 
                if v.plain_json then
                        v.stream.write "\{"
@@ -466,10 +449,11 @@ redef class Map[K, V]
        # Instantiate a new `Array` from its serialized representation.
        redef init from_deserializer(v: Deserializer)
        do
-               init
+               super
 
                if v isa JsonDeserializer then
                        v.notify_of_creation self
+                       init
 
                        var length = v.deserialize_attribute("__length").as(Int)
                        var keys = v.path.last["__keys"].as(SequenceRead[nullable Object])
index 4482a93..a9e8920 100644 (file)
@@ -84,40 +84,40 @@ private extern class JavaVMInitArgs `{ JavaVMInitArgs* `}
        # Unavailable on Android, where you cannot instanciate a new JVM.
        fun set_default `{
        #ifndef ANDROID
-               JNI_GetDefaultJavaVMInitArgs(recv);
+               JNI_GetDefaultJavaVMInitArgs(self);
        #endif
        `}
 
-       fun version: Int `{ return recv->version; `}
-       fun version=(v: Int) `{ recv->version = v; `}
+       fun version: Int `{ return self->version; `}
+       fun version=(v: Int) `{ self->version = v; `}
 
-       fun options: JavaVMOptionArray `{ return recv->options; `}
-       fun options=(v: JavaVMOptionArray) `{ recv->options = v; `}
+       fun options: JavaVMOptionArray `{ return self->options; `}
+       fun options=(v: JavaVMOptionArray) `{ self->options = v; `}
 
-       fun n_options: Int `{ return recv->nOptions; `}
-       fun n_options=(v: Int) `{ recv->nOptions = v; `}
+       fun n_options: Int `{ return self->nOptions; `}
+       fun n_options=(v: Int) `{ self->nOptions = v; `}
 end
 
 private extern class JavaVMOption `{ JavaVMOption* `}
        fun string: String import NativeString.to_s `{
-               return NativeString_to_s((char*)recv->optionString);
+               return NativeString_to_s((char*)self->optionString);
        `}
        fun string=(v: String) import String.to_cstring `{
-               recv->optionString = String_to_cstring(v);
+               self->optionString = String_to_cstring(v);
        `}
 
        fun extra_info: String import NativeString.to_s `{
-               return NativeString_to_s((char*)recv->extraInfo);
+               return NativeString_to_s((char*)self->extraInfo);
        `}
        fun extra_info=(v: String) import String.to_cstring `{
-               recv->extraInfo = String_to_cstring(v);
+               self->extraInfo = String_to_cstring(v);
        `}
 end
 
 private extern class JavaVMOptionArray `{ JavaVMOption* `}
        new(size: Int) `{ return (JavaVMOption*)malloc(sizeof(JavaVMOption)*size); `}
 
-       fun [](i: Int): JavaVMOption `{ return recv+i; `}
+       fun [](i: Int): JavaVMOption `{ return self+i; `}
 end
 
 # Represents a jni JavaVM
@@ -156,12 +156,12 @@ extern class JavaVM `{JavaVM *`}
        end
 
        fun destroy `{
-               (*recv)->DestroyJavaVM(recv);
+               (*self)->DestroyJavaVM(self);
        `}
 
        fun env: JniEnv import jni_error `{
                JNIEnv *env;
-               int res = (*recv)->GetEnv(recv, (void **)&env, JNI_VERSION_1_6);
+               int res = (*self)->GetEnv(self, (void **)&env, JNI_VERSION_1_6);
                if (res != JNI_OK) {
                        JavaVM_jni_error(NULL, "Could not get JNIEnv from Java VM", res);
                        return NULL;
@@ -173,9 +173,9 @@ extern class JavaVM `{JavaVM *`}
                JNIEnv *env;
        #ifdef ANDROID
                // the signature is different (better actually) on Android
-               int res = (*recv)->AttachCurrentThread(recv, &env, NULL);
+               int res = (*self)->AttachCurrentThread(self, &env, NULL);
        #else
-               int res = (*recv)->AttachCurrentThread(recv, (void**)&env, NULL);
+               int res = (*self)->AttachCurrentThread(self, (void**)&env, NULL);
        #endif
                if (res != JNI_OK) {
                        JavaVM_jni_error(NULL, "Could not attach current thread to Java VM", res);
@@ -190,84 +190,84 @@ extern class JniEnv `{JNIEnv *`}
 
        # Get a class object from its fully-qualified name or null if the class cannot be found
        fun find_class(class_name : String): JClass import String.to_cstring `{
-               return (*recv)->FindClass(recv,String_to_cstring(class_name));
+               return (*self)->FindClass(self,String_to_cstring(class_name));
        `}
 
        # Return the method id for an instance of a class or interface
        # The method is determined by its name and signature
        # To obtain the method ID of a constructor, supply "<init>" as the method name and "void(V)" as the return type
        fun get_method_id(clazz : JClass, name : String, signature : String): JMethodID import String.to_cstring `{
-               return (*recv)->GetMethodID(recv, clazz, String_to_cstring(name), String_to_cstring(signature));
+               return (*self)->GetMethodID(self, clazz, String_to_cstring(name), String_to_cstring(signature));
        `}
 
        # Construct a new Java object from the `clazz`, using the constructor Μ€ method_id`
        fun new_object(clazz: JClass, method_id: JMethodID): JavaObject `{
-               return (*recv)->NewObject(recv, clazz, method_id);
+               return (*self)->NewObject(self, clazz, method_id);
        `}
 
        # Return the JClass of `obj`
        fun get_object_class(obj: JavaObject): JClass `{
-               return (*recv)->GetObjectClass(recv, obj);
+               return (*self)->GetObjectClass(self, obj);
        `}
 
        # Registers native methods with the class specified by the `clazz` argument
        fun register_natives(clazz: JClass, method: JNINativeMethod, n_method : Int): Int `{
-               return (*recv)->RegisterNatives(recv, clazz, method, n_method);
+               return (*self)->RegisterNatives(self, clazz, method, n_method);
        `}
 
        # Call a method on `obj` designed by `method_id` with an array `args` of arguments
        fun call_void_method(obj: JavaObject, method_id: JMethodID, args: nullable Array[nullable Object]) import convert_args_to_jni `{
-               jvalue * args_tab = JniEnv_convert_args_to_jni(recv, args);
-               (*recv)->CallVoidMethodA(recv, obj, method_id, args_tab);
+               jvalue * args_tab = JniEnv_convert_args_to_jni(self, args);
+               (*self)->CallVoidMethodA(self, obj, method_id, args_tab);
                free(args_tab);
        `}
 
        # Call a method on `obj` designed by `method_id` with an array `args` of argument returning a JavaObject
        fun call_object_method(obj: JavaObject, method_id: JMethodID, args: nullable Array[nullable Object]): JavaObject import convert_args_to_jni `{
-               jvalue * args_tab = JniEnv_convert_args_to_jni(recv, args);
-               jobject res = (*recv)->CallObjectMethod(recv, obj, method_id, args_tab);
+               jvalue * args_tab = JniEnv_convert_args_to_jni(self, args);
+               jobject res = (*self)->CallObjectMethod(self, obj, method_id, args_tab);
                free(args_tab);
                return res;
        `}
 
        # Call a method on `obj` designed by `method_id` with an array `args` of arguments returning a Bool
        fun call_boolean_method(obj: JavaObject, method_id: JMethodID, args: nullable Array[nullable Object]): Bool import convert_args_to_jni `{
-               jvalue * args_tab = JniEnv_convert_args_to_jni(recv, args);
-               jboolean res = (*recv)->CallBooleanMethod(recv, obj, method_id, args_tab);
+               jvalue * args_tab = JniEnv_convert_args_to_jni(self, args);
+               jboolean res = (*self)->CallBooleanMethod(self, obj, method_id, args_tab);
                free(args_tab);
                return res;
        `}
 
        # Call a method on `obj` designed by `method_id` with an array `args` of arguments returning a Char
        fun call_char_method(obj: JavaObject, method_id: JMethodID, args: nullable Array[nullable Object]): Char import convert_args_to_jni `{
-               jvalue * args_tab = JniEnv_convert_args_to_jni(recv, args);
-               jchar res = (*recv)->CallCharMethod(recv, obj, method_id, args_tab);
+               jvalue * args_tab = JniEnv_convert_args_to_jni(self, args);
+               jchar res = (*self)->CallCharMethod(self, obj, method_id, args_tab);
                free(args_tab);
                return res;
        `}
 
        # Call a method on `obj` designed by `method_id` with an array `args` of arguments returning an Int
        fun call_int_method(obj: JavaObject, method_id: JMethodID, args: nullable Array[nullable Object]): Int import convert_args_to_jni `{
-               jvalue * args_tab = JniEnv_convert_args_to_jni(recv, args);
-               jint res = (*recv)->CallIntMethod(recv, obj, method_id, args_tab);
+               jvalue * args_tab = JniEnv_convert_args_to_jni(self, args);
+               jint res = (*self)->CallIntMethod(self, obj, method_id, args_tab);
                free(args_tab);
                return res;
        `}
 
        # Call a method on `obj` designed by `method_id` with an array `args` of arguments returning a Float
        fun call_float_method(obj: JavaObject, method_id: JMethodID, args: nullable Array[nullable Object]): Float import convert_args_to_jni `{
-               jvalue * args_tab = JniEnv_convert_args_to_jni(recv, args);
-               jfloat res = (*recv)->CallFloatMethod(recv, obj, method_id, args_tab);
+               jvalue * args_tab = JniEnv_convert_args_to_jni(self, args);
+               jfloat res = (*self)->CallFloatMethod(self, obj, method_id, args_tab);
                free(args_tab);
                return res;
        `}
 
        # Call a method on `obj` designed by `method_id` with an array `args` of arguments returning a NativeString
        fun call_string_method(obj: JavaObject, method_id: JMethodID, args: nullable Array[nullable Object]): NativeString import convert_args_to_jni `{
-               jvalue * args_tab = JniEnv_convert_args_to_jni(recv, args);
-               jobject jobj = (*recv)->CallObjectMethod(recv, obj, method_id, args_tab);
+               jvalue * args_tab = JniEnv_convert_args_to_jni(self, args);
+               jobject jobj = (*self)->CallObjectMethod(self, obj, method_id, args_tab);
                free(args_tab);
-               return (char*)(*recv)->GetStringUTFChars(recv, (jstring)jobj, NULL);
+               return (char*)(*self)->GetStringUTFChars(self, (jstring)jobj, NULL);
        `}
 
        private fun convert_args_to_jni(args: nullable Array[nullable Object]): Pointer import Array[nullable Object].as not nullable, Array[nullable Object].[], Array[nullable Object].length, nullable Object.as(Int), nullable Object.as(Char), nullable Object.as(Bool), nullable Object.as(Float), nullable Object.as(JavaObject), nullable Object.as(String), String.to_cstring, String.length `{
@@ -298,7 +298,7 @@ extern class JniEnv `{JNIEnv *`}
                        } else if(nullable_Object_is_a_String(nullable_obj)){
                                String val = nullable_Object_as_String(nullable_obj);
                                char* c = String_to_cstring(val);
-                               jstring js = (*recv)->NewStringUTF(recv, c);
+                               jstring js = (*self)->NewStringUTF(self, c);
                                c_array[i].l = js;
                        } else {
                                fprintf(stderr, "NOT YET SUPPORTED: nit objects are not supported\n");
@@ -310,95 +310,95 @@ extern class JniEnv `{JNIEnv *`}
 
        # Returns the field ID for an instance field of a class. The field is specified by its name and signature
        fun get_field_id(clazz: JClass, name: String, sign: String): JFieldID import String.to_cstring `{
-               return (*recv)->GetFieldID(recv, clazz, String_to_cstring(name), String_to_cstring(sign));
+               return (*self)->GetFieldID(self, clazz, String_to_cstring(name), String_to_cstring(sign));
        `}
 
        # returns the value of an instance (nonstatic) field of an object. The field to access is specified by a field ID obtained by calling get_field_id()
        fun get_object_field(obj: JavaObject, fieldID: JFieldID): JavaObject `{
-               return (*recv)->GetObjectField(recv, obj, fieldID);
+               return (*self)->GetObjectField(self, obj, fieldID);
        `}
 
        fun get_boolean_field(obj: JavaObject, fieldID: JFieldID): Bool `{
-               return (*recv)->GetBooleanField(recv, obj, fieldID);
+               return (*self)->GetBooleanField(self, obj, fieldID);
        `}
 
        fun get_char_field(obj: JavaObject, fieldID: JFieldID): Char `{
-               return (*recv)->GetCharField(recv, obj, fieldID);
+               return (*self)->GetCharField(self, obj, fieldID);
        `}
 
        fun get_int_field(obj: JavaObject, fieldID: JFieldID): Int `{
-               return (*recv)->GetIntField(recv, obj, fieldID);
+               return (*self)->GetIntField(self, obj, fieldID);
        `}
 
        fun get_float_field(obj: JavaObject, fieldID: JFieldID): Float `{
-               return (*recv)->GetFloatField(recv, obj, fieldID);
+               return (*self)->GetFloatField(self, obj, fieldID);
        `}
 
        fun set_object_field(obj: JavaObject, fieldID: JFieldID, value: JavaObject) `{
-               (*recv)->SetObjectField(recv, obj, fieldID, value);
+               (*self)->SetObjectField(self, obj, fieldID, value);
        `}
 
        fun set_boolean_field(obj: JavaObject, fieldID: JFieldID, value: Bool) `{
-               (*recv)->SetBooleanField(recv, obj, fieldID, value);
+               (*self)->SetBooleanField(self, obj, fieldID, value);
        `}
 
        fun set_char_field(obj: JavaObject, fieldID: JFieldID, value: Char) `{
-               (*recv)->SetCharField(recv, obj, fieldID, value);
+               (*self)->SetCharField(self, obj, fieldID, value);
        `}
 
        fun set_int_field(obj: JavaObject, fieldID: JFieldID, value: Int) `{
-               (*recv)->SetIntField(recv, obj, fieldID, value);
+               (*self)->SetIntField(self, obj, fieldID, value);
        `}
 
        fun set_float_field(obj: JavaObject, fieldID: JFieldID, value: Float) `{
-               (*recv)->SetFloatField(recv, obj, fieldID, value);
+               (*self)->SetFloatField(self, obj, fieldID, value);
        `}
 
        # Check for pending exception without creating a local reference to the exception object
        fun exception_check: Bool `{
-               return (*recv)->ExceptionCheck(recv);
+               return (*self)->ExceptionCheck(self);
        `}
 
        # Construct an exception object from the specified class with the message specified by `message` and causes that exception to be thrown
        fun throw_new(clazz: JClass, message: String): Int import String.to_cstring `{
-               return (*recv)->ThrowNew(recv, clazz, String_to_cstring(message));
+               return (*self)->ThrowNew(self, clazz, String_to_cstring(message));
        `}
 
        # return the exception if there is one in the process of being thrown, or NULL if no exception is currently being thrown
        fun exception_occurred: JavaObject `{
-               return (*recv)->ExceptionOccurred(recv);
+               return (*self)->ExceptionOccurred(self);
        `}
 
        # prints an exception and backtrace to error channel
        fun exception_describe `{
-               return (*recv)->ExceptionDescribe(recv);
+               return (*self)->ExceptionDescribe(self);
        `}
 
        # clears any exception currently being thrown, has no effect if there is no exception
        fun exception_clear `{
-               return (*recv)->ExceptionClear(recv);
+               return (*self)->ExceptionClear(self);
        `}
 
        # Raise a fatal error
        fun fatal_error(msg: String) import String.to_cstring `{
-               (*recv)->FatalError(recv, String_to_cstring(msg));
+               (*self)->FatalError(self, String_to_cstring(msg));
        `}
 
        # Transform a NIT String into a JavaObject
        fun string_to_jobject(string: String): JavaObject `{
-               return (*recv)->NewStringUTF(recv, String_to_cstring(string));
+               return (*self)->NewStringUTF(self, String_to_cstring(string));
        `}
 
        # Pushes a local reference frame on the JNI stack
        fun push_local_frame(capacity: Int): Bool `{
-               return (*recv)->PushLocalFrame(recv, capacity);
+               return (*self)->PushLocalFrame(self, capacity);
        `}
 
        # Pops the current local reference frame on the JNI stack
        #
        # Similiar to `JavaObject::pop_from_local_frame` which returns a value.
        fun pop_local_frame `{
-               (*recv)->PopLocalFrame(recv, NULL);
+               (*self)->PopLocalFrame(self, NULL);
        `}
 end
 
@@ -422,19 +422,19 @@ end
 # Represents a jni JNINNativeMethod
 extern class JNINativeMethod `{ JNINativeMethod* `}
        fun name: String import NativeString.to_s `{
-               return NativeString_to_s((void*)recv->name);
+               return NativeString_to_s((void*)self->name);
        `}
 
        fun name=(name: String) import String.to_cstring `{
-               recv->name = String_to_cstring(name);
+               self->name = String_to_cstring(name);
        `}
 
        fun signature: String import NativeString.to_s `{
-               return NativeString_to_s((void*)recv->signature);
+               return NativeString_to_s((void*)self->signature);
        `}
 
        fun signature=(signature: String) import String.to_cstring `{
-               recv->signature = String_to_cstring(signature);
+               self->signature = String_to_cstring(signature);
        `}
 end
 
@@ -446,50 +446,50 @@ end
 extern class JValue `{jvalue`}
 
        fun set_boolean(b: Bool) `{
-               recv.z = b;
+               self.z = b;
        `}
 
        fun get_boolean:Bool `{
-               return recv.z;
+               return self.z;
        `}
 
        fun set_char(c: Char)`{
-               recv.c = c;
+               self.c = c;
        `}
 
        fun get_char: Char `{
-               return recv.c;
+               return self.c;
        `}
 
        fun set_int(i: Int) `{
-               recv.i = i;
+               self.i = i;
        `}
 
        fun get_int: Int `{
-               return recv.i;
+               return self.i;
        `}
 
        fun set_float(f: Float) `{
-               recv.f = f;
+               self.f = f;
        `}
 
        fun get_float: Float `{
-               return recv.f;
+               return self.f;
        `}
 
        fun set_jobject(obj: JavaObject) `{
-               recv.l = obj;
+               self.l = obj;
        `}
 
        fun get_jobject: JavaObject `{
-               return recv.l;
+               return self.l;
        `}
 end
 
 redef class Int
        redef fun to_jvalue(env): JValue `{
                jvalue value;
-               value.i = recv;
+               value.i = self;
                return value;
        `}
 end
@@ -497,7 +497,7 @@ end
 redef class Float
        redef fun to_jvalue(env): JValue `{
                jvalue value;
-               value.f = recv;
+               value.f = self;
                return value;
        `}
 end
@@ -505,7 +505,7 @@ end
 redef class Bool
        redef fun to_jvalue(env): JValue `{
                jvalue value;
-               value.z = recv;
+               value.z = self;
                return value;
        `}
 end
@@ -513,7 +513,7 @@ end
 redef class NativeString
        redef fun to_jvalue(env)`{
                jvalue value;
-               value.l = (*env)->NewStringUTF(env, recv);
+               value.l = (*env)->NewStringUTF(env, self);
                return value;
        `}
 end
index 58069c8..7ba6763 100644 (file)
@@ -100,15 +100,15 @@ extern class NativeEventBase `{ struct event_base * `}
        #
        # This loop will run the event base until either there are no more added
        # events, or until something calls `exit_loop`.
-       fun dispatch `{ event_base_dispatch(recv); `}
+       fun dispatch `{ event_base_dispatch(self); `}
 
        # Exit the event loop
        #
        # TODO support timer
-       fun exit_loop `{ event_base_loopexit(recv, NULL); `}
+       fun exit_loop `{ event_base_loopexit(self, NULL); `}
 
        # Destroy this instance
-       fun destroy `{ event_base_free(recv); `}
+       fun destroy `{ event_base_free(self); `}
 end
 
 # Spawned to manage a specific connection
@@ -182,39 +182,39 @@ end
 extern class NativeBufferEvent `{ struct bufferevent * `}
        # Write `length` bytes of `line`
        fun write(line: NativeString, length: Int): Int `{
-               return bufferevent_write(recv, line, length);
+               return bufferevent_write(self, line, length);
        `}
 
        # Write the byte `value`
        fun write_byte(value: Int): Int `{
                unsigned char byt = (unsigned char)value;
-               return bufferevent_write(recv, &byt, 1);
+               return bufferevent_write(self, &byt, 1);
        `}
 
        # Check if we have anything left in our buffers. If so, we set our connection to be closed
        # on a callback. Otherwise we close it and free it right away.
        fun destroy: Bool `{
-               struct evbuffer* out = bufferevent_get_output(recv);
-               struct evbuffer* in = bufferevent_get_input(recv);
+               struct evbuffer* out = bufferevent_get_output(self);
+               struct evbuffer* in = bufferevent_get_input(self);
                if(evbuffer_get_length(in) > 0 || evbuffer_get_length(out) > 0) {
                        return 0;
                } else {
-                       bufferevent_free(recv);
+                       bufferevent_free(self);
                        return 1;
                }
        `}
 
        # The output buffer associated to `self`
-       fun output_buffer: OutputNativeEvBuffer `{ return bufferevent_get_output(recv); `}
+       fun output_buffer: OutputNativeEvBuffer `{ return bufferevent_get_output(self); `}
 
        # The input buffer associated to `self`
-       fun input_buffer: InputNativeEvBuffer `{ return bufferevent_get_input(recv); `}
+       fun input_buffer: InputNativeEvBuffer `{ return bufferevent_get_input(self); `}
 end
 
 # A single buffer
 extern class NativeEvBuffer `{ struct evbuffer * `}
        # Length of data in this buffer
-       fun length: Int `{ return evbuffer_get_length(recv); `}
+       fun length: Int `{ return evbuffer_get_length(self); `}
 end
 
 # An input buffer
@@ -222,7 +222,7 @@ extern class InputNativeEvBuffer
        super NativeEvBuffer
 
        # Empty/clear `length` data from buffer
-       fun drain(length: Int) `{ evbuffer_drain(recv, length); `}
+       fun drain(length: Int) `{ evbuffer_drain(self, length); `}
 end
 
 # An output buffer
@@ -231,7 +231,7 @@ extern class OutputNativeEvBuffer
 
        # Add file to buffer
        fun add_file(fd, offset, length: Int): Bool `{
-               return evbuffer_add_file(recv, fd, offset, length);
+               return evbuffer_add_file(self, fd, offset, length);
        `}
 end
 
@@ -266,7 +266,7 @@ extern class ConnectionListener `{ struct evconnlistener * `}
        `}
 
        # Get the `NativeEventBase` associated to `self`
-       fun base: NativeEventBase `{ return evconnlistener_get_base(recv); `}
+       fun base: NativeEventBase `{ return evconnlistener_get_base(self); `}
 
        # Callback method on listening error
        fun error_callback do
index 7c65426..0d264cb 100644 (file)
@@ -134,17 +134,21 @@ class MarkdownProcessor
 
        # Split `input` string into `MDLines` and create a parent `MDBlock` with it.
        private fun read_lines(input: String): MDBlock do
-               var block = new MDBlock
+               var block = new MDBlock(new MDLocation(1, 1, 1, 1))
                var value = new FlatBuffer
                var i = 0
+
+               var line_pos = 0
+               var col_pos = 0
+
                while i < input.length do
                        value.clear
                        var pos = 0
                        var eol = false
                        while not eol and i < input.length do
+                               col_pos += 1
                                var c = input[i]
                                if c == '\n' then
-                                       i += 1
                                        eol = true
                                else if c == '\t' then
                                        var np = pos + (4 - (pos.bin_and(3)))
@@ -152,18 +156,20 @@ class MarkdownProcessor
                                                value.add ' '
                                                pos += 1
                                        end
-                                       i += 1
                                else
                                        pos += 1
                                        value.add c
-                                       i += 1
                                end
+                               i += 1
                        end
+                       line_pos += 1
 
-                       var line = new MDLine(value.write_to_string)
+                       var loc = new MDLocation(line_pos, 1, line_pos, col_pos)
+                       var line = new MDLine(loc, value.write_to_string)
                        var is_link_ref = check_link_ref(line)
                        # Skip link refs
                        if not is_link_ref then block.add_line line
+                       col_pos = 0
                end
                return block
        end
@@ -370,70 +376,72 @@ class MarkdownProcessor
                        c2 = ' '
                end
 
+               var loc = text.pos_to_loc(pos)
+
                if c == '*' then
                        if c1 == '*' then
                                if c0 != ' ' or c2 != ' ' then
-                                       return new TokenStrongStar(pos, c)
+                                       return new TokenStrongStar(loc, pos, c)
                                else
-                                       return new TokenEmStar(pos, c)
+                                       return new TokenEmStar(loc, pos, c)
                                end
                        end
                        if c0 != ' ' or c1 != ' ' then
-                               return new TokenEmStar(pos, c)
+                               return new TokenEmStar(loc, pos, c)
                        else
-                               return new TokenNone(pos, c)
+                               return new TokenNone(loc, pos, c)
                        end
                else if c == '_' then
                        if c1 == '_' then
                                if c0 != ' ' or c2 != ' 'then
-                                       return new TokenStrongUnderscore(pos, c)
+                                       return new TokenStrongUnderscore(loc, pos, c)
                                else
-                                       return new TokenEmUnderscore(pos, c)
+                                       return new TokenEmUnderscore(loc, pos, c)
                                end
                        end
                        if ext_mode then
                                if (c0.is_letter or c0.is_digit) and c0 != '_' and
                                   (c1.is_letter or c1.is_digit) then
-                                       return new TokenNone(pos, c)
+                                       return new TokenNone(loc, pos, c)
                                else
-                                       return new TokenEmUnderscore(pos, c)
+                                       return new TokenEmUnderscore(loc, pos, c)
                                end
                        end
                        if c0 != ' ' or c1 != ' ' then
-                               return new TokenEmUnderscore(pos, c)
+                               return new TokenEmUnderscore(loc, pos, c)
                        else
-                               return new TokenNone(pos, c)
+                               return new TokenNone(loc, pos, c)
                        end
                else if c == '!' then
-                       if c1 == '[' then return new TokenImage(pos, c)
-                       return new TokenNone(pos, c)
+                       if c1 == '[' then return new TokenImage(loc, pos, c)
+                       return new TokenNone(loc, pos, c)
                else if c == '[' then
-                       return new TokenLink(pos, c)
+                       return new TokenLink(loc, pos, c)
                else if c == ']' then
-                       return new TokenNone(pos, c)
+                       return new TokenNone(loc, pos, c)
                else if c == '`' then
                        if c1 == '`' then
-                               return new TokenCodeDouble(pos, c)
+                               return new TokenCodeDouble(loc, pos, c)
                        else
-                               return new TokenCodeSingle(pos, c)
+                               return new TokenCodeSingle(loc, pos, c)
                        end
                else if c == '\\' then
                        if c1 == '\\' or c1 == '[' or c1 == ']' or c1 == '(' or c1 == ')' or c1 == '{' or c1 == '}' or c1 == '#' or c1 == '"' or c1 == '\'' or c1 == '.' or c1 == '<' or c1 == '>' or c1 == '*' or c1 == '+' or c1 == '-' or c1 == '_' or c1 == '!' or c1 == '`' or c1 == '~' or c1 == '^' then
-                               return new TokenEscape(pos, c)
+                               return new TokenEscape(loc, pos, c)
                        else
-                               return new TokenNone(pos, c)
+                               return new TokenNone(loc, pos, c)
                        end
                else if c == '<' then
-                       return new TokenHTML(pos, c)
+                       return new TokenHTML(loc, pos, c)
                else if c == '&' then
-                       return new TokenEntity(pos, c)
+                       return new TokenEntity(loc, pos, c)
                else
                        if ext_mode then
                                if c == '~' and c1 == '~' then
-                                       return new TokenStrike(pos, c)
+                                       return new TokenStrike(loc, pos, c)
                                end
                        end
-                       return new TokenNone(pos, c)
+                       return new TokenNone(loc, pos, c)
                end
        end
 
@@ -856,9 +864,31 @@ class HTMLDecorator
        private var allowed_id_chars: Array[Char] = ['-', '_', ':', '.']
 end
 
+# Location in a Markdown input.
+class MDLocation
+
+       # Starting line number (starting from 1).
+       var line_start: Int
+
+       # Starting column number (starting from 1).
+       var column_start: Int
+
+       # Stopping line number (starting from 1).
+       var line_end: Int
+
+       # Stopping column number (starting from 1).
+       var column_end: Int
+
+       redef fun to_s do return "{line_start},{column_start}--{line_end},{column_end}"
+end
+
 # A block of markdown lines.
 # A `MDBlock` can contains lines and/or sub-blocks.
 class MDBlock
+
+       # Position of `self` in the input.
+       var location: MDLocation
+
        # Kind of block.
        # See `Block`.
        var kind: Block = new BlockNone(self) is writable
@@ -911,7 +941,14 @@ class MDBlock
 
        # Split `self` creating a new sub-block having `line` has `last_line`.
        fun split(line: MDLine): MDBlock do
-               var block = new MDBlock
+               # location for new block
+               var new_loc = new MDLocation(
+                       first_line.location.line_start,
+                       first_line.location.column_start,
+                       line.location.line_end,
+                       line.location.column_end)
+               # create block
+               var block = new MDBlock(new_loc)
                block.first_line = first_line
                block.last_line = line
                first_line = line.next
@@ -920,6 +957,9 @@ class MDBlock
                        last_line = null
                else
                        first_line.prev = null
+                       # update current block loc
+                       location.line_start = first_line.location.line_start
+                       location.column_start = first_line.location.column_start
                end
                if first_block == null then
                        first_block = block
@@ -1292,6 +1332,9 @@ end
 # A markdown line.
 class MDLine
 
+       # Location of `self` in the original input.
+       var location: MDLocation
+
        # Text contained in this line.
        var value: String is writable
 
@@ -1799,7 +1842,10 @@ end
 # Some tokens have a specific markup behaviour that is handled here.
 abstract class Token
 
-       # Position of `self` in markdown input.
+       # Location of `self` in the original input.
+       var location: MDLocation
+
+       # Position of `self` in input independant from lines.
        var pos: Int
 
        # Character found at `pos` in the markdown input.
@@ -2428,6 +2474,24 @@ redef class Text
                return null
        end
 
+       # Init a `MDLocation` instance at `pos` in `self`.
+       private fun pos_to_loc(pos: Int): MDLocation do
+               assert pos <= length
+               var line = 1
+               var col = 0
+               var i = 0
+               while i <= pos do
+                       col += 1
+                       var c = self[i]
+                       if c == '\n' then
+                               line +=1
+                               col = 0
+                       end
+                       i +=1
+               end
+               return new MDLocation(line, col, line, col)
+       end
+
        # Is `self` an unsafe HTML element?
        private fun is_html_unsafe: Bool do return html_unsafe_tags.has(self.write_to_string)
 
index e552883..e4bd177 100644 (file)
@@ -2366,43 +2366,46 @@ end
 class TestBlock
        super TestSuite
 
+       # A dummy location for testing purposes.
+       var loc = new MDLocation(0, 0, 0, 0)
+
        fun test_has_blocks do
-               var subject = new MDBlock
+               var subject = new MDBlock(loc)
                assert not subject.has_blocks
-               subject.first_block = new MDBlock
+               subject.first_block = new MDBlock(loc)
                assert subject.has_blocks
        end
 
        fun test_count_blocks do
-               var subject = new MDBlock
+               var subject = new MDBlock(loc)
                assert subject.count_blocks == 0
-               subject.first_block = new MDBlock
+               subject.first_block = new MDBlock(loc)
                assert subject.count_blocks == 1
-               subject.first_block.next = new MDBlock
+               subject.first_block.next = new MDBlock(loc)
                assert subject.count_blocks == 2
        end
 
        fun test_has_lines do
-               var subject = new MDBlock
+               var subject = new MDBlock(loc)
                assert not subject.has_lines
-               subject.first_line = new MDLine("")
+               subject.first_line = new MDLine(loc, "")
                assert subject.has_lines
        end
 
        fun test_count_lines do
-               var subject = new MDBlock
+               var subject = new MDBlock(loc)
                assert subject.count_lines == 0
-               subject.first_line = new MDLine("")
+               subject.first_line = new MDLine(loc, "")
                assert subject.count_lines == 1
-               subject.first_line.next = new MDLine("")
+               subject.first_line.next = new MDLine(loc, "")
                assert subject.count_lines == 2
        end
 
        fun test_split do
-               var line1 = new MDLine("line1")
-               var line2 = new MDLine("line2")
-               var line3 = new MDLine("line3")
-               var subject = new MDBlock
+               var line1 = new MDLine(loc, "line1")
+               var line2 = new MDLine(loc, "line2")
+               var line3 = new MDLine(loc, "line3")
+               var subject = new MDBlock(loc)
                subject.add_line line1
                subject.add_line line2
                subject.add_line line3
@@ -2417,19 +2420,19 @@ class TestBlock
        end
 
        fun test_add_line do
-               var subject = new MDBlock
+               var subject = new MDBlock(loc)
                assert subject.count_lines == 0
-               subject.add_line new MDLine("")
+               subject.add_line new MDLine(loc, "")
                assert subject.count_lines == 1
-               subject.add_line new MDLine("")
+               subject.add_line new MDLine(loc, "")
                assert subject.count_lines == 2
        end
 
        fun test_remove_line do
-               var line1 = new MDLine("line1")
-               var line2 = new MDLine("line2")
-               var line3 = new MDLine("line3")
-               var subject = new MDBlock
+               var line1 = new MDLine(loc, "line1")
+               var line2 = new MDLine(loc, "line2")
+               var line3 = new MDLine(loc, "line3")
+               var subject = new MDBlock(loc)
                subject.add_line line1
                subject.add_line line2
                subject.add_line line3
@@ -2442,29 +2445,29 @@ class TestBlock
        end
 
        fun test_transform_headline1 do
-               var subject = new MDBlock
+               var subject = new MDBlock(loc)
                var kind = new BlockHeadline(subject)
-               subject.add_line new MDLine(" #   Title 1   ")
+               subject.add_line new MDLine(loc, " #   Title 1   ")
                kind.transform_headline(subject)
                assert kind.depth == 1
                assert subject.first_line.value == "Title 1"
        end
 
        fun test_transform_headline2 do
-               var subject = new MDBlock
+               var subject = new MDBlock(loc)
                var kind = new BlockHeadline(subject)
-               subject.add_line new MDLine(" #####Title 5   ")
+               subject.add_line new MDLine(loc, " #####Title 5   ")
                kind.transform_headline(subject)
                assert kind.depth == 5
                assert subject.first_line.value == "Title 5"
        end
 
        fun test_remove_quote_prefix do
-               var subject = new MDBlock
+               var subject = new MDBlock(loc)
                var kind = new BlockQuote(subject)
-               subject.add_line new MDLine(" > line 1")
-               subject.add_line new MDLine(" > line 2")
-               subject.add_line new MDLine(" > line 3")
+               subject.add_line new MDLine(loc, " > line 1")
+               subject.add_line new MDLine(loc, " > line 2")
+               subject.add_line new MDLine(loc, " > line 3")
                kind.remove_block_quote_prefix(subject)
                assert subject.first_line.value == "line 1"
                assert subject.first_line.next.value == "line 2"
@@ -2472,51 +2475,51 @@ class TestBlock
        end
 
        fun test_remove_leading_empty_lines_1 do
-               var block = new MDBlock
-               block.add_line new MDLine("")
-               block.add_line new MDLine("")
-               block.add_line new MDLine("")
-               block.add_line new MDLine("")
-               block.add_line new MDLine("   text")
-               block.add_line new MDLine("")
+               var block = new MDBlock(loc)
+               block.add_line new MDLine(loc, "")
+               block.add_line new MDLine(loc, "")
+               block.add_line new MDLine(loc, "")
+               block.add_line new MDLine(loc, "")
+               block.add_line new MDLine(loc, "   text")
+               block.add_line new MDLine(loc, "")
                assert block.remove_leading_empty_lines
                assert block.first_line.value == "   text"
        end
 
        fun test_remove_leading_empty_lines_2 do
-               var block = new MDBlock
-               block.add_line new MDLine("   text")
+               var block = new MDBlock(loc)
+               block.add_line new MDLine(loc, "   text")
                block.remove_leading_empty_lines
                assert block.first_line.value == "   text"
        end
 
        fun test_remove_trailing_empty_lines_1 do
-               var block = new MDBlock
-               block.add_line new MDLine("")
-               block.add_line new MDLine("text")
-               block.add_line new MDLine("")
-               block.add_line new MDLine("")
-               block.add_line new MDLine("")
-               block.add_line new MDLine("")
+               var block = new MDBlock(loc)
+               block.add_line new MDLine(loc, "")
+               block.add_line new MDLine(loc, "text")
+               block.add_line new MDLine(loc, "")
+               block.add_line new MDLine(loc, "")
+               block.add_line new MDLine(loc, "")
+               block.add_line new MDLine(loc, "")
                assert block.remove_trailing_empty_lines
                assert block.last_line.value == "text"
        end
 
        fun test_remove_trailing_empty_lines_2 do
-               var block = new MDBlock
-               block.add_line new MDLine("text  ")
+               var block = new MDBlock(loc)
+               block.add_line new MDLine(loc, "text  ")
                assert not block.remove_trailing_empty_lines
                assert block.last_line.value == "text  "
        end
 
        fun test_remove_surrounding_empty_lines do
-               var block = new MDBlock
-               block.add_line new MDLine("")
-               block.add_line new MDLine("text")
-               block.add_line new MDLine("")
-               block.add_line new MDLine("")
-               block.add_line new MDLine("")
-               block.add_line new MDLine("")
+               var block = new MDBlock(loc)
+               block.add_line new MDLine(loc, "")
+               block.add_line new MDLine(loc, "text")
+               block.add_line new MDLine(loc, "")
+               block.add_line new MDLine(loc, "")
+               block.add_line new MDLine(loc, "")
+               block.add_line new MDLine(loc, "")
                assert block.remove_surrounding_empty_lines
                assert block.first_line.value == "text"
                assert block.last_line.value == "text"
@@ -2526,118 +2529,121 @@ end
 class TestLine
        super TestSuite
 
+       # A dummy location for testing purposes.
+       var loc = new MDLocation(0, 0, 0, 0)
+
        var subject: MDLine
 
        fun test_is_empty do
-               subject = new MDLine("")
+               subject = new MDLine(loc, "")
                assert subject.is_empty
-               subject = new MDLine("    ")
+               subject = new MDLine(loc, "    ")
                assert subject.is_empty
-               subject = new MDLine("test")
+               subject = new MDLine(loc, "test")
                assert not subject.is_empty
-               subject = new MDLine("    test")
+               subject = new MDLine(loc, "    test")
                assert not subject.is_empty
        end
 
        fun test_leading do
-               subject = new MDLine("")
+               subject = new MDLine(loc, "")
                assert subject.leading == 0
-               subject = new MDLine("    ")
+               subject = new MDLine(loc, "    ")
                assert subject.leading == 4
-               subject = new MDLine("test")
+               subject = new MDLine(loc, "test")
                assert subject.leading == 0
-               subject = new MDLine("    test")
+               subject = new MDLine(loc, "    test")
                assert subject.leading == 4
        end
 
        fun test_trailing do
-               subject = new MDLine("")
+               subject = new MDLine(loc, "")
                assert subject.trailing == 0
-               subject = new MDLine("    ")
+               subject = new MDLine(loc, "    ")
                assert subject.trailing == 0
-               subject = new MDLine("test   ")
+               subject = new MDLine(loc, "test   ")
                assert subject.trailing == 3
-               subject = new MDLine("    test ")
+               subject = new MDLine(loc, "    test ")
                assert subject.trailing == 1
        end
 
        fun test_line_type do
                var v = new MarkdownProcessor
-               subject = new MDLine("")
+               subject = new MDLine(loc, "")
                assert v.line_kind(subject) isa LineEmpty
-               subject = new MDLine("    ")
+               subject = new MDLine(loc, "    ")
                assert v.line_kind(subject) isa LineEmpty
-               subject = new MDLine("text   ")
+               subject = new MDLine(loc, "text   ")
                assert v.line_kind(subject) isa LineOther
-               subject = new MDLine("  # Title")
+               subject = new MDLine(loc, "  # Title")
                assert v.line_kind(subject) isa LineHeadline
-               subject = new MDLine("  ### Title")
+               subject = new MDLine(loc, "  ### Title")
                assert v.line_kind(subject) isa LineHeadline
-               subject = new MDLine("    code")
+               subject = new MDLine(loc, "    code")
                assert v.line_kind(subject) isa LineCode
-               subject = new MDLine("   Title  ")
-               subject.next = new MDLine("== ")
+               subject = new MDLine(loc, "   Title  ")
+               subject.next = new MDLine(loc, "== ")
                assert v.line_kind(subject) isa LineHeadline1
-               subject = new MDLine("   Title  ")
-               subject.next = new MDLine("-- ")
+               subject = new MDLine(loc, "   Title  ")
+               subject.next = new MDLine(loc, "-- ")
                assert v.line_kind(subject) isa LineHeadline2
-               subject = new MDLine("  *    *   * ")
+               subject = new MDLine(loc, "  *    *   * ")
                assert v.line_kind(subject) isa LineHR
-               subject = new MDLine("  *** ")
+               subject = new MDLine(loc, "  *** ")
                assert v.line_kind(subject) isa LineHR
-               subject = new MDLine("- -- ")
+               subject = new MDLine(loc, "- -- ")
                assert v.line_kind(subject) isa LineHR
-               subject = new MDLine("--------- ")
+               subject = new MDLine(loc, "--------- ")
                assert v.line_kind(subject) isa LineHR
-               subject = new MDLine(" >")
+               subject = new MDLine(loc, " >")
                assert v.line_kind(subject) isa LineBlockquote
-               subject = new MDLine("<p></p>")
+               subject = new MDLine(loc, "<p></p>")
                assert v.line_kind(subject) isa LineXML
-               subject = new MDLine("<p>")
+               subject = new MDLine(loc, "<p>")
                assert v.line_kind(subject) isa LineOther
-               subject = new MDLine("  * foo")
+               subject = new MDLine(loc, "  * foo")
                assert v.line_kind(subject) isa LineUList
-               subject = new MDLine("- foo")
+               subject = new MDLine(loc, "- foo")
                assert v.line_kind(subject) isa LineUList
-               subject = new MDLine("+ foo")
+               subject = new MDLine(loc, "+ foo")
                assert v.line_kind(subject) isa LineUList
-               subject = new MDLine("1. foo")
+               subject = new MDLine(loc, "1. foo")
                assert v.line_kind(subject) isa LineOList
-               subject = new MDLine("   11111. foo")
+               subject = new MDLine(loc, "   11111. foo")
                assert v.line_kind(subject) isa LineOList
        end
 
        fun test_line_type_ext do
                var v = new MarkdownProcessor
-               subject = new MDLine("  ~~~")
+               subject = new MDLine(loc, "  ~~~")
                assert v.line_kind(subject) isa LineFence
-               subject = new MDLine("  ```")
+               subject = new MDLine(loc, "  ```")
                assert v.line_kind(subject) isa LineFence
        end
 
        fun test_count_chars do
-               subject = new MDLine("")
+               subject = new MDLine(loc, "")
                assert subject.count_chars('*') == 0
-               subject = new MDLine("* ")
+               subject = new MDLine(loc, "* ")
                assert subject.count_chars('*') == 1
-               subject = new MDLine(" * text")
+               subject = new MDLine(loc, " * text")
                assert subject.count_chars('*') == 0
-               subject = new MDLine(" *    *    *")
+               subject = new MDLine(loc, " *    *    *")
                assert subject.count_chars('*') == 3
-               subject = new MDLine("text ** ")
+               subject = new MDLine(loc, "text ** ")
                assert subject.count_chars('*') == 0
        end
 
        fun test_count_chars_start do
-               subject = new MDLine("")
+               subject = new MDLine(loc, "")
                assert subject.count_chars_start('*') == 0
-               subject = new MDLine("* ")
+               subject = new MDLine(loc, "* ")
                assert subject.count_chars_start('*') == 1
-               subject = new MDLine(" * text")
+               subject = new MDLine(loc, " * text")
                assert subject.count_chars_start('*') == 1
-               subject = new MDLine(" *    *    * text")
+               subject = new MDLine(loc, " *    *    * text")
                assert subject.count_chars_start('*') == 3
-               subject = new MDLine("text ** ")
+               subject = new MDLine(loc, "text ** ")
                assert subject.count_chars_start('*') == 0
        end
 end
@@ -2682,3 +2688,130 @@ c:c
                assert res == exp
        end
 end
+
+class TestTokenLocation
+       super TestSuite
+
+       fun test_token_location1 do
+               var string = "**Hello** `World`"
+               var stack =  [
+                       "TokenStrongStar at 1,1--1,1",
+                       "TokenStrongStar at 1,8--1,8",
+                       "TokenCodeSingle at 1,11--1,11",
+                       "TokenCodeSingle at 1,17--1,17"]
+               (new TestTokenProcessor(stack)).process(string)
+       end
+
+       fun test_token_location2 do
+               var string = "**Hello**\n`World`\n*Bonjour*\n[le monde]()"
+               var stack =  [
+                       "TokenStrongStar at 1,1--1,1",
+                       "TokenStrongStar at 1,8--1,8",
+                       "TokenCodeSingle at 2,1--2,1",
+                       "TokenCodeSingle at 2,7--2,7",
+                       "TokenEmStar at 3,1--3,1",
+                       "TokenEmStar at 3,9--3,9",
+                       "TokenLink at 4,1--4,1"]
+               (new TestTokenProcessor(stack)).process(string)
+       end
+
+       fun test_token_location3 do
+               var string = """**Hello**
+               `World`
+               *Bonjour*
+               [le monde]()"""
+               var stack =  [
+                       "TokenStrongStar at 1,1--1,1",
+                       "TokenStrongStar at 1,8--1,8",
+                       "TokenCodeSingle at 2,1--2,1",
+                       "TokenCodeSingle at 2,7--2,7",
+                       "TokenEmStar at 3,1--3,1",
+                       "TokenEmStar at 3,9--3,9",
+                       "TokenLink at 4,1--4,1"]
+               (new TestTokenProcessor(stack)).process(string)
+       end
+end
+
+class TestTokenProcessor
+       super MarkdownProcessor
+
+       var test_stack: Array[String]
+
+       redef fun token_at(input, pos) do
+               var token = super
+               if token isa TokenNone then return token
+               var res = "{token.class_name} at {token.location}"
+               print res
+               var exp = test_stack.shift
+               assert exp == res
+               return token
+       end
+end
+
+class TestBlockLocation
+       super TestSuite
+
+       var proc = new MarkdownProcessor
+
+       fun test_block_location1 do
+               var stack = [
+                       "BlockHeadline: 1,1--1,8",
+                       "BlockListItem: 2,1--2,6",
+                       "BlockListItem: 3,1--3,5"
+               ]
+               var string =
+               "# Title\n* li1\n* li2"
+               proc.emitter.decorator = new TestBlockDecorator(stack)
+               proc.process(string)
+       end
+
+       fun test_block_location2 do
+               var stack = [
+                       "BlockHeadline: 1,1--1,11",
+                       "BlockFence: 3,1--5,4",
+                       "BlockListItem: 7,1--7,7",
+                       "BlockListItem: 8,1--8,6"]
+               var string ="""#### Title
+
+~~~fence
+some code
+~~~
+
+1. li1
+1. li2"""
+               proc.emitter.decorator = new TestBlockDecorator(stack)
+               proc.process(string)
+       end
+end
+
+class TestBlockDecorator
+       super HTMLDecorator
+
+       var stack: Array[String]
+
+       redef fun add_headline(v, block) do
+               super
+               check_res(block)
+       end
+
+       redef fun add_listitem(v, block) do
+               super
+               check_res(block)
+       end
+
+       redef fun add_blockquote(v, block) do
+               super
+               check_res(block)
+       end
+
+       redef fun add_code(v, block) do
+               super
+               check_res(block)
+       end
+
+       fun check_res(block: Block) do
+               var res = "{block.class_name}: {block.block.location}"
+               var exp = stack.shift
+               assert res == exp
+       end
+end
index 473bc18..22b67c0 100644 (file)
@@ -32,7 +32,7 @@ redef class MarkdownProcessor
                if not token isa TokenLink then return token
                if pos + 1 < text.length then
                        var c = text[pos + 1]
-                       if c == '[' then return new TokenWikiLink(pos, c)
+                       if c == '[' then return new TokenWikiLink(token.location, pos, c)
                end
                return token
        end
index 85828aa..41de768 100644 (file)
@@ -499,7 +499,7 @@ redef class String
                int di;
                char *in_text;
 
-               in_text = String_to_cstring(recv);
+               in_text = String_to_cstring(self);
 
                md5_init(&state);
                md5_append(&state, (const md5_byte_t *)in_text, strlen(in_text));
index b11d8dd..f95602e 100644 (file)
@@ -185,7 +185,7 @@ class Opengles1Display
                }
 
                /* Used by Android to set buffer geometry */
-               Opengles1Display_midway_init(recv, format);
+               Opengles1Display_midway_init(self, format);
 
                surface = eglCreateWindowSurface(display, config, mnit_window, NULL);
                context = eglCreateContext(display, config, NULL, NULL);
@@ -428,43 +428,43 @@ end
 extern class Opengles1Image in "C" `{struct mnit_opengles_Texture *`}
        super Image
 
-    redef fun destroy is extern `{ free( recv ); `}
+    redef fun destroy is extern `{ free( self ); `}
 
-    redef fun width: Int is extern `{ return recv->width; `}
-    redef fun height: Int is extern `{ return recv->height; `}
+    redef fun width: Int is extern `{ return self->width; `}
+    redef fun height: Int is extern `{ return self->height; `}
 
-       fun center_x: Int `{ return recv->center_x; `}
-       fun center_y: Int `{ return recv->center_y; `}
+       fun center_x: Int `{ return self->center_x; `}
+       fun center_y: Int `{ return self->center_y; `}
 
     redef fun scale=( v: Float ) is extern `{
-               recv->scale = v;
-               recv->center_x = v*recv->width/2;
-               recv->center_y = v*recv->height/2;
+               self->scale = v;
+               self->center_x = v*self->width/2;
+               self->center_y = v*self->height/2;
     `}
-    redef fun scale: Float is extern `{ return recv->scale; `}
+    redef fun scale: Float is extern `{ return self->scale; `}
 
-    redef fun blended=( v: Bool ) is extern `{ recv->blended = v; `}
-    redef fun blended: Bool is extern `{ return recv->blended; `}
+    redef fun blended=( v: Bool ) is extern `{ self->blended = v; `}
+    redef fun blended: Bool is extern `{ return self->blended; `}
 
     # inherits scale and blend from source
     redef fun subimage( x, y, w, h: Int ): Image is extern import Opengles1Image.as( Image ) `{
                struct mnit_opengles_Texture* image =
                        malloc( sizeof( struct mnit_opengles_Texture ) );
 
-               image->texture = recv->texture;
+               image->texture = self->texture;
                image->width = w;
                image->height = h;
-               image->center_x = recv->scale*w/2;
-               image->center_y = recv->scale*h/2;
-               image->scale = recv->scale;
-               image->blended = recv->blended;
-
-               float r_dx = recv->src_xi - recv->src_xo;
-               float r_dy = recv->src_yi - recv->src_yo;
-               image->src_xo = recv->src_xo + ((float)x)/recv->width*r_dx;
-               image->src_yo = recv->src_yo + ((float)y)/recv->height*r_dy;
-               image->src_xi = recv->src_xo + ((float)x+w)/recv->width*r_dx;
-               image->src_yi = recv->src_yo + ((float)y+h)/recv->height*r_dy;
+               image->center_x = self->scale*w/2;
+               image->center_y = self->scale*h/2;
+               image->scale = self->scale;
+               image->blended = self->blended;
+
+               float r_dx = self->src_xi - self->src_xo;
+               float r_dy = self->src_yi - self->src_yo;
+               image->src_xo = self->src_xo + ((float)x)/self->width*r_dx;
+               image->src_yo = self->src_yo + ((float)y)/self->height*r_dy;
+               image->src_xi = self->src_xo + ((float)x+w)/self->width*r_dx;
+               image->src_yi = self->src_yo + ((float)y+h)/self->height*r_dy;
 
                return Opengles1Image_as_Image( image );
     `}
index 1720c57..51e1ec8 100644 (file)
@@ -35,8 +35,8 @@ in "C" `{
        void mnit_android_png_read_data(png_structp png_ptr,
                        png_bytep data, png_size_t length)
        {
-                       struct AAsset *recv = png_get_io_ptr(png_ptr);
-                       int read = AAsset_read(recv, data, length);
+                       struct AAsset *self = png_get_io_ptr(png_ptr);
+                       int read = AAsset_read(self, data, length);
        }
        void mnit_android_png_error_fn(png_structp png_ptr,
                png_const_charp error_msg)
@@ -54,7 +54,7 @@ extern class AndroidAsset in "C" `{struct AAsset*`}
 
        fun read(count: Int): nullable String is extern import String.as nullable, NativeString.to_s `{
                char *buffer = malloc(sizeof(char) * (count+1));
-               int read = AAsset_read(recv, buffer, count);
+               int read = AAsset_read(self, buffer, count);
                if (read != count)
                        return null_String();
                else
@@ -65,18 +65,18 @@ extern class AndroidAsset in "C" `{struct AAsset*`}
        `}
 
        fun length: Int is extern `{
-               return AAsset_getLength(recv);
+               return AAsset_getLength(self);
        `}
 
        fun to_fd: Int is extern `{
                off_t start;
                off_t length;
-               int fd = AAsset_openFileDescriptor(recv, &start, &length);
+               int fd = AAsset_openFileDescriptor(self, &start, &length);
                return fd;
        `}
 
        fun close is extern `{
-               AAsset_close(recv);
+               AAsset_close(self);
        `}
 end
 
@@ -102,7 +102,7 @@ redef class App
        end
 
        protected fun load_asset_from_apk(path: String): nullable AndroidAsset is extern import String.to_cstring, AndroidAsset.as nullable, native_app_glue  `{
-               struct android_app *native_app_glue = App_native_app_glue(recv);
+               struct android_app *native_app_glue = App_native_app_glue(self);
                struct AAsset* a = AAssetManager_open(native_app_glue->activity->assetManager, String_to_cstring(path), AASSET_MODE_BUFFER);
                if (a == NULL)
                {
@@ -119,7 +119,7 @@ end
 redef class Opengles1Image
        # Read a png from a zipped stream
        new from_android_asset(asset: AndroidAsset) import Int.next_pow `{
-               struct mnit_opengles_Texture *recv = NULL;
+               struct mnit_opengles_Texture *self = NULL;
 
                png_structp png_ptr = NULL;
                png_infop info_ptr = NULL;
@@ -198,7 +198,7 @@ redef class Opengles1Image
                for (i = 0; i < height; i++)
                        memcpy(pixels + (row_bytes_pow2*i), row_pointers[i], row_bytes);
 
-               recv = mnit_opengles_load_image((const uint_least32_t *)pixels,
+               self = mnit_opengles_load_image((const uint_least32_t *)pixels,
                        width, height, width_pow2, height_pow2, has_alpha);
 
                // Calculate the size of the client-side memory allocated and freed
@@ -223,7 +223,7 @@ redef class Opengles1Image
                }
 
        close_stream:
-               return recv;
+               return self;
        `}
 end
 
index 5ff9e7c..71e59aa 100644 (file)
@@ -30,7 +30,7 @@ in "C" `{
 
 redef class Opengles1Display
        redef fun midway_init(format) import app_native_window `{
-               mnit_window = Opengles1Display_app_native_window(recv);
+               mnit_window = Opengles1Display_app_native_window(self);
                if (ANativeWindow_setBuffersGeometry(mnit_window, 0, 0, (EGLint)format) != 0) {
                        LOGW("Unable to ANativeWindow_setBuffersGeometry");
                }
index 6608bc1..0ee217d 100644 (file)
@@ -53,7 +53,7 @@ extern class NativeBSON `{ bson_t * `}
                bson_t *bson;
                bson = bson_new_from_json(data, -1, &error);
                if(!bson) {
-                       NativeBSON_set_mongoc_error(recv, &error);
+                       NativeBSON_set_mongoc_error(bson, &error);
                        return NULL;
                }
                return bson;
@@ -64,7 +64,7 @@ extern class NativeBSON `{ bson_t * `}
        # The `bson_as_json()` function shall encode bson as a JSON encoded UTF-8 string.
        # The caller is responsible for freeing the resulting UTF-8 encoded string
        # by calling `bson_free()` with the result.
-       fun to_native_string: NativeString `{ return bson_as_json(recv, NULL); `}
+       fun to_native_string: NativeString `{ return bson_as_json(self, NULL); `}
 
        # Wrapper for `bson_destroy()`.
        #
@@ -73,7 +73,7 @@ extern class NativeBSON `{ bson_t * `}
        # unless otherwise specified.
        #
        # This instance should not be used beyond this point!
-       fun destroy `{ bson_destroy(recv); `}
+       fun destroy `{ bson_destroy(self); `}
 
        # Utility method to set `Sys.last_mongoc_error`.
        fun set_mongoc_error(err: BSONError) do sys.last_mongoc_error = err
@@ -90,17 +90,17 @@ extern class BSONError `{ bson_error_t * `}
        #
        # The `error.domain` field contains the logical domain within a library that
        # created the error.
-       fun domain: Int `{ return recv->domain; `}
+       fun domain: Int `{ return self->domain; `}
 
        # Wrapper for `error.code`.
        #
        # The `error.code` field contains the domain specific error code.
-       fun code: Int `{ return recv->code; `}
+       fun code: Int `{ return self->code; `}
 
        # Wrapper for `error.message`.
        #
        # The `error.message` field contains a human printable error message.
-       fun message: NativeString `{ return recv->message; `}
+       fun message: NativeString `{ return self->message; `}
 end
 
 redef class Sys
@@ -117,7 +117,7 @@ redef class NativeCStringArray
        # Frees `self`.
        #
        # This instance should not be used beyond this point!
-       fun destroy `{ free(recv); `}
+       fun destroy `{ free(self); `}
 end
 
 # Wrapper for `mongoc_client_t`.
@@ -144,8 +144,8 @@ extern class NativeMongoClient `{ mongoc_client_t * `}
        fun server_status: nullable NativeBSON import set_mongoc_error, NativeBSON.as nullable `{
                bson_error_t error;
                bson_t *reply = bson_new();
-               if(!mongoc_client_get_server_status(recv, NULL, reply, &error)){
-                       NativeMongoClient_set_mongoc_error(recv, &error);
+               if(!mongoc_client_get_server_status(self, NULL, reply, &error)){
+                       NativeMongoClient_set_mongoc_error(self, &error);
                        return null_NativeBSON();
                }
                return NativeBSON_as_nullable(reply);
@@ -159,10 +159,10 @@ extern class NativeMongoClient `{ mongoc_client_t * `}
                import set_mongoc_error, NativeCStringArray, NativeCStringArray.as nullable `{
                bson_error_t error;
                char **strv;
-               if(strv = mongoc_client_get_database_names(recv, &error)) {
+               if(strv = mongoc_client_get_database_names(self, &error)) {
                        return NativeCStringArray_as_nullable(strv);
                }
-               NativeMongoClient_set_mongoc_error(recv, &error);
+               NativeMongoClient_set_mongoc_error(self, &error);
                return null_NativeCStringArray();
        `}
 
@@ -170,7 +170,7 @@ extern class NativeMongoClient `{ mongoc_client_t * `}
        #
        # This instance should not be used beyond this point!
        fun destroy `{
-               mongoc_client_destroy(recv);
+               mongoc_client_destroy(self);
                mongoc_cleanup();
        `}
 
@@ -206,10 +206,10 @@ extern class NativeMongoDb `{ mongoc_database_t * `}
                import set_mongoc_error, NativeCStringArray, NativeCStringArray.as nullable `{
                bson_error_t error;
                char **strv;
-               if(strv = mongoc_database_get_collection_names(recv, &error)) {
+               if(strv = mongoc_database_get_collection_names(self, &error)) {
                        return NativeCStringArray_as_nullable(strv);
                }
-               NativeMongoDb_set_mongoc_error(recv, &error);
+               NativeMongoDb_set_mongoc_error(self, &error);
                return null_NativeCStringArray();
        `}
 
@@ -218,7 +218,7 @@ extern class NativeMongoDb `{ mongoc_database_t * `}
        # Allocates a new `mongoc_collection_t` structure for the collection named
        # `name` in database.
        fun collection(name: NativeString): NativeMongoCollection `{
-               return mongoc_database_get_collection(recv, name);
+               return mongoc_database_get_collection(self, name);
        `}
 
        # Wrapper for `mongoc_database_has_collection()`.
@@ -227,8 +227,8 @@ extern class NativeMongoDb `{ mongoc_database_t * `}
        # within database.
        fun has_collection(name: NativeString): Bool import set_mongoc_error `{
                bson_error_t error;
-               if(!mongoc_database_has_collection(recv, name, &error)) {
-                       NativeMongoDb_set_mongoc_error(recv, &error);
+               if(!mongoc_database_has_collection(self, name, &error)) {
+                       NativeMongoDb_set_mongoc_error(self, &error);
                        return false;
                }
                return true;
@@ -239,8 +239,8 @@ extern class NativeMongoDb `{ mongoc_database_t * `}
        # This function attempts to drop a database on the MongoDB server.
        fun drop: Bool import set_mongoc_error `{
                bson_error_t error;
-               if(!mongoc_database_drop(recv, &error)) {
-                       NativeMongoDb_set_mongoc_error(recv, &error);
+               if(!mongoc_database_drop(self, &error)) {
+                       NativeMongoDb_set_mongoc_error(self, &error);
                        return false;
                }
                return true;
@@ -249,7 +249,7 @@ extern class NativeMongoDb `{ mongoc_database_t * `}
        # Wrapper for `mongoc_database_destroy()`.
        #
        # This instance should not be used beyond this point!
-       fun destroy `{ mongoc_database_destroy(recv); `}
+       fun destroy `{ mongoc_database_destroy(self); `}
 
        # Utility method to set `Sys.last_mongoc_error`.
        fun set_mongoc_error(err: BSONError) do sys.last_mongoc_error = err
@@ -290,8 +290,8 @@ extern class NativeMongoCollection `{ mongoc_collection_t * `}
        # You can retrieve a generated `_id` from `mongoc_collection_get_last_error()`.
        fun insert(doc: NativeBSON): Bool import set_mongoc_error `{
                bson_error_t error;
-               if(!mongoc_collection_insert(recv, MONGOC_INSERT_NONE, doc, NULL, &error)) {
-                       NativeMongoCollection_set_mongoc_error(recv, &error);
+               if(!mongoc_collection_insert(self, MONGOC_INSERT_NONE, doc, NULL, &error)) {
+                       NativeMongoCollection_set_mongoc_error(self, &error);
                        return false;
                }
                return true;
@@ -304,8 +304,8 @@ extern class NativeMongoCollection `{ mongoc_collection_t * `}
        # Otherwise it will be inserted.
        fun save(document: NativeBSON): Bool import set_mongoc_error `{
                bson_error_t error;
-               if(!mongoc_collection_save(recv, document, NULL, &error)) {
-                       NativeMongoCollection_set_mongoc_error(recv, &error);
+               if(!mongoc_collection_save(self, document, NULL, &error)) {
+                       NativeMongoCollection_set_mongoc_error(self, &error);
                        return false;
                }
                return true;
@@ -318,8 +318,8 @@ extern class NativeMongoCollection `{ mongoc_collection_t * `}
        # The bson selector is not validated, simply passed along as appropriate to the server.
        fun remove(selector: NativeBSON): Bool import set_mongoc_error `{
                bson_error_t error;
-               if(!mongoc_collection_remove(recv, MONGOC_REMOVE_SINGLE_REMOVE, selector, NULL, &error)) {
-                       NativeMongoCollection_set_mongoc_error(recv, &error);
+               if(!mongoc_collection_remove(self, MONGOC_REMOVE_SINGLE_REMOVE, selector, NULL, &error)) {
+                       NativeMongoCollection_set_mongoc_error(self, &error);
                        return false;
                }
                return true;
@@ -330,8 +330,8 @@ extern class NativeMongoCollection `{ mongoc_collection_t * `}
        # This function shall remove documents in the collection that match `selector`.
        fun remove_all(selector: NativeBSON): Bool import set_mongoc_error `{
                bson_error_t error;
-               if(!mongoc_collection_remove(recv, MONGOC_REMOVE_NONE, selector, NULL, &error)) {
-                       NativeMongoCollection_set_mongoc_error(recv, &error);
+               if(!mongoc_collection_remove(self, MONGOC_REMOVE_NONE, selector, NULL, &error)) {
+                       NativeMongoCollection_set_mongoc_error(self, &error);
                        return false;
                }
                return true;
@@ -343,8 +343,8 @@ extern class NativeMongoCollection `{ mongoc_collection_t * `}
        # matches `selector`.
        fun update(selector, update: NativeBSON): Bool import set_mongoc_error `{
                bson_error_t error;
-               if(!mongoc_collection_update(recv, MONGOC_UPDATE_NONE, selector, update, NULL, &error)) {
-                       NativeMongoCollection_set_mongoc_error(recv, &error);
+               if(!mongoc_collection_update(self, MONGOC_UPDATE_NONE, selector, update, NULL, &error)) {
+                       NativeMongoCollection_set_mongoc_error(self, &error);
                        return false;
                }
                return true;
@@ -355,8 +355,8 @@ extern class NativeMongoCollection `{ mongoc_collection_t * `}
        # This function shall update documents in the collection that match `selector`.
        fun update_all(selector, update: NativeBSON): Bool import set_mongoc_error `{
                bson_error_t error;
-               if(!mongoc_collection_update(recv, MONGOC_UPDATE_MULTI_UPDATE, selector, update, NULL, &error)) {
-                       NativeMongoCollection_set_mongoc_error(recv, &error);
+               if(!mongoc_collection_update(self, MONGOC_UPDATE_MULTI_UPDATE, selector, update, NULL, &error)) {
+                       NativeMongoCollection_set_mongoc_error(self, &error);
                        return false;
                }
                return true;
@@ -367,9 +367,9 @@ extern class NativeMongoCollection `{ mongoc_collection_t * `}
        # This function shall execute a count `query` on the underlying collection.
        fun count(query: NativeBSON): Int import set_mongoc_error `{
                bson_error_t error;
-               int64_t count = mongoc_collection_count(recv, MONGOC_QUERY_NONE, query, 0, 0, NULL, &error);
+               int64_t count = mongoc_collection_count(self, MONGOC_QUERY_NONE, query, 0, 0, NULL, &error);
                if(count < 0) {
-                       NativeMongoCollection_set_mongoc_error(recv, &error);
+                       NativeMongoCollection_set_mongoc_error(self, &error);
                        return -1;
                }
                return count;
@@ -387,10 +387,10 @@ extern class NativeMongoCollection `{ mongoc_collection_t * `}
                NativeMongoCursor.as nullable, set_mongoc_error `{
                bson_error_t error;
                mongoc_cursor_t *cursor;
-               cursor = mongoc_collection_find(recv, MONGOC_QUERY_NONE, 0, 0, 0, query, NULL, NULL);
+               cursor = mongoc_collection_find(self, MONGOC_QUERY_NONE, 0, 0, 0, query, NULL, NULL);
 
                if (mongoc_cursor_error(cursor, &error)) {
-                       NativeMongoCollection_set_mongoc_error(recv, &error);
+                       NativeMongoCollection_set_mongoc_error(self, &error);
                        return null_NativeMongoCursor();
                }
 
@@ -403,8 +403,8 @@ extern class NativeMongoCollection `{ mongoc_collection_t * `}
        fun stats: nullable NativeBSON import set_mongoc_error, NativeBSON.as nullable `{
                bson_error_t error;
                bson_t *reply = bson_new();
-               if(!mongoc_collection_stats(recv, NULL, reply, &error)){
-                       NativeMongoCollection_set_mongoc_error(recv, &error);
+               if(!mongoc_collection_stats(self, NULL, reply, &error)){
+                       NativeMongoCollection_set_mongoc_error(self, &error);
                        return null_NativeBSON();
                }
                return NativeBSON_as_nullable(reply);
@@ -416,8 +416,8 @@ extern class NativeMongoCollection `{ mongoc_collection_t * `}
        # including all indexes associated with the collection.
        fun drop: Bool import set_mongoc_error `{
                bson_error_t error;
-               if(!mongoc_collection_drop(recv, &error)) {
-                       NativeMongoCollection_set_mongoc_error(recv, &error);
+               if(!mongoc_collection_drop(self, &error)) {
+                       NativeMongoCollection_set_mongoc_error(self, &error);
                        return false;
                }
                return true;
@@ -431,8 +431,8 @@ extern class NativeMongoCollection `{ mongoc_collection_t * `}
        # Additional operations will occur on renamed collection.
        fun rename(new_database, new_name: NativeString): Bool `{
                bson_error_t error;
-               if(!mongoc_collection_rename(recv, new_database, new_name, false, &error)){
-                       NativeMongoCollection_set_mongoc_error(recv, &error);
+               if(!mongoc_collection_rename(self, new_database, new_name, false, &error)){
+                       NativeMongoCollection_set_mongoc_error(self, &error);
                        return false;
                }
                return true;
@@ -441,7 +441,7 @@ extern class NativeMongoCollection `{ mongoc_collection_t * `}
        # Wrapper for `mongoc_collection_destroy()`.
        #
        # This instance should not be used beyond this point!
-       fun destroy `{ mongoc_collection_destroy(recv); `}
+       fun destroy `{ mongoc_collection_destroy(self); `}
 
        # Utility method to set `Sys.last_mongoc_error`.
        fun set_mongoc_error(err: BSONError) do sys.last_mongoc_error = err
@@ -467,7 +467,7 @@ extern class NativeMongoCursor `{ mongoc_cursor_t* `}
        # 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(recv); `}
+       fun current: NativeBSON `{ return (bson_t*) mongoc_cursor_current(self); `}
 
        # Wrapper for `mongoc_cursor_next()`.
        #
@@ -477,16 +477,16 @@ extern class NativeMongoCursor `{ mongoc_cursor_t* `}
        # This function is a blocking function.
        fun next: Bool `{
                const bson_t *doc;
-               return mongoc_cursor_next(recv, &doc);
+               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(recv); `}
+       fun more: Bool `{ return mongoc_cursor_more(self); `}
 
        # Wrapper for `mongoc_cursor_destroy()`.
        #
        # This instance should not be used beyond this point!
-       fun destroy `{ mongoc_cursor_destroy(recv); `}
+       fun destroy `{ mongoc_cursor_destroy(self); `}
 end
index 69d0d9f..d7b5784 100644 (file)
@@ -177,14 +177,14 @@ extern class Comm `{ MPI_Comm `}
        # Number of processors in this communicator
        fun size: Int `{
                int size;
-               MPI_Comm_size(recv, &size);
+               MPI_Comm_size(self, &size);
                return size;
        `}
 
        # Rank on this processor in this communicator
        fun rank: Rank `{
                int rank;
-               MPI_Comm_rank(recv, &rank);
+               MPI_Comm_rank(self, &rank);
                return rank;
        `}
 end
@@ -243,19 +243,19 @@ extern class Status `{ MPI_Status* `}
        new `{ return malloc(sizeof(MPI_Status)); `}
 
        # Source of this communication
-       fun source: Rank `{ return recv->MPI_SOURCE; `}
+       fun source: Rank `{ return self->MPI_SOURCE; `}
 
        # Tag of this communication
-       fun tag: Tag `{ return recv->MPI_TAG; `}
+       fun tag: Tag `{ return self->MPI_TAG; `}
 
        # Success or error on this communication
-       fun error: SuccessOrError `{ return recv->MPI_ERROR; `}
+       fun error: SuccessOrError `{ return self->MPI_ERROR; `}
 
        # Count of the given `data_type` in this communication
        fun count(data_type: DataType): Int
        `{
                int count;
-               MPI_Get_count(recv, data_type, &count);
+               MPI_Get_count(self, data_type, &count);
                return count;
        `}
 end
@@ -322,7 +322,7 @@ end
 # An MPI return code to report success or errors
 extern class SuccessOrError `{ int `}
        # Is this a success?
-       fun is_success: Bool `{ return recv == MPI_SUCCESS; `}
+       fun is_success: Bool `{ return self == MPI_SUCCESS; `}
 
        # Is this an error?
        fun is_error: Bool do return not is_success
@@ -333,14 +333,14 @@ extern class SuccessOrError `{ int `}
        fun error_class: ErrorClass
        `{
                int class;
-               MPI_Error_class(recv, &class);
+               MPI_Error_class(self, &class);
                return class;
        `}
 
        redef fun to_s do return native_to_s.to_s
        private fun native_to_s: NativeString `{
                char *err = malloc(MPI_MAX_ERROR_STRING);
-               MPI_Error_string(recv, err, NULL);
+               MPI_Error_string(self, err, NULL);
                return err;
        `}
 end
@@ -350,7 +350,7 @@ extern class ErrorClass `{ int `}
        redef fun to_s do return native_to_s.to_s
        private fun native_to_s: NativeString `{
                char *err = malloc(MPI_MAX_ERROR_STRING);
-               MPI_Error_string(recv, err, NULL);
+               MPI_Error_string(self, err, NULL);
                return err;
        `}
 end
@@ -361,7 +361,7 @@ extern class Rank `{ int `}
        new any `{ return MPI_ANY_SOURCE; `}
 
        # This Rank as an `Int`
-       fun to_i: Int `{ return recv; `}
+       fun to_i: Int `{ return self; `}
        redef fun to_s do return to_i.to_s
 end
 
@@ -371,19 +371,19 @@ extern class Tag `{ int `}
        new any `{ return MPI_ANY_TAG; `}
 
        # This tag as an `Int`
-       fun to_i: Int `{ return recv; `}
+       fun to_i: Int `{ return self; `}
        redef fun to_s do return to_i.to_s
 end
 
 redef universal Int
        # `self`th MPI rank
-       fun rank: Rank `{ return recv; `}
+       fun rank: Rank `{ return self; `}
 
        # Tag identified by `self`
-       fun tag: Tag `{ return recv; `}
+       fun tag: Tag `{ return self; `}
 
        # Is this value undefined according to MPI? (may be returned by `Status::count`)
-       fun is_undefined: Bool `{ return recv == MPI_UNDEFINED; `}
+       fun is_undefined: Bool `{ return self == MPI_UNDEFINED; `}
 end
 
 # Something sendable directly and efficiently over MPI
index 2ffa800..12a2b9f 100644 (file)
@@ -105,7 +105,7 @@ abstract class NeoNodeCollection
        #
        # SEE: `create_node`
        # SEE: `register`
-       redef fun add(node: NeoNode) is abstract
+       redef fun add(node) is abstract
 
        # Add a new node to the graph and return it.
        #
index fb5ffd0..898c059 100644 (file)
@@ -297,7 +297,7 @@ redef class NeoNode
        redef fun to_s do return to_json
 
        # Append the JSON representation of the node to the specified buffer.
-       redef fun append_json_for(graph: NeoGraph, buffer: Buffer) do
+       redef fun append_json_for(graph, buffer) do
                append_json(buffer)
        end
 end
@@ -307,7 +307,7 @@ redef class NeoEdge
        # Append the JSON representation of the relationship to the specified buffer.
        #
        # Use the IDs specfied by `graph.nodes`.
-       redef fun append_json_for(graph: NeoGraph, buffer: Buffer) do
+       redef fun append_json_for(graph, buffer) do
                buffer.append "\{\"type\":"
                rel_type.append_json(buffer)
                buffer.append ",\"properties\":"
index fb6129f..939ed88 100644 (file)
@@ -63,7 +63,7 @@ class SequentialNodeCollection
                return nodes[id]
        end
 
-       redef fun has_id(id: Int): Bool do
+       redef fun has_id(id) do
                return id >= 0 and id < nodes.length and nodes[id] isa NeoNode
        end
 
index 666974b..ef87adb 100644 (file)
@@ -50,7 +50,7 @@ class HttpResponse
        end
 
        # Get this reponse as a string according to HTTP protocol
-       redef fun to_s: String
+       redef fun to_s
        do
                finalize
 
index 248a4d4..89ff3cf 100644 (file)
@@ -366,9 +366,9 @@ in "C Header" `{
 extern class PepperDictionary `{ struct PP_Var* `}
 
        new `{
-               struct PP_Var* recv = malloc( sizeof( struct PP_Var ) );
-               *recv = g_varDictionaryInterface->Create();
-               return recv;
+               struct PP_Var* self = malloc( sizeof( struct PP_Var ) );
+               *self = g_varDictionaryInterface->Create();
+               return self;
        `}
 
        # Get fonction using PepperVars.
@@ -377,7 +377,7 @@ extern class PepperDictionary `{ struct PP_Var* `}
        # If 'key' is not a String typed PepperVar, or doesn't exist in the Dictionary, an undefined PepperVar is returned.
        fun native_get(key: PepperVar): PepperVar `{
                struct PP_Var* value = malloc( sizeof ( struct PP_Var ) );
-               *value = g_varDictionaryInterface->Get(*recv, *key);
+               *value = g_varDictionaryInterface->Get(*self, *key);
                return value;
        `}
 
@@ -401,7 +401,7 @@ extern class PepperDictionary `{ struct PP_Var* `}
        #Β Returns a Boolean indicating whether the operation succeeds.
        fun native_set(key: PepperVar, value: PepperVar): Bool `{
                PP_Bool b;
-               b = g_varDictionaryInterface->Set(*recv, *key, *value);
+               b = g_varDictionaryInterface->Set(*self, *key, *value);
                return b;
        `}
 
@@ -422,7 +422,7 @@ extern class PepperDictionary `{ struct PP_Var* `}
        #
        # Takes a String typed PepperVar.
        fun native_delete(key: PepperVar) `{
-               g_varDictionaryInterface->Delete(*recv, *key);
+               g_varDictionaryInterface->Delete(*self, *key);
        `}
        
        # Deletes the specified key and its associated value, if the key exists.
@@ -439,7 +439,7 @@ extern class PepperDictionary `{ struct PP_Var* `}
        # Takes a String typed PepperVar.
        fun native_has_key(key: PepperVar): Bool `{
                PP_Bool b;
-               b = g_varDictionaryInterface->HasKey(*recv, *key);
+               b = g_varDictionaryInterface->HasKey(*self, *key);
                return b;
        `}
 
@@ -457,7 +457,7 @@ extern class PepperDictionary `{ struct PP_Var* `}
        # Returns a PepperArray which contains all the keys of the Dictionary. The elements are string vars.
        fun get_keys: PepperArray `{
                struct PP_Var* array = malloc( sizeof( struct PP_Var ) );
-               *array = g_varDictionaryInterface->GetKeys(*recv);
+               *array = g_varDictionaryInterface->GetKeys(*self);
                return array;
        `}
 
@@ -465,7 +465,7 @@ extern class PepperDictionary `{ struct PP_Var* `}
        fun copy: PepperDictionary `{
                struct PP_Var* varDictionary = malloc( sizeof( struct PP_Var ) );
                *varDictionary = g_varDictionaryInterface->Create();
-               *varDictionary = *recv;
+               *varDictionary = *self;
                return varDictionary;
        `}
 end
@@ -474,9 +474,9 @@ end
 extern class PepperArray `{ struct PP_Var* `}
 
        new `{
-               struct PP_Var* recv = malloc( sizeof( struct PP_Var ) );
-               *recv = g_varArrayInterface->Create();
-               return recv;
+               struct PP_Var* self = malloc( sizeof( struct PP_Var ) );
+               *self = g_varArrayInterface->Create();
+               return self;
        `}
 
        #Β Returns the element at the specified position as a PepperVar.
@@ -484,7 +484,7 @@ extern class PepperArray `{ struct PP_Var* `}
        # If 'index' is larger than or equal to the array length, an undefined PepperVar is returned.
        fun native_get(index: Int): PepperVar `{
                struct PP_Var* value = malloc( sizeof( struct PP_Var ) );
-               *value = g_varArrayInterface->Get(*recv, index);
+               *value = g_varArrayInterface->Get(*self, index);
                return value;
        `}
 
@@ -499,7 +499,7 @@ extern class PepperArray `{ struct PP_Var* `}
 
        # Returns an int containing the length of the PepperArray.
        fun length: Int `{
-               int length = g_varArrayInterface->GetLength(*recv);
+               int length = g_varArrayInterface->GetLength(*self);
                return length;
        `}
 
@@ -511,7 +511,7 @@ extern class PepperArray `{ struct PP_Var* `}
        # Returns a Boolean indicating whether the operation succeeds.
        fun native_set(index: Int, value: PepperVar): Bool `{
                PP_Bool b;
-               b = g_varArrayInterface->Set(*recv, index, *value);
+               b = g_varArrayInterface->Set(*self, index, *value);
                return b;
        `}
 
@@ -534,7 +534,7 @@ extern class PepperArray `{ struct PP_Var* `}
        #Β Returns a Boolean indicating whether the operation succeeds.
        fun length=(length: Int): Bool `{
                PP_Bool b;
-               b = g_varArrayInterface->SetLength(*recv, length);
+               b = g_varArrayInterface->SetLength(*self, length);
                return b;
        `}
 end
@@ -561,19 +561,19 @@ extern class PepperVar `{ struct PP_Var* `}
                return null
        end
 
-       private fun isa_null: Bool `{ return recv->type == PP_VARTYPE_NULL; `}
-       private fun isa_bool: Bool `{ return recv->type == PP_VARTYPE_BOOL; `}
-       private fun isa_int: Bool `{ return recv->type == PP_VARTYPE_INT32; `}
-       private fun isa_float: Bool `{ return recv->type == PP_VARTYPE_DOUBLE; `}
-       private fun isa_string: Bool `{ return recv->type == PP_VARTYPE_STRING; `}
-       private fun is_undefined: Bool `{ return recv->type == PP_VARTYPE_UNDEFINED; `}
+       private fun isa_null: Bool `{ return self->type == PP_VARTYPE_NULL; `}
+       private fun isa_bool: Bool `{ return self->type == PP_VARTYPE_BOOL; `}
+       private fun isa_int: Bool `{ return self->type == PP_VARTYPE_INT32; `}
+       private fun isa_float: Bool `{ return self->type == PP_VARTYPE_DOUBLE; `}
+       private fun isa_string: Bool `{ return self->type == PP_VARTYPE_STRING; `}
+       private fun is_undefined: Bool `{ return self->type == PP_VARTYPE_UNDEFINED; `}
 
-       private fun as_bool: Bool `{ return recv->value.as_bool; `}
-       private fun as_int: Int `{ return recv->value.as_int; `}
-       private fun as_float: Float `{ return recv->value.as_double; `}
+       private fun as_bool: Bool `{ return self->value.as_bool; `}
+       private fun as_int: Int `{ return self->value.as_int; `}
+       private fun as_float: Float `{ return self->value.as_double; `}
        private fun as_string: String import NativeString.to_s_with_length `{
                uint32_t len;
-               char* str = (char*)g_varInterface->VarToUtf8(*recv, &len);
+               char* str = (char*)g_varInterface->VarToUtf8(*self, &len);
                return NativeString_to_s_with_length(str, len);
        `}
 end
@@ -589,7 +589,7 @@ redef class Int
        # Converts a Int into a PepperVar with Int type.
        redef fun to_pepper `{
                struct PP_Var* var = malloc( sizeof( struct PP_Var ) );
-               *var = PP_MakeInt32(recv);
+               *var = PP_MakeInt32(self);
                return var;
        `}
 end
@@ -600,7 +600,7 @@ redef class Float
        # Converts a Float into a PepperVar with Float type.
        redef fun to_pepper `{
                struct PP_Var* var = malloc( sizeof( struct PP_Var ) );
-               *var = PP_MakeDouble(recv);
+               *var = PP_MakeDouble(self);
                return var;
        `}
 end
@@ -611,7 +611,7 @@ redef class Bool
        # Converts a Bool into a PepperVar with Bool type.
        redef fun to_pepper `{
                struct PP_Var* var = malloc( sizeof( struct PP_Var ) );
-               *var = PP_MakeBool(recv);
+               *var = PP_MakeBool(self);
                return var;
        `}
 end
@@ -621,9 +621,9 @@ redef class String
 
        # Converts a String into a PepperVar with String type.
        redef fun to_pepper: PepperVar import String.to_cstring, String.length `{
-               char *str = String_to_cstring(recv);
+               char *str = String_to_cstring(self);
                struct PP_Var* var = malloc( sizeof( struct PP_Var ) );
-               *var = g_varInterface->VarFromUtf8(str, String_length(recv));
+               *var = g_varInterface->VarFromUtf8(str, String_length(self));
                return var;
        `}
 end
@@ -680,7 +680,7 @@ class PnaclApp
 
        #Β Sets everything up to work, need to be called at first.
        fun initialize import PnaclApp.handle_message, PnaclApp.handle_dictionary, NativeString.to_s_with_length `{
-               app = recv;
+               app = self;
        `}
 
        # Posts a message to JS.
index 32d1a71..fc624a6 100644 (file)
@@ -19,5 +19,5 @@ module posix_ext
 
 redef extern class Passwd
        # User information
-       fun gecos: String import NativeString.to_s `{ return NativeString_to_s(recv->pw_gecos); `}
+       fun gecos: String import NativeString.to_s `{ return NativeString_to_s(self->pw_gecos); `}
 end
index e408270..3ed81b4 100644 (file)
@@ -32,7 +32,7 @@ in "C" `{
 
 redef extern class NativePthread
        fun cancel: Bool `{
-               return pthread_cancel(*recv);
+               return pthread_cancel(*self);
        `}
 end
 
@@ -56,7 +56,7 @@ private extern class NativePthreadBarrier in "C" `{ pthread_barrier_t * `}
                return barrier;
        `}
 
-       fun destroy `{ pthread_barrier_destroy(recv); `}
+       fun destroy `{ pthread_barrier_destroy(self); `}
 
-       fun wait `{ pthread_barrier_wait(recv); `}
+       fun wait `{ pthread_barrier_wait(self); `}
 end
index afb66d6..900063f 100644 (file)
@@ -112,14 +112,14 @@ private extern class NativePthread in "C" `{ pthread_t * `}
 
        fun join: nullable Object `{
                void *thread_return;
-               pthread_join(*recv, &thread_return);
+               pthread_join(*self, &thread_return);
                if(thread_return == NULL) thread_return = null_Object();
                return (nullable_Object)thread_return;
        `}
 
-       fun equal(other: NativePthread): Bool `{ return pthread_equal(*recv, *other); `}
+       fun equal(other: NativePthread): Bool `{ return pthread_equal(*self, *other); `}
 
-       fun kill(signal: Int) `{ pthread_kill(*recv, signal); `}
+       fun kill(signal: Int) `{ pthread_kill(*self, signal); `}
 end
 
 private extern class NativePthreadAttr in "C" `{ pthread_attr_t * `}
@@ -135,7 +135,7 @@ private extern class NativePthreadAttr in "C" `{ pthread_attr_t * `}
        `}
 
        fun destroy `{
-               pthread_attr_destroy(recv);
+               pthread_attr_destroy(self);
        `}
 
        # Most features of this class are still TODO
@@ -159,11 +159,11 @@ private extern class NativePthreadMutex in "C" `{ pthread_mutex_t * `}
                return mutex;
        `}
 
-       fun destroy `{ pthread_mutex_destroy(recv); `}
+       fun destroy `{ pthread_mutex_destroy(self); `}
 
-       fun lock `{ pthread_mutex_lock(recv); `}
-       fun try_lock: Bool `{ return pthread_mutex_trylock(recv); `}
-       fun unlock `{ pthread_mutex_unlock(recv); `}
+       fun lock `{ pthread_mutex_lock(self); `}
+       fun try_lock: Bool `{ return pthread_mutex_trylock(self); `}
+       fun unlock `{ pthread_mutex_unlock(self); `}
 end
 
 private extern class NativePthreadMutexAttr in "C" `{ pthread_mutexattr_t * `}
@@ -173,11 +173,11 @@ private extern class NativePthreadMutexAttr in "C" `{ pthread_mutexattr_t * `}
                return attr;
        `}
 
-       fun destroy `{ pthread_mutexattr_destroy(recv); `}
+       fun destroy `{ pthread_mutexattr_destroy(self); `}
 
-       fun set_type_normal `{ pthread_mutexattr_settype(recv, PTHREAD_MUTEX_NORMAL); `}
-       fun set_type_recursive `{ pthread_mutexattr_settype(recv, PTHREAD_MUTEX_RECURSIVE); `}
-       fun set_type_errorcheck `{ pthread_mutexattr_settype(recv, PTHREAD_MUTEX_ERRORCHECK); `}
+       fun set_type_normal `{ pthread_mutexattr_settype(self, PTHREAD_MUTEX_NORMAL); `}
+       fun set_type_recursive `{ pthread_mutexattr_settype(self, PTHREAD_MUTEX_RECURSIVE); `}
+       fun set_type_errorcheck `{ pthread_mutexattr_settype(self, PTHREAD_MUTEX_ERRORCHECK); `}
 
        # pthread_mutexattr_setpshared
        # pthread_mutexattr_setprotocol
@@ -193,13 +193,13 @@ private extern class NativePthreadKey in "C" `{ pthread_key_t * `}
        `}
 
        fun get: nullable Object `{
-               void *val = pthread_getspecific(*recv);
+               void *val = pthread_getspecific(*self);
                if (val == NULL) val = null_Object();
                return val;
        `}
 
        fun set(val: nullable Object) `{
-               pthread_setspecific(*recv, val);
+               pthread_setspecific(*self, val);
        `}
 end
 
@@ -215,13 +215,13 @@ private extern class NativePthreadCond in "C" `{ pthread_cond_t * `}
                return NULL;
        `}
 
-       fun destroy `{ pthread_cond_destroy(recv); `}
+       fun destroy `{ pthread_cond_destroy(self); `}
 
-       fun signal `{ pthread_cond_signal(recv); `}
+       fun signal `{ pthread_cond_signal(self); `}
 
-       fun broadcast `{ pthread_cond_broadcast(recv);  `}
+       fun broadcast `{ pthread_cond_broadcast(self);  `}
 
-       fun wait(mutex: NativePthreadMutex) `{ pthread_cond_wait(recv, mutex); `}
+       fun wait(mutex: NativePthreadMutex) `{ pthread_cond_wait(self, mutex); `}
 end
 
 #
index 3a02d86..960a3cb 100644 (file)
@@ -48,7 +48,7 @@ extern class Timespec `{struct timespec*`}
 
        # Update `self` clock.
        fun update `{
-               clock_gettime( CLOCK_MONOTONIC, recv );
+               clock_gettime(CLOCK_MONOTONIC, self);
        `}
 
        # Substract a Timespec from `self`.
@@ -62,14 +62,14 @@ extern class Timespec `{struct timespec*`}
 
        # Number of whole seconds of elapsed time.
        fun sec : Int `{
-               return recv->tv_sec;
+               return self->tv_sec;
        `}
 
        # Rest of the elapsed time (a fraction of a second).
        #
        # Number of nanoseconds.
        fun nanosec : Int `{
-               return recv->tv_nsec;
+               return self->tv_nsec;
        `}
 
        # Seconds in Float
index f54ec0f..64691cd 100644 (file)
@@ -31,9 +31,9 @@ class AttributesImpl
        super Attributes
 
        private var data = new Array[String]
-       redef var length: Int = 0
+       redef var length = 0
 
-       redef fun uri(index: Int): nullable String do
+       redef fun uri(index) do
                if index >= 0 and index < length then
                        return data[index * 5]
                else
@@ -41,7 +41,7 @@ class AttributesImpl
                end
        end
 
-       redef fun local_name(index: Int): nullable String do
+       redef fun local_name(index) do
                if index >= 0 and index < length then
                        return data[index * 5 + 1]
                else
@@ -49,7 +49,7 @@ class AttributesImpl
                end
        end
 
-       redef fun qname(index: Int): nullable String do
+       redef fun qname(index) do
                if index >= 0 and index < length then
                        return data[index * 5 + 2]
                else
@@ -85,7 +85,7 @@ class AttributesImpl
        # are not available.
        #
        # SEE: `length`
-       redef fun type_of(index): nullable String do
+       redef fun type_of(index) do
                if index isa Int then
                        if index >= 0 and index < length then
                                return data[index * 5 + 3]
@@ -124,7 +124,7 @@ class AttributesImpl
        # are not available.
        #
        # SEE: `length`
-       redef fun value_of(index): nullable String do
+       redef fun value_of(index) do
                if index isa Int then
                        if index >= 0 and index < length then
                                return data[index * 5 + 4]
@@ -157,7 +157,7 @@ class AttributesImpl
        #
        # The index of the attribute, or -1 if it does not
        # appear in the list.
-       redef fun index_ns(uri: String, local_name: String): Int do
+       redef fun index_ns(uri, local_name) do
                var i = 0
 
                if "" != local_name then
@@ -184,7 +184,7 @@ class AttributesImpl
        #
        # The index of the attribute, or -1 if it does not
        # appear in the list.
-       redef fun index_of(qname: String): Int do
+       redef fun index_of(qname) do
                var i = 0
 
                if "" != qname then
@@ -218,7 +218,7 @@ class AttributesImpl
        # The attribute type as a string, or `null` if the
        # attribute is not in the list or if Namespace
        # processing is not being performed.
-       redef fun type_ns(uri: String, local_name: String): nullable String do
+       redef fun type_ns(uri, local_name) do
                var i = 0
 
                if "" != local_name then
@@ -252,7 +252,7 @@ class AttributesImpl
        # The attribute value as a string, or `null` if the
        # attribute is not in the list or if Namespace
        # processing is not being performed.
-       redef fun value_ns(uri: String, local_name: String): nullable String do
+       redef fun value_ns(uri, local_name) do
                var i = 0
 
                if "" != local_name then
index 99d0228..185f074 100644 (file)
@@ -19,19 +19,21 @@ import sax::sax_locator
 # can use it to make a persistent snapshot of a locator at any
 # point during a document parse:
 #
-#     import sax::helpers::sax_locator_impl
-#     import sax::content_handler
+# ~~~nitish
+# import sax::helpers::sax_locator_impl
+# import sax::content_handler
 #
-#     class Example super ContentHandler
-#      private var locator: SAXLocator
-#      private var start_loc: nullable SAXLocator = null
+# class Example super ContentHandler
+#     private var locator: SAXLocator
+#     private var start_loc: nullable SAXLocator = null
 #
-#      redef fun start_document do
-#              # save the location of the start of the document
-#              # for future use.
-#              start_loc = new SAXLocatorImpl.from(locator)
-#      end
+#     redef fun start_document do
+#         # save the location of the start of the document
+#         # for future use.
+#         start_loc = new SAXLocatorImpl.from(locator)
 #     end
+# end
+# ~~~
 #
 # Normally, parser writers will not use this class, since it
 # is more efficient to provide location information only when
@@ -40,10 +42,10 @@ import sax::sax_locator
 # Note: The original source code and documentation of this class comes, in part,
 # from [SAX 2.0](http://www.saxproject.org).
 class SAXLocatorImpl super SAXLocator
-       redef var public_id: nullable String = null is writable
-       redef var system_id: nullable String = null is writable
-       redef var line_number: Int = -1 is writable
-       redef var column_number: Int = -1 is writable
+       redef var public_id = null is writable
+       redef var system_id = null is writable
+       redef var line_number = -1 is writable
+       redef var column_number = -1 is writable
 
        # Zero-argument constructor.
        #
index 7bcd021..78efef9 100644 (file)
@@ -42,14 +42,14 @@ class XMLFilterImpl
 
        # XMLFilter
 
-       redef var parent: nullable XMLReader = null is writable
+       redef var parent = null is writable
 
        # XMLReader
 
-       redef var entity_resolver: nullable EntityResolver = null is writable
-       redef var dtd_handler: nullable DTDHandler = null is writable
-       redef var content_handler: nullable ContentHandler = null is writable
-       redef var error_handler: nullable ErrorHandler = null is writable
+       redef var entity_resolver = null is writable
+       redef var dtd_handler = null is writable
+       redef var content_handler = null is writable
+       redef var error_handler = null is writable
 
 
        ############################################################################
@@ -73,7 +73,7 @@ class XMLFilterImpl
                parent = parent_reader
        end
 
-       redef fun feature_recognized(name: String): Bool do
+       redef fun feature_recognized(name) do
                if parent == null then
                        return false
                else
@@ -81,7 +81,7 @@ class XMLFilterImpl
                end
        end
 
-       redef fun feature_readable(name: String): Bool do
+       redef fun feature_readable(name) do
                if parent == null then
                        return false
                else
@@ -89,7 +89,7 @@ class XMLFilterImpl
                end
        end
 
-       redef fun feature_writable(name: String): Bool do
+       redef fun feature_writable(name) do
                if parent == null then
                        return false
                else
@@ -112,7 +112,7 @@ class XMLFilterImpl
        # SEE: `feature_recognized`
        #
        # SEE: `feature_readable`
-       redef fun feature(name: String): Bool do
+       redef fun feature(name) do
                assert sax_recognized: parent != null else
                        sys.stderr.write("Feature: {name}\n")
                end
@@ -136,14 +136,14 @@ class XMLFilterImpl
        # SEE: `feature_recognized`
        #
        # SEE: `feature_writable`
-       redef fun feature=(name: String, value: Bool) do
+       redef fun feature=(name, value) do
                assert sax_recognized: parent != null else
                        sys.stderr.write("Feature: {name}\n")
                end
                parent.feature(name) = value
        end
 
-       redef fun property_recognized(name: String): Bool do
+       redef fun property_recognized(name) do
                if parent == null then
                        return false
                else
@@ -151,7 +151,7 @@ class XMLFilterImpl
                end
        end
 
-       redef fun property_readable(name: String): Bool do
+       redef fun property_readable(name) do
                if parent == null then
                        return false
                else
@@ -159,7 +159,7 @@ class XMLFilterImpl
                end
        end
 
-       redef fun property_writable(name: String): Bool do
+       redef fun property_writable(name) do
                if parent == null then
                        return false
                else
@@ -180,7 +180,7 @@ class XMLFilterImpl
        # SEE: `property_recognized`
        #
        # SEE: `property_readable`
-       redef fun property(name: String): nullable Object do
+       redef fun property(name) do
                assert sax_recognized: parent != null else
                        sys.stderr.write("Property: {name}\n")
                end
@@ -204,19 +204,19 @@ class XMLFilterImpl
        # SEE: `property_recognized`
        #
        # SEE: `property_writable`
-       redef fun property=(name: String, value: nullable Object) do
+       redef fun property=(name, value) do
                assert sax_recognized: parent != null else
                        sys.stderr.write("Property: {name}\n")
                end
                parent.property(name) = value
        end
 
-       redef fun parse(input: InputSource) do
+       redef fun parse(input) do
                setup_parse
                parent.parse(input)
        end
 
-       redef fun parse_file(system_id: String) do
+       redef fun parse_file(system_id) do
                var source = new InputSource
 
                source.system_id = system_id
@@ -227,9 +227,7 @@ class XMLFilterImpl
        ############################################################################
        # EntityResolver
 
-       redef fun resolve_entity(public_id: nullable String,
-                       system_id: nullable String):
-                       nullable InputSource do
+       redef fun resolve_entity(public_id, system_id) do
                if entity_resolver == null then
                        return null
                else
@@ -241,15 +239,13 @@ class XMLFilterImpl
        ############################################################################
        # DTDHandler
 
-       redef fun notation_decl(name: String, public_id: String,
-                       system_id: String) do
+       redef fun notation_decl(name, public_id, system_id) do
                if dtd_handler != null then
                        dtd_handler.notation_decl(name, public_id, system_id)
                end
        end
 
-       redef fun unparsed_entity_decl(name: String, public_id: String,
-                       system_id: String) do
+       redef fun unparsed_entity_decl(name, public_id, system_id) do
                if dtd_handler != null then
                        dtd_handler.unparsed_entity_decl(name, public_id, system_id)
                end
@@ -259,7 +255,7 @@ class XMLFilterImpl
        ############################################################################
        # ContentHandler
 
-       redef fun document_locator=(locator: SAXLocator) do
+       redef fun document_locator=(locator) do
                if content_handler != null then
                        content_handler.document_locator = locator
                end
@@ -277,50 +273,49 @@ class XMLFilterImpl
                end
        end
 
-       redef fun start_prefix_mapping(prefix: String, uri: String) do
+       redef fun start_prefix_mapping(prefix, uri) do
                if content_handler != null then
                        content_handler.start_prefix_mapping(prefix, uri)
                end
        end
 
-       redef fun end_prefix_mapping(prefix: String) do
+       redef fun end_prefix_mapping(prefix) do
                if content_handler != null then
                        content_handler.end_prefix_mapping(prefix)
                end
        end
 
-       redef fun start_element(uri: String, local_name: String, qname: String,
-                       atts: Attributes) do
+       redef fun start_element(uri, local_name, qname, atts) do
                if content_handler != null then
                        content_handler.start_element(uri, local_name, qname, atts)
                end
        end
 
-       redef fun end_element(uri: String, local_name: String, qname: String) do
+       redef fun end_element(uri, local_name, qname) do
                if content_handler != null then
                        content_handler.end_element(uri, local_name, qname)
                end
        end
 
-       redef fun characters(str: String) do
+       redef fun characters(str) do
                if content_handler != null then
                        content_handler.characters(str)
                end
        end
 
-       redef fun ignorable_whitespace(str: String) do
+       redef fun ignorable_whitespace(str) do
                if content_handler != null then
                        content_handler.ignorable_whitespace(str)
                end
        end
 
-       redef fun processing_instruction(target: String, data: nullable String) do
+       redef fun processing_instruction(target, data) do
                if content_handler != null then
                        content_handler.processing_instruction(target, data)
                end
        end
 
-       redef fun skipped_entity(name: String) do
+       redef fun skipped_entity(name) do
                if content_handler != null then
                        content_handler.skipped_entity(name)
                end
@@ -330,19 +325,19 @@ class XMLFilterImpl
        ############################################################################
        # ErrorHandler
 
-       redef fun warning(exception: SAXParseException) do
+       redef fun warning(exception) do
                if error_handler != null then
                        error_handler.warning(exception)
                end
        end
 
-       redef fun error(exception: SAXParseException) do
+       redef fun error(exception) do
                if error_handler != null then
                        error_handler.error(exception)
                end
        end
 
-       redef fun fatal_error(exception: SAXParseException) do
+       redef fun fatal_error(exception) do
                if error_handler != null then
                        error_handler.fatal_error(exception)
                else
index 6b3f616..19dbb69 100644 (file)
@@ -68,63 +68,63 @@ class XophonReader
        private var model = new XophonReaderModel
        private var lexer: XophonLexer is noinit
 
-       redef fun entity_resolver: nullable EntityResolver do return model.entity_resolver
-       redef fun entity_resolver=(entity_resolver: nullable EntityResolver) do
+       redef fun entity_resolver do return model.entity_resolver
+       redef fun entity_resolver=(entity_resolver) do
                model.entity_resolver = entity_resolver
        end
 
-       redef fun dtd_handler: nullable DTDHandler do return model.dtd_handler
-       redef fun dtd_handler=(dtd_handler: nullable DTDHandler) do
+       redef fun dtd_handler do return model.dtd_handler
+       redef fun dtd_handler=(dtd_handler) do
                model.dtd_handler = dtd_handler
        end
 
-       redef fun content_handler: nullable ContentHandler do return model.content_handler
-       redef fun content_handler=(content_handler: nullable ContentHandler) do
+       redef fun content_handler do return model.content_handler
+       redef fun content_handler=(content_handler) do
                model.content_handler = content_handler
        end
 
-       redef fun error_handler: nullable ErrorHandler do return model.error_handler
-       redef fun error_handler=(error_handler: nullable ErrorHandler) do
+       redef fun error_handler do return model.error_handler
+       redef fun error_handler=(error_handler) do
                model.error_handler = error_handler
        end
 
 
-       redef fun feature_recognized(name: String): Bool do
+       redef fun feature_recognized(name) do
                return model.feature_recognized(name)
        end
 
-       redef fun feature_readable(name: String): Bool do
+       redef fun feature_readable(name) do
                return model.feature_readable(name)
        end
 
-       redef fun feature_writable(name: String): Bool do
+       redef fun feature_writable(name) do
                return model.feature_readable(name)
        end
 
-       redef fun feature(name: String): Bool do return model.feature(name)
-       redef fun feature=(name: String, value: Bool) do model.feature(name) = value
+       redef fun feature(name) do return model.feature(name)
+       redef fun feature=(name, value) do model.feature(name) = value
 
-       redef fun property_recognized(name: String): Bool do
+       redef fun property_recognized(name) do
                return model.property_recognized(name)
        end
 
-       redef fun property_readable(name: String): Bool do
+       redef fun property_readable(name) do
                return model.property_readable(name)
        end
 
-       redef fun property_writable(name: String): Bool do
+       redef fun property_writable(name) do
                return model.property_writable(name)
        end
 
-       redef fun property(name: String): nullable Object do
+       redef fun property(name) do
                return model.property(name)
        end
 
-       redef fun property=(name: String, value: nullable Object) do
+       redef fun property=(name, value) do
                model.property(name) = value
        end
 
-       redef fun parse(input: InputSource) do
+       redef fun parse(input) do
                var system_id: nullable MaybeError[String, Error] = null
                model.locator = new SAXLocatorImpl
 
@@ -157,7 +157,7 @@ class XophonReader
                end
        end
 
-       redef fun parse_file(system_id: String) do
+       redef fun parse_file(system_id) do
                parse(new InputSource.with_system_id(system_id))
        end
 
index 70db6a5..cc69c83 100644 (file)
@@ -259,7 +259,7 @@ class SAXEventLogger
        ############################################################################
        # XMLReader
 
-       redef fun property(name: String): nullable Object do
+       redef fun property(name) do
                assert sax_recognized: parent != null else
                        sys.stderr.write("Property: {name}\n")
                end
@@ -278,7 +278,7 @@ class SAXEventLogger
                end
        end
 
-       redef fun property=(name: String, value: nullable Object) do
+       redef fun property=(name, value) do
                assert sax_recognized: parent != null else
                        sys.stderr.write("Property: {name}\n")
                end
@@ -297,7 +297,7 @@ class SAXEventLogger
                end
        end
 
-       redef fun parse(input: InputSource) do
+       redef fun parse(input) do
                assert parent_is_not_null: parent != 0 else
                        sys.stderr.write("No parent for filter.")
                end
@@ -314,9 +314,7 @@ class SAXEventLogger
        ############################################################################
        # EntityResolver
 
-       redef fun resolve_entity(public_id: nullable String,
-                       system_id: nullable String):
-                       nullable InputSource do
+       redef fun resolve_entity(public_id, system_id) do
                log.push(["resolve_entity",
                                public_id or else "^NULL",
                                system_id or else "^NULL"])
@@ -327,14 +325,12 @@ class SAXEventLogger
        ############################################################################
        # DTDHandler
 
-       redef fun notation_decl(name: String, public_id: String,
-                       system_id: String) do
+       redef fun notation_decl(name, public_id, system_id) do
                log.push(["notation_decl", name, public_id, system_id])
                super
        end
 
-       redef fun unparsed_entity_decl(name: String, public_id: String,
-                       system_id: String) do
+       redef fun unparsed_entity_decl(name, public_id, system_id) do
                log.push(["unparsed_entity_decl", name, public_id, system_id])
                super
        end
@@ -343,7 +339,7 @@ class SAXEventLogger
        ############################################################################
        # ContentHandler
 
-       redef fun document_locator=(locator: SAXLocator) do
+       redef fun document_locator=(locator) do
                log.push(["document_locator=",
                                locator.public_id or else "^NULL",
                                locator.system_id or else "^NULL",
@@ -362,18 +358,17 @@ class SAXEventLogger
                super
        end
 
-       redef fun start_prefix_mapping(prefix: String, uri: String) do
+       redef fun start_prefix_mapping(prefix, uri) do
                log.push(["start_prefix_mapping", prefix, uri])
                super
        end
 
-       redef fun end_prefix_mapping(prefix: String) do
+       redef fun end_prefix_mapping(prefix) do
                log.push(["end_prefix_mapping", prefix])
                super
        end
 
-       redef fun start_element(uri: String, local_name: String, qname: String,
-                       atts: Attributes) do
+       redef fun start_element(uri, local_name, qname, atts) do
                var entry = new Array[String]
                var i = 0
                var length = atts.length
@@ -394,27 +389,27 @@ class SAXEventLogger
                super
        end
 
-       redef fun end_element(uri: String, local_name: String, qname: String) do
+       redef fun end_element(uri, local_name, qname) do
                log.push(["end_element", uri, local_name, qname])
                super
        end
 
-       redef fun characters(str: String) do
+       redef fun characters(str) do
                log.push(["characters", str])
                super
        end
 
-       redef fun ignorable_whitespace(str: String) do
+       redef fun ignorable_whitespace(str) do
                log.push(["ignorable_witespace", str])
                super
        end
 
-       redef fun processing_instruction(target: String, data: nullable String) do
+       redef fun processing_instruction(target, data) do
                log.push(["processing_instruction", target, data or else "^NULL"])
                super
        end
 
-       redef fun skipped_entity(name: String) do
+       redef fun skipped_entity(name) do
                log.push(["skipped_entity", name])
                super
        end
@@ -423,17 +418,17 @@ class SAXEventLogger
        ############################################################################
        # ErrorHandler
 
-       redef fun warning(exception: SAXParseException) do
+       redef fun warning(exception) do
                log.push(["warning", exception.full_message])
                super
        end
 
-       redef fun error(exception: SAXParseException) do
+       redef fun error(exception) do
                log.push(["error", exception.full_message])
                super
        end
 
-       redef fun fatal_error(exception: SAXParseException) do
+       redef fun fatal_error(exception) do
                log.push(["fatal_error", exception.full_message])
                if error_handler != null then
                        error_handler.fatal_error(exception)
@@ -444,18 +439,14 @@ class SAXEventLogger
        ############################################################################
        # DeclHandler
 
-       redef fun element_decl(name: String, model: String) do
+       redef fun element_decl(name, model) do
                log.push(["element_decl", name, model])
                if decl_handler != null then
                        decl_handler.element_decl(name, model)
                end
        end
 
-       redef fun attribute_decl(element_name: String,
-                       attribute_name: String,
-                       attribute_type: String,
-                       mode: nullable String,
-                       value: nullable String) do
+       redef fun attribute_decl(element_name, attribute_name, attribute_type, mode, value) do
                log.push(["attribute_decl",
                                element_name,
                                attribute_name,
@@ -468,14 +459,14 @@ class SAXEventLogger
                end
        end
 
-       redef fun internal_entity_decl(name: String, value: String) do
+       redef fun internal_entity_decl(name, value) do
                log.push(["internal_entity_decl", name, value])
                if decl_handler != null then
                        decl_handler.internal_entity_decl(name, value)
                end
        end
 
-       redef fun external_entity_decl(name: String, value: String) do
+       redef fun external_entity_decl(name, value) do
                log.push(["external_entity_decl", name, value])
                if decl_handler != null then
                        decl_handler.external_entity_decl(name, value)
@@ -486,8 +477,7 @@ class SAXEventLogger
        ############################################################################
        # LexicalHandler
 
-       redef fun start_dtd(name: String, public_id: nullable String,
-                       system_id: nullable String) do
+       redef fun start_dtd(name, public_id, system_id) do
                log.push(["start_dtd", name,
                                public_id or else "^NULL",
                                system_id or else "^NULL"])
@@ -503,14 +493,14 @@ class SAXEventLogger
                end
        end
 
-       redef fun start_entity(name: String) do
+       redef fun start_entity(name) do
                log.push(["start_entity", name])
                if lexical_handler != null then
                        lexical_handler.start_entity(name)
                end
        end
 
-       redef fun end_entity(name: String) do
+       redef fun end_entity(name) do
                log.push(["end_entity", name])
                if lexical_handler != null then
                        lexical_handler.end_entity(name)
@@ -531,7 +521,7 @@ class SAXEventLogger
                end
        end
 
-       redef fun comment(str: String) do
+       redef fun comment(str) do
                log.push(["comment", str])
                if lexical_handler != null then
                        lexical_handler.comment(str)
index 6de6d2d..c5e1ec9 100644 (file)
@@ -70,19 +70,19 @@ extern class SDLDisplay `{SDL_Surface *`}
                        TTF_Quit();
        `}
 
-       redef fun finish `{ SDL_Flip(recv); `}
+       redef fun finish `{ SDL_Flip(self); `}
 
        # Clear the entire window with given RGB color (integer values)
        fun clear_int(r, g, b: Int) `{
-               SDL_FillRect(recv, NULL, SDL_MapRGB(recv->format,r,g,b)); 
+               SDL_FillRect(self, NULL, SDL_MapRGB(self->format,r,g,b));
        `}
 
-       redef fun width: Int `{ return recv->w; `}
-       redef fun height: Int `{ return recv->h; `}
+       redef fun width: Int `{ return self->w; `}
+       redef fun height: Int `{ return self->h; `}
 
        # Fill a rectangle with given color
        fun fill_rect(rect: SDLRectangle, r, g, b: Int) `{
-               SDL_FillRect(recv, rect,  SDL_MapRGB(recv->format,r,g,b));
+               SDL_FillRect(self, rect,  SDL_MapRGB(self->format,r,g,b));
        `}
 
        redef fun clear(r, g, b: Float) `{
@@ -90,7 +90,7 @@ extern class SDLDisplay `{SDL_Surface *`}
                ri = (Uint8)r*255;
                gi = (Uint8)g*255;
                bi = (Uint8)b*255;
-               SDL_FillRect(recv, NULL, SDL_MapRGB(recv->format,ri,gi,bi));
+               SDL_FillRect(self, NULL, SDL_MapRGB(self->format,ri,gi,bi));
        `}
 
        # SDL events since the last call to this method
@@ -203,7 +203,7 @@ extern class SDLDrawable `{SDL_Surface*`}
                dst.w = 0;
                dst.h = 0;
 
-               SDL_BlitSurface(img, NULL, recv, &dst);
+               SDL_BlitSurface(img, NULL, self, &dst);
        `}
 
        redef fun blit_centered(img, x, y)
@@ -245,18 +245,18 @@ extern class SDLImage
        fun save_to_file(path: String) import String.to_cstring `{ `}
 
        # Destroy the image and free the memory
-       redef fun destroy `{ SDL_FreeSurface(recv); `}
+       redef fun destroy `{ SDL_FreeSurface(self); `}
 
-       redef fun width: Int `{ return recv->w; `}
-       redef fun height: Int `{ return recv->h; `}
+       redef fun width: Int `{ return self->w; `}
+       redef fun height: Int `{ return self->h; `}
 
        fun is_ok: Bool do return not address_is_null
 
        # Returns a reference to the pixels of the texture
-       fun pixels: NativeCByteArray `{ return recv->pixels; `}
+       fun pixels: NativeCByteArray `{ return self->pixels; `}
 
        # Does this texture has an alpha mask?
-       fun amask: Bool `{ return recv->format->Amask; `}
+       fun amask: Bool `{ return self->format->Amask; `}
 end
 
 # A simple rectangle
@@ -271,17 +271,17 @@ extern class SDLRectangle `{SDL_Rect*`}
                return rect;
        `}
 
-       fun x=(v: Int) `{ recv->x = (Sint16)v; `}
-       fun x: Int `{ return recv->x; `}
+       fun x=(v: Int) `{ self->x = (Sint16)v; `}
+       fun x: Int `{ return self->x; `}
 
-       fun y=(v: Int) `{ recv->y = (Sint16)v; `}
-       fun y: Int `{ return recv->y; `}
+       fun y=(v: Int) `{ self->y = (Sint16)v; `}
+       fun y: Int `{ return self->y; `}
 
-       fun w=(v: Int) `{ recv->w = (Uint16)v; `}
-       fun w: Int `{ return recv->w; `}
+       fun w=(v: Int) `{ self->w = (Uint16)v; `}
+       fun w: Int `{ return self->w; `}
 
-       fun h=(v: Int) `{ recv->h = (Uint16)v; `}
-       fun h: Int `{ return recv->h; `}
+       fun h=(v: Int) `{ self->h = (Uint16)v; `}
+       fun h: Int `{ return self->h; `}
 end
 
 interface SDLInputEvent
@@ -418,7 +418,7 @@ class SDLQuitEvent
 end
 
 redef class Int
-       fun delay `{ SDL_Delay(recv); `}
+       fun delay `{ SDL_Delay(self); `}
 end
 
 # Class to load and use TTF_Font
@@ -436,7 +436,7 @@ extern class SDLFont `{TTF_Font *`}
        return font;
        `}
 
-       fun destroy `{ TTF_CloseFont(recv); `}
+       fun destroy `{ TTF_CloseFont(self); `}
 
        # Create a String with the specified color, return an SDLImage
        fun render(text: String, r, g, b: Int): SDLImage import String.to_cstring `{
@@ -449,7 +449,7 @@ extern class SDLFont `{TTF_Font *`}
                color.b = b;
 
                ctext = String_to_cstring(text);
-               if(!(text_surface=TTF_RenderText_Blended(recv, ctext, color)))
+               if(!(text_surface=TTF_RenderText_Blended(self, ctext, color)))
                {
                        fprintf(stderr, "SDL TFF error: %s\n", TTF_GetError());
                        exit(1);
@@ -467,30 +467,30 @@ extern class SDLFont `{TTF_Font *`}
 
        # Maximum pixel height of all glyphs of this font.
        fun height: Int `{
-               return TTF_FontHeight(recv);
+               return TTF_FontHeight(self);
        `}
 
        fun ascent: Int `{
-               return TTF_FontAscent(recv);
+               return TTF_FontAscent(self);
        `}
 
        fun descent: Int `{
-               return TTF_FontDescent(recv);
+               return TTF_FontDescent(self);
        `}
 
        # Get the recommended pixel height of a rendered line of text of the loaded font. This is usually larger than the Font.height.
        fun line_skip: Int `{
-               return TTF_FontLineSkip(recv);
+               return TTF_FontLineSkip(self);
        `}
 
        # Return true is the font used fixed width for each char
        fun is_fixed_width: Bool `{
-               return TTF_FontFaceIsFixedWidth(recv);
+               return TTF_FontFaceIsFixedWidth(self);
        `}
 
        # Return the family name of the font
        fun family_name: nullable String import String.to_cstring, String.as nullable  `{
-               char *fn = TTF_FontFaceFamilyName(recv);
+               char *fn = TTF_FontFaceFamilyName(self);
 
                if (fn == NULL)
                        return null_String();
@@ -500,7 +500,7 @@ extern class SDLFont `{TTF_Font *`}
 
        # Return the style name of the font
        fun style_name: nullable String import String.to_cstring, String.as nullable  `{
-               char *sn = TTF_FontFaceStyleName(recv);
+               char *sn = TTF_FontFaceStyleName(self);
 
                if (sn == NULL)
                        return null_String();
@@ -512,7 +512,7 @@ extern class SDLFont `{TTF_Font *`}
        fun width_of(text: String): Int import NativeString.to_s `{
                char *ctext = String_to_cstring(text);
                int w;
-               if (TTF_SizeText(recv, ctext, &w, NULL))
+               if (TTF_SizeText(self, ctext, &w, NULL))
                {
                        fprintf(stderr, "SDL TFF error: %s\n", TTF_GetError());
                        exit(1);
@@ -541,6 +541,6 @@ extern class SDLSystemWindowManagerInfo `{SDL_SysWMinfo *`}
 
        # Returns the handle of this window on a X11 window system
        fun x11_window_handle: Pointer `{
-               return (void*)recv->info.x11.window;
+               return (void*)self->info.x11.window;
        `}
 end
index 0ad457d..6da4c24 100644 (file)
@@ -33,7 +33,7 @@ extern class SDLEventBuffer `{SDL_Event *`}
        # Poll and event into `self`
        #
        # Returns `true` if an event was available.
-       fun poll_event: Bool `{ return SDL_PollEvent(recv); `}
+       fun poll_event: Bool `{ return SDL_PollEvent(self); `}
 
        # Get a reference to the data at `self` as a precise `SDLEvent`
        #
@@ -53,28 +53,28 @@ extern class SDLEventBuffer `{SDL_Event *`}
        end
 
        # Is this a quit event?
-       fun is_quit: Bool `{ return recv->type == SDL_QUIT; `}
+       fun is_quit: Bool `{ return self->type == SDL_QUIT; `}
 
        # Get a reference to data at `self` as a `SDLQuitEvent`
-       fun to_quit: SDLQuitEvent `{ return recv; `}
+       fun to_quit: SDLQuitEvent `{ return self; `}
 
        # Is this a mouse motion event?
-       fun is_mouse_motion: Bool `{ return recv->type == SDL_MOUSEMOTION; `}
+       fun is_mouse_motion: Bool `{ return self->type == SDL_MOUSEMOTION; `}
 
        # Get a reference to data at `self` as a `SDLMouseMotionEvent`
-       fun to_mouse_motion: SDLMouseMotionEvent `{ return recv; `}
+       fun to_mouse_motion: SDLMouseMotionEvent `{ return self; `}
 
        # Is this a mouse button down event?
-       fun is_mouse_button_down: Bool `{ return recv->type == SDL_MOUSEBUTTONDOWN; `}
+       fun is_mouse_button_down: Bool `{ return self->type == SDL_MOUSEBUTTONDOWN; `}
 
        # Get a reference to data at `self` as a `SDLMouseButtonDownEvent`
-       fun to_mouse_button_down: SDLMouseButtonDownEvent `{ return recv; `}
+       fun to_mouse_button_down: SDLMouseButtonDownEvent `{ return self; `}
 
        # Is this a mouse button up event?
-       fun is_mouse_button_up: Bool `{ return recv->type == SDL_MOUSEBUTTONUP; `}
+       fun is_mouse_button_up: Bool `{ return self->type == SDL_MOUSEBUTTONUP; `}
 
        # Get a reference to data at `self` as a `SDLMouseButtonUpEvent`
-       fun to_mouse_button_up: SDLMouseButtonUpEvent `{ return recv; `}
+       fun to_mouse_button_up: SDLMouseButtonUpEvent `{ return self; `}
 
        # TODO other SDL events:
        #
@@ -120,7 +120,7 @@ extern class SDLMouseEvent
        # four fields of each events are common to all of them.
 
        # Which mouse, pointer or finger raised this event
-       fun which: Int `{ return recv->motion.which; `}
+       fun which: Int `{ return self->motion.which; `}
 end
 
 # A mouse motion event
@@ -128,16 +128,16 @@ extern class SDLMouseMotionEvent
        super SDLMouseEvent
 
        # X coordinate on screen of this event
-       fun x: Int `{ return recv->motion.x; `}
+       fun x: Int `{ return self->motion.x; `}
 
        # Y coordinate on screen of this event
-       fun y: Int `{ return recv->motion.y; `}
+       fun y: Int `{ return self->motion.y; `}
 
        # Difference on the X axis between this event and the previous one
-       fun xrel: Int `{ return recv->motion.xrel; `}
+       fun xrel: Int `{ return self->motion.xrel; `}
 
        # Difference on the Y axis between this event and the previous one
-       fun yrel: Int `{ return recv->motion.yrel; `}
+       fun yrel: Int `{ return self->motion.yrel; `}
 end
 
 # A mouse button event
@@ -148,10 +148,10 @@ extern class SDLMouseButtonEvent
        super SDLMouseEvent
 
        # X coordinate on screen of this event
-       fun x: Int `{ return recv->button.x; `}
+       fun x: Int `{ return self->button.x; `}
 
        # Y coordinate on screen of this event
-       fun y: Int `{ return recv->button.y; `}
+       fun y: Int `{ return self->button.y; `}
 end
 
 # A mouse button release event
index ce642b8..a1373ec 100644 (file)
@@ -65,14 +65,14 @@ extern class SDLImgInitFlags `{ int `}
        new `{ return 0; `}
 
        # Add the JPG support to this flag set
-       fun jpg: SDLImgInitFlags `{ return recv | IMG_INIT_JPG; `}
+       fun jpg: SDLImgInitFlags `{ return self | IMG_INIT_JPG; `}
 
        # Add the PNG support to this flag set
-       fun png: SDLImgInitFlags `{ return recv | IMG_INIT_PNG; `}
+       fun png: SDLImgInitFlags `{ return self | IMG_INIT_PNG; `}
 
        # Add the TIF support to this flag set
-       fun tif: SDLImgInitFlags `{ return recv | IMG_INIT_TIF; `}
+       fun tif: SDLImgInitFlags `{ return self | IMG_INIT_TIF; `}
 
        # Add the WEBP support to this flag set
-       fun webp: SDLImgInitFlags `{ return recv | IMG_INIT_WEBP; `}
+       fun webp: SDLImgInitFlags `{ return self | IMG_INIT_WEBP; `}
 end
index ee129d7..52b1970 100644 (file)
@@ -84,35 +84,35 @@ extern class SDLInitFlags `{ Uint32 `}
        new `{ return 0; `}
 
        # Add the timer subsystem
-       fun timer: SDLInitFlags `{ return recv | SDL_INIT_TIMER; `}
+       fun timer: SDLInitFlags `{ return self | SDL_INIT_TIMER; `}
 
        # Add the audio subsystem
-       fun audio: SDLInitFlags `{ return recv | SDL_INIT_AUDIO; `}
+       fun audio: SDLInitFlags `{ return self | SDL_INIT_AUDIO; `}
 
        # Add the video subsystem
-       fun video: SDLInitFlags `{ return recv | SDL_INIT_VIDEO; `}
+       fun video: SDLInitFlags `{ return self | SDL_INIT_VIDEO; `}
 
        # Add the joystick subsystem
        #
        # Implied by `gamecontroller`
-       fun joystick: SDLInitFlags `{ return recv | SDL_INIT_JOYSTICK; `}
+       fun joystick: SDLInitFlags `{ return self | SDL_INIT_JOYSTICK; `}
 
        # Add the haptic subsystem
-       fun haptic: SDLInitFlags `{ return recv | SDL_INIT_HAPTIC; `}
+       fun haptic: SDLInitFlags `{ return self | SDL_INIT_HAPTIC; `}
 
        # Add the gamecontroller subsystem
-       fun gamecontroller: SDLInitFlags `{ return recv | SDL_INIT_GAMECONTROLLER; `}
+       fun gamecontroller: SDLInitFlags `{ return self | SDL_INIT_GAMECONTROLLER; `}
 
        # Add the events subsystem
        #
        # Implied by `video` and `joystick`
-       fun events: SDLInitFlags `{ return recv | SDL_INIT_EVENTS; `}
+       fun events: SDLInitFlags `{ return self | SDL_INIT_EVENTS; `}
 
        # Add all subsystems
-       fun everything: SDLInitFlags `{ return recv | SDL_INIT_EVERYTHING; `}
+       fun everything: SDLInitFlags `{ return self | SDL_INIT_EVERYTHING; `}
 
        # Is this flag set empty?
-       fun is_empty: Bool `{ return recv == 0; `}
+       fun is_empty: Bool `{ return self == 0; `}
 
        # TODO add all other is_
 end
@@ -130,20 +130,20 @@ extern class SDLWindow `{ SDL_Window * `}
        fun initialized: Bool do return not address_is_null
 
        # Destroy this window
-       fun destroy `{ SDL_DestroyWindow(recv); `}
+       fun destroy `{ SDL_DestroyWindow(self); `}
 
        # Get the `SDLWindowFlags` describing the status of the window
-       fun flags: SDLWindowFlags `{ return SDL_GetWindowFlags(recv); `}
+       fun flags: SDLWindowFlags `{ return SDL_GetWindowFlags(self); `}
 
        # Show a simple message box
        #
        # Similar to `sys.sdl.show_simple_message_box` but attached to this window
        fun show_simple_message_box(level: SDLMessageBoxFlags, title, content: NativeString) `{
-               SDL_ShowSimpleMessageBox(level, title, content, recv);
+               SDL_ShowSimpleMessageBox(level, title, content, self);
        `}
 
        # Set the icon of this window
-       fun icon=(icon: SDLSurface) `{ SDL_SetWindowIcon(recv, icon); `}
+       fun icon=(icon: SDLSurface) `{ SDL_SetWindowIcon(self, icon); `}
 end
 
 # Flags for `SDLWindow::new` and returned by `SDLWindow::flags`
@@ -152,62 +152,62 @@ extern class SDLWindowFlags `{ Uint32 `}
        new `{ return 0; `}
 
        # Add the flag requesting a fullscreen window
-       fun fullscreen: SDLWindowFlags `{ return recv | SDL_WINDOW_FULLSCREEN; `}
+       fun fullscreen: SDLWindowFlags `{ return self | SDL_WINDOW_FULLSCREEN; `}
 
        # Add the flag requesting a fullscreen window for the current desktop
-       fun fullscreen_desktop: SDLWindowFlags `{ return recv | SDL_WINDOW_FULLSCREEN_DESKTOP; `}
+       fun fullscreen_desktop: SDLWindowFlags `{ return self | SDL_WINDOW_FULLSCREEN_DESKTOP; `}
 
        # Add the flag requesting a window usable with an OpenGL context
-       fun opengl: SDLWindowFlags `{ return recv | SDL_WINDOW_OPENGL; `}
+       fun opengl: SDLWindowFlags `{ return self | SDL_WINDOW_OPENGL; `}
 
        # Add the flag requesting a hidden window
-       fun hidden: SDLWindowFlags `{ return recv | SDL_WINDOW_HIDDEN; `}
+       fun hidden: SDLWindowFlags `{ return self | SDL_WINDOW_HIDDEN; `}
 
        # Add the flag requesting a borderless window
-       fun borderless: SDLWindowFlags `{ return recv | SDL_WINDOW_BORDERLESS; `}
+       fun borderless: SDLWindowFlags `{ return self | SDL_WINDOW_BORDERLESS; `}
 
        # Add the flag requesting a resizable window
-       fun resizable: SDLWindowFlags `{ return recv | SDL_WINDOW_RESIZABLE; `}
+       fun resizable: SDLWindowFlags `{ return self | SDL_WINDOW_RESIZABLE; `}
 
        # Add the flag requesting a minimized window
-       fun minimized: SDLWindowFlags `{ return recv | SDL_WINDOW_MINIMIZED; `}
+       fun minimized: SDLWindowFlags `{ return self | SDL_WINDOW_MINIMIZED; `}
 
        # Add the flag requesting a maximimez window
-       fun maximized: SDLWindowFlags `{ return recv | SDL_WINDOW_MAXIMIZED; `}
+       fun maximized: SDLWindowFlags `{ return self | SDL_WINDOW_MAXIMIZED; `}
 
        # Add the flag to grab the input focus
-       fun input_grabbed: SDLWindowFlags `{ return recv | SDL_WINDOW_INPUT_GRABBED; `}
+       fun input_grabbed: SDLWindowFlags `{ return self | SDL_WINDOW_INPUT_GRABBED; `}
 
        # Add the flag to request a window using the system High-DPI mode
        fun allow_highdpi: SDLWindowFlags `{
                #if SDL_VERSION_ATLEAST(2, 0, 2)
-                       return recv | SDL_WINDOW_ALLOW_HIGHDPI;
+                       return self | SDL_WINDOW_ALLOW_HIGHDPI;
                #else
-                       return recv;
+                       return self;
                #endif
        `}
 
        # Is the window shown?
        #
        # Can only be queried because it is ignored by `SDLWindow::new`
-       fun is_shown: Bool `{ return recv & SDL_WINDOW_SHOWN; `}
+       fun is_shown: Bool `{ return self & SDL_WINDOW_SHOWN; `}
 
        # Does the window has the input focus?
        #
        # Can only be queried because it is ignored by `SDLWindow::new`
-       fun has_input_focus: Bool `{ return recv & SDL_WINDOW_INPUT_FOCUS; `}
+       fun has_input_focus: Bool `{ return self & SDL_WINDOW_INPUT_FOCUS; `}
 
        # Does the window has the mouse focus?
        #
        # Can only be queried because it is ignored by `SDLWindow::new`
-       fun has_mouse_focus: Bool `{ return recv & SDL_WINDOW_MOUSE_FOCUS; `}
+       fun has_mouse_focus: Bool `{ return self & SDL_WINDOW_MOUSE_FOCUS; `}
 
        # TODO add all other `is_` methods, as needed
 end
 
 redef universal Int
-       # Suspend execution for `recv` milliseconds
-       fun delay `{ SDL_Delay(recv); `}
+       # Suspend execution for `self` milliseconds
+       fun delay `{ SDL_Delay(self); `}
 end
 
 # A renderer, maybe software or hardware
@@ -225,10 +225,10 @@ extern class SDLRenderer `{ SDL_Renderer * `}
        `}
 
        # Destroy this renderer
-       fun destroy `{ SDL_DestroyRenderer(recv); `}
+       fun destroy `{ SDL_DestroyRenderer(self); `}
 
        # Clear the rendering target with the current `draw_color`
-       fun clear `{ SDL_RenderClear(recv); `}
+       fun clear `{ SDL_RenderClear(self); `}
 
        # Copy the rectangle at `src` from `texture` to fill the `dst` at the rendering `target`
        #
@@ -245,18 +245,18 @@ extern class SDLRenderer `{ SDL_Renderer * `}
        end
 
        private fun native_copy(texture: SDLTexture, src, dst: SDLRect) `{
-               SDL_RenderCopy(recv, texture, src, dst);
+               SDL_RenderCopy(self, texture, src, dst);
        `}
 
        # Update the screen with all rendering since the previous call
-       fun present `{ SDL_RenderPresent(recv); `}
+       fun present `{ SDL_RenderPresent(self); `}
 
        # Get the `SDLRendererInfo` for this renderer
-       fun info_copy(out: SDLRendererInfo) `{ SDL_GetRendererInfo(recv, out); `}
+       fun info_copy(out: SDLRendererInfo) `{ SDL_GetRendererInfo(self, out); `}
 
        # Set the drawing color
        fun draw_color=(val: SDLColor) `{
-               SDL_SetRenderDrawColor(recv, val->r, val->g, val->b, val->a);
+               SDL_SetRenderDrawColor(self, val->r, val->g, val->b, val->a);
        `}
 
        # Get the drawing color of this renderer
@@ -272,31 +272,31 @@ extern class SDLRenderer `{ SDL_Renderer * `}
 
        # Copy the drawing color of this renderer in `color`
        fun draw_color_copy(color: SDLColor) `{
-               SDL_GetRenderDrawColor(recv, &color->r, &color->g, &color->b, &color->a);
+               SDL_GetRenderDrawColor(self, &color->r, &color->g, &color->b, &color->a);
        `}
 
        # Fill a rectangle with the current `draw_color`
        #
        # If `rect.address_is_null` then fills the entire screen.
-       fun fill_rect(rect: SDLRect) `{ SDL_RenderFillRect(recv, rect); `}
+       fun fill_rect(rect: SDLRect) `{ SDL_RenderFillRect(self, rect); `}
 
        # Draw a rectangle with the current `draw_color`
-       fun draw_rect(rect: SDLRect) `{ SDL_RenderDrawRect(recv, rect); `}
+       fun draw_rect(rect: SDLRect) `{ SDL_RenderDrawRect(self, rect); `}
 
        # Draw a point with the current `draw_color`
-       fun draw_point(x, y: Int) `{ SDL_RenderDrawPoint(recv, x, y); `}
+       fun draw_point(x, y: Int) `{ SDL_RenderDrawPoint(self, x, y); `}
 
        # Draw a line with the current `draw_color`
-       fun draw_line(x1, y1, x2, y2: Int) `{ SDL_RenderDrawLine(recv, x1, y1, x2, y2); `}
+       fun draw_line(x1, y1, x2, y2: Int) `{ SDL_RenderDrawLine(self, x1, y1, x2, y2); `}
 
        # Set the viewport of this renderer
-       fun viewport=(rect: SDLRect) `{ SDL_RenderSetViewport(recv, rect); `}
+       fun viewport=(rect: SDLRect) `{ SDL_RenderSetViewport(self, rect); `}
 
        # Get the rendering target of this renderer
-       fun target: SDLTexture `{ return SDL_GetRenderTarget(recv); `}
+       fun target: SDLTexture `{ return SDL_GetRenderTarget(self); `}
 
        # Set the rendering target of this renderer
-       fun target=(val: SDLTexture) `{ SDL_SetRenderTarget(recv, val); `}
+       fun target=(val: SDLTexture) `{ SDL_SetRenderTarget(self, val); `}
 
        # TODO add other renderer related methods:
        #
@@ -329,28 +329,28 @@ extern class SDLColor `{ SDL_Color *`}
        end
 
        # The red component of this color `[0..255]`
-       fun r: Int `{ return recv->r; `}
+       fun r: Int `{ return self->r; `}
 
        # Set the red component of this color `[0..255]`
-       fun r=(val: Int) `{ recv->r = val; `}
+       fun r=(val: Int) `{ self->r = val; `}
 
        # The green component of this color `[0..255]`
-       fun g: Int `{ return recv->g; `}
+       fun g: Int `{ return self->g; `}
 
        # Set the green component of this color `[0..255]`
-       fun g=(val: Int) `{ recv->g = val; `}
+       fun g=(val: Int) `{ self->g = val; `}
 
        # The blue component of this color `[0..255]`
-       fun b: Int `{ return recv->b; `}
+       fun b: Int `{ return self->b; `}
 
        # Set the blue component of this color `[0..255]`
-       fun b=(val: Int) `{ recv->b = val; `}
+       fun b=(val: Int) `{ self->b = val; `}
 
        # The alpha component of this color `[0..255]`
-       fun a: Int `{ return recv->a; `}
+       fun a: Int `{ return self->a; `}
 
        # Set the ralpha component of this color `[0..255]`
-       fun a=(val: Int) `{ recv->a = val; `}
+       fun a=(val: Int) `{ self->a = val; `}
 
        # TODO implement the related `SDL_Palette` and related methods
 end
@@ -361,18 +361,18 @@ extern class SDLRendererFlags `{ Uint32 `}
        new `{ return 0; `}
 
        # Add the flag to request a software renderer
-       fun software: SDLRendererFlags `{ return recv | SDL_RENDERER_SOFTWARE; `}
+       fun software: SDLRendererFlags `{ return self | SDL_RENDERER_SOFTWARE; `}
 
        # Add the flag to request an accelerated renderer
        #
        # This is the default option.
-       fun accelerated: SDLRendererFlags `{ return recv | SDL_RENDERER_ACCELERATED; `}
+       fun accelerated: SDLRendererFlags `{ return self | SDL_RENDERER_ACCELERATED; `}
 
        # Add the flag to request a renderer where `SDLRenderer::present` is synchronized with the refresh rate
-       fun presentvsync: SDLRendererFlags `{ return recv | SDL_RENDERER_PRESENTVSYNC; `}
+       fun presentvsync: SDLRendererFlags `{ return self | SDL_RENDERER_PRESENTVSYNC; `}
 
        # Add the flag to request a renderer able to render to a texture
-       fun targettexture: SDLRendererFlags `{ return recv | SDL_RENDERER_TARGETTEXTURE; `}
+       fun targettexture: SDLRendererFlags `{ return self | SDL_RENDERER_TARGETTEXTURE; `}
 end
 
 # A bitmap surface
@@ -381,10 +381,10 @@ extern class SDLSurface `{ SDL_Surface * `}
        # Load the BMP file at `path`
        new load_bmp(path: NativeString) `{ return SDL_LoadBMP(path); `}
 
-       redef fun free `{ SDL_FreeSurface(recv); `}
+       redef fun free `{ SDL_FreeSurface(self); `}
 
        # Save this texture to a BMP file
-       fun save_bmp(path: NativeString) `{ SDL_SaveBMP(recv, path); `}
+       fun save_bmp(path: NativeString) `{ SDL_SaveBMP(self, path); `}
 end
 
 # A loaded bitmap texture
@@ -395,19 +395,19 @@ extern class SDLTexture `{ SDL_Texture * `}
        `}
 
        # Destroy this texture
-       fun destroy `{ SDL_DestroyTexture(recv); `}
+       fun destroy `{ SDL_DestroyTexture(self); `}
 
        # Width of this texture
        fun width: Int `{
                int val;
-               SDL_QueryTexture(recv, NULL, NULL, &val, NULL);
+               SDL_QueryTexture(self, NULL, NULL, &val, NULL);
                return val;
        `}
 
        # Height of this texture
        fun height: Int `{
                int val;
-               SDL_QueryTexture(recv, NULL, NULL, NULL, &val);
+               SDL_QueryTexture(self, NULL, NULL, NULL, &val);
                return val;
        `}
 
@@ -442,28 +442,28 @@ extern class SDLRect `{SDL_Rect *`}
        end
 
        # X coordinate of the top left corner
-       fun x: Int `{ return recv->x; `}
+       fun x: Int `{ return self->x; `}
 
        # Set the X coordinate of the top left corner
-       fun x=(val: Int) `{ recv->x = val; `}
+       fun x=(val: Int) `{ self->x = val; `}
 
        # Y coordinate of the top left corner
-       fun y: Int `{ return recv->y; `}
+       fun y: Int `{ return self->y; `}
 
        # Set the Y coordinate of the top left corner
-       fun y=(val: Int) `{ recv->y = val; `}
+       fun y=(val: Int) `{ self->y = val; `}
 
        # Width of this rectangle
-       fun w: Int `{ return recv->w; `}
+       fun w: Int `{ return self->w; `}
 
        # Set the width of this rectangle
-       fun w=(val: Int) `{ recv->w = val; `}
+       fun w=(val: Int) `{ self->w = val; `}
 
        # Height of this rectangle
-       fun h: Int `{ return recv->h; `}
+       fun h: Int `{ return self->h; `}
 
        # Set the height of this rectangle
-       fun h=(val: Int) `{ recv->h = val; `}
+       fun h=(val: Int) `{ self->h = val; `}
 
        # TODO implement other `SDLRect` related methods:
        #
@@ -496,16 +496,16 @@ extern class SDLPoint `{SDL_Point *`}
        end
 
        # X coordinate of this point
-       fun x: Int `{ return recv->x; `}
+       fun x: Int `{ return self->x; `}
 
        # Set the X coordinate of this point
-       fun x=(val: Int) `{ recv->x = val; `}
+       fun x=(val: Int) `{ self->x = val; `}
 
        # Y coordinate of this point
-       fun y: Int `{ return recv->y; `}
+       fun y: Int `{ return self->y; `}
 
        # Set the Y coordinate of this point
-       fun y=(val: Int) `{ recv->y = val; `}
+       fun y=(val: Int) `{ self->y = val; `}
 end
 
 # Flag to set the icon in `sys.sdl.show_simple_message_box` and `SDLWindow::show_simple_message_box`
@@ -526,11 +526,11 @@ extern class SDLRendererInfo `{ SDL_RendererInfo * `}
        new malloc `{ return malloc(sizeof(SDL_RendererInfo)); `}
 
        # Name of the renderer's driver
-       fun name: NativeString `{ return (char*)recv->name; `}
+       fun name: NativeString `{ return (char*)self->name; `}
 
        # Maximum texture width supported by the renderer
-       fun max_texture_width: Int `{ return recv->max_texture_width; `}
+       fun max_texture_width: Int `{ return self->max_texture_width; `}
 
        # Maximum texture height supported by the renderer
-       fun max_texture_height: Int `{ return recv->max_texture_height; `}
+       fun max_texture_height: Int `{ return self->max_texture_height; `}
 end
index 97ec28a..068c634 100644 (file)
@@ -32,7 +32,7 @@ redef extern class SDLWindow
 
                SDL_VERSION(&val->version);
 
-               if(SDL_GetWindowWMInfo(recv, val) <= 0) {
+               if(SDL_GetWindowWMInfo(self, val) <= 0) {
                        free(val);
                        return NULL;
                }
@@ -46,27 +46,27 @@ end
 # Created using `SDLWindow::vm_info`
 extern class SDLSysWMInfo `{ SDL_SysWMinfo * `}
        # Is this an unknown window manager?
-       fun is_unknown: Bool `{ return recv->subsystem == SDL_SYSWM_UNKNOWN; `}
+       fun is_unknown: Bool `{ return self->subsystem == SDL_SYSWM_UNKNOWN; `}
 
        # Is this a Windows system?
-       fun is_windows: Bool `{ return recv->subsystem == SDL_SYSWM_WINDOWS; `}
+       fun is_windows: Bool `{ return self->subsystem == SDL_SYSWM_WINDOWS; `}
 
        # Is this the X11 window manager?
-       fun is_x11: Bool `{ return recv->subsystem == SDL_SYSWM_X11; `}
+       fun is_x11: Bool `{ return self->subsystem == SDL_SYSWM_X11; `}
 
        # Is this a direct DirectFB?
-       fun is_direcfb: Bool `{ return recv->subsystem == SDL_SYSWM_DIRECTFB; `}
+       fun is_direcfb: Bool `{ return self->subsystem == SDL_SYSWM_DIRECTFB; `}
 
        # Is this system an OS X?
-       fun is_cocoa: Bool `{ return recv->subsystem == SDL_SYSWM_COCOA; `}
+       fun is_cocoa: Bool `{ return self->subsystem == SDL_SYSWM_COCOA; `}
 
        # Is this system an iOS?
-       fun is_uikit: Bool `{ return recv->subsystem == SDL_SYSWM_UIKIT; `}
+       fun is_uikit: Bool `{ return self->subsystem == SDL_SYSWM_UIKIT; `}
 
        # It this window manager Wayland?
        fun is_wayland: Bool `{
                #if SDL_VERSION_ATLEAST(2, 0, 2)
-                       return recv->subsystem == SDL_SYSWM_WAYLAND;
+                       return self->subsystem == SDL_SYSWM_WAYLAND;
                #else
                        return 0;
                #endif
@@ -75,7 +75,7 @@ extern class SDLSysWMInfo `{ SDL_SysWMinfo * `}
        # It this window manager Mir?
        fun is_mir: Bool `{
                #if SDL_VERSION_ATLEAST(2, 0, 3)
-                       return recv->subsystem == SDL_SYSWM_MIR;
+                       return self->subsystem == SDL_SYSWM_MIR;
                #else
                        return 0;
                #endif
@@ -84,7 +84,7 @@ extern class SDLSysWMInfo `{ SDL_SysWMinfo * `}
        # Is this system a Windows RT?
        fun is_winrt: Bool `{
                #if SDL_VERSION_ATLEAST(2, 0, 3)
-                       return recv->subsystem == SDL_SYSWM_WINRT;
+                       return self->subsystem == SDL_SYSWM_WINRT;
                #else
                        return 0;
                #endif
@@ -93,7 +93,7 @@ extern class SDLSysWMInfo `{ SDL_SysWMinfo * `}
        # Is this system an Android?
        fun is_android: Bool `{
                #if SDL_VERSION_ATLEAST(2, 0, 4)
-                       return recv->subsystem == SDL_SYSWM_ANDROID;
+                       return self->subsystem == SDL_SYSWM_ANDROID;
                #else
                        return 0;
                #endif
@@ -103,6 +103,6 @@ extern class SDLSysWMInfo `{ SDL_SysWMinfo * `}
        #
        # Require: `is_x11`
        fun x11_window_handle: Pointer `{
-               return (void*)recv->info.x11.window;
+               return (void*)self->info.x11.window;
        `}
 end
diff --git a/lib/serialization/caching.nit b/lib/serialization/caching.nit
new file mode 100644 (file)
index 0000000..186c96c
--- /dev/null
@@ -0,0 +1,118 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Services for caching serialization engines
+module caching
+
+import serialization
+private import engine_tools
+
+# A `Serializer` with a `cache`
+abstract class CachingSerializer
+       super Serializer
+
+       # Cache of known objects
+       var cache = new SerializerCache is lazy, writable
+
+       # Link the cache of `self` with `deserializer`
+       #
+       # This allows reference objects by id when they are known by the other side
+       # of the stream.
+       #
+       # Use `cache` if it is a `DuplexCache`, otherwise create a new one.
+       fun link(deserializer: CachingDeserializer)
+       do
+               var mem = self.cache
+               if not mem isa DuplexCache then mem = new DuplexCache
+
+               self.cache = mem
+               deserializer.cache = mem
+       end
+end
+
+# A `Deserializer` with a `cache`
+abstract class CachingDeserializer
+       super Deserializer
+
+       # Cache of known objects
+       var cache = new DeserializerCache is lazy, writable
+end
+
+# Cache of sent objects
+#
+# Used by `Serializer` to avoid duplicating objects, by serializing them once,
+# then using a reference.
+class SerializerCache
+       # Map of already serialized objects to the reference id
+       private var sent: Map[Serializable, Int] = new StrictHashMap[Serializable, Int]
+
+       # Is `object` known?
+       fun has_object(object: Serializable): Bool do return sent.keys.has(object)
+
+       # Get the id for `object`
+       #
+       # Require: `has_object(object)`
+       fun id_for(object: Serializable): Int
+       do
+               assert sent.keys.has(object)
+               return sent[object]
+       end
+
+       # Get a new id for `object` and store it
+       #
+       # Require: `not has_object(object)`
+       fun new_id_for(object: Serializable): Int
+       do
+               var id = sent.length
+               sent[object] = id
+               return id
+       end
+end
+
+# Cache of received objects sorted by there reference id
+#
+# Used by `Deserializer` to find already deserialized objects by their reference.
+class DeserializerCache
+       # Map of references to already deserialized objects.
+       private var received: Map[Int, Object] = new StrictHashMap[Int, Object]
+
+       # Is there an object associated to `id`?
+       fun has_id(id: Int): Bool do return received.keys.has(id)
+
+       # Get the object associated to `id`
+       fun object_for(id: Int): nullable Object do return received[id]
+
+       # Associate `object` to `id`
+       fun []=(id: Int, object: Object) do received[id] = object
+end
+
+# A shared cache for serialization and deserialization
+class DuplexCache
+       super SerializerCache
+       super DeserializerCache
+
+       redef fun new_id_for(object)
+       do
+               var id = super
+               received[id] = object
+               return id
+       end
+
+       redef fun []=(id, object)
+       do
+               super
+               assert object isa Serializable
+               sent[object] = id
+       end
+end
index 1e0ee0b..33d36b4 100644 (file)
 module engine_tools
 
 import serialization
+intrude import standard::collection::hash_collection
 
-# Maps instances to a value, uses `is_same_instance`
-#
-# Warning: This class does not implement all the services from `Map`.
+# Maps instances to a value, uses `is_same_serialized` and `serialization_hash`.
 class StrictHashMap[K, V]
-       super Map[K, V]
-
-       # private
-       var map = new HashMap[K, Array[Couple[K, V]]]
-
-       redef var length = 0
-
-       redef fun is_empty do return length == 0
+       super HashMap[K, V]
 
-       # private
-       fun node_at(key: K): nullable Couple[K, V]
+       redef fun index_at(k)
        do
-               if not map.keys.has(key) then return null
-
-               var arr = map[key]
-               for couple in arr do
-                       if couple.first.is_same_serialized(key) then
-                               return couple
-                       end
-               end
+               if k == null then return 0
 
-               return null
+               var i = k.serialization_hash % _capacity
+               if i < 0 then i = - i
+               return i
        end
 
-       redef fun [](key)
+       redef fun node_at_idx(i, k)
        do
-               var node = node_at(key)
-               assert node != null
-               return node.second
-       end
-
-       redef fun []=(key, value)
-       do
-               var node = node_at(key)
-               if node != null then
-                       node.second = value
-                       return
+               var c = _array[i]
+               while c != null do
+                       var ck = c._key
+                       if ck.is_same_serialized(k) then
+                               break
+                       end
+                       c = c._next_in_bucklet
                end
-
-               var arr
-               if not map.keys.has(key) then
-                       arr = new Array[Couple[K, V]]
-                       map[key] = arr
-               else arr = map[key]
-
-               arr.add new Couple[K, V](key, value)
-               self.length += 1
+               return c
        end
-
-       redef fun has_key(key) do return node_at(key) != null
 end
index 3ba9968..8977baa 100644 (file)
@@ -146,6 +146,12 @@ redef interface Object
        #
        # Used to determine if an object has already been serialized.
        fun is_same_serialized(other: nullable Object): Bool do return is_same_instance(other)
+
+       # Hash value use for serialization
+       #
+       # Used in combination with `is_same_serialized`. If two objects are the same
+       # in a serialization context, they must have the same `serialization_hash`.
+       fun serialization_hash: Int do return object_id
 end
 
 # Instances of this class are not delayed and instead serialized immediately
index 033bd83..eea4c03 100644 (file)
@@ -235,7 +235,7 @@ redef class String
                sha1nfo s;
 
                sha1_init(&s);
-               sha1_write(&s, String_to_cstring(recv), String_length(recv));
+               sha1_write(&s, String_to_cstring(self), String_length(self));
                uint8_t* digest = sha1_result(&s);
 
                char* digested = malloc(21);
@@ -258,7 +258,7 @@ redef class String
                sha1nfo s;
 
                sha1_init(&s);
-               sha1_write(&s, String_to_cstring(recv), String_length(recv));
+               sha1_write(&s, String_to_cstring(self), String_length(self));
                uint8_t* digest = sha1_result(&s);
 
                char* ret_str = malloc(41);
index 58482a8..daf3e29 100644 (file)
@@ -168,8 +168,8 @@ interface SignalHandler
                        if (last_handler != NULL)
                                SignalHandler_decr_ref(last_handler);
 
-                       nit_signals_list[signal].handler = recv;
-                       SignalHandler_incr_ref(recv);
+                       nit_signals_list[signal].handler = self;
+                       SignalHandler_incr_ref(self);
 
                        nit_signals_list[signal].safely = safely;
                }
index d553540..a665b41 100644 (file)
@@ -141,7 +141,7 @@ class TCPStream
        end
 
        # If socket.end_reached, nothing will happen
-       redef fun write(msg: Text)
+       redef fun write(msg)
        do
                if closed then return
                socket.write(msg.to_s)
index fbf2923..ee6173e 100644 (file)
@@ -87,13 +87,13 @@ end
 private extern class NativeSocketPollFD `{ struct pollfd * `}
 
        # File descriptor
-       fun fd: Int `{ return recv->fd; `}
+       fun fd: Int `{ return self->fd; `}
 
        # List of events to be watched
-       fun events: Int `{ return recv->events; `}
+       fun events: Int `{ return self->events; `}
 
        # List of events received by the last poll function
-       fun revents: Int `{  return recv->revents; `}
+       fun revents: Int `{  return self->revents; `}
 
        new (pid: Int, events: NativeSocketPollValues) `{
                struct pollfd *poll = malloc(sizeof(struct pollfd));
@@ -115,32 +115,32 @@ extern class NativeSocket `{ int* `}
                return d;
        `}
 
-       fun destroy `{ free(recv); `}
+       fun destroy `{ free(self); `}
 
-       fun close: Int `{ return close(*recv); `}
+       fun close: Int `{ return close(*self); `}
 
-       fun descriptor: Int `{ return *recv; `}
+       fun descriptor: Int `{ return *self; `}
 
        fun gethostbyname(n: String): NativeSocketHostent import String.to_cstring `{ return gethostbyname(String_to_cstring(n)); `}
 
        fun connect(addrIn: NativeSocketAddrIn): Int `{
-               return connect(*recv, (struct sockaddr*)addrIn, sizeof(*addrIn));
+               return connect(*self, (struct sockaddr*)addrIn, sizeof(*addrIn));
        `}
 
        fun write(buffer: String): Int
        import String.to_cstring, String.length `{
-               return write(*recv, (char*)String_to_cstring(buffer), String_length(buffer));
+               return write(*self, (char*)String_to_cstring(buffer), String_length(buffer));
        `}
 
        # Write `value` as a single byte
        fun write_byte(value: Int): Int `{
                unsigned char byt = (unsigned char)value;
-               return write(*recv, &byt, 1);
+               return write(*self, &byt, 1);
        `}
 
        fun read: String import NativeString.to_s_with_length, NativeString.to_s_with_copy `{
                static char c[1024];
-               int n = read(*recv, c, 1023);
+               int n = read(*self, c, 1023);
                if(n < 0) {
                        return NativeString_to_s_with_length("",0);
                }
@@ -152,16 +152,16 @@ extern class NativeSocket `{ int* `}
        #
        # Returns `true` on success.
        fun setsockopt(level: NativeSocketOptLevels, option_name: NativeSocketOptNames, option_value: Int): Bool `{
-               int err = setsockopt(*recv, level, option_name, &option_value, sizeof(int));
+               int err = setsockopt(*self, level, option_name, &option_value, sizeof(int));
                if(err != 0){
                        return 0;
                }
                return 1;
        `}
 
-       fun bind(addrIn: NativeSocketAddrIn): Int `{ return bind(*recv, (struct sockaddr*)addrIn, sizeof(*addrIn)); `}
+       fun bind(addrIn: NativeSocketAddrIn): Int `{ return bind(*self, (struct sockaddr*)addrIn, sizeof(*addrIn)); `}
 
-       fun listen(size: Int): Int `{ return listen(*recv, size); `}
+       fun listen(size: Int): Int `{ return listen(*self, size); `}
 
        # Checks if the buffer is ready for any event specified when creating the pollfd structure
        fun socket_poll(filedesc: PollFD, timeout: Int): Array[NativeSocketPollValues]
@@ -193,7 +193,7 @@ extern class NativeSocket `{ int* `}
 
        private fun native_accept(addr_in: NativeSocketAddrIn): NativeSocket `{
                socklen_t s = sizeof(struct sockaddr);
-               int socket = accept(*recv, (struct sockaddr*)addr_in, &s);
+               int socket = accept(*self, (struct sockaddr*)addr_in, &s);
                if (socket == -1) return NULL;
 
                int *ptr = malloc(sizeof(int));
@@ -211,7 +211,7 @@ extern class NativeSocket `{ int* `}
 
        # Set wether this socket is non blocking
        fun non_blocking=(value: Bool) `{
-               int flags = fcntl(*recv, F_GETFL, 0);
+               int flags = fcntl(*self, F_GETFL, 0);
                if (flags == -1) flags = 0;
 
                if (value) {
@@ -221,7 +221,7 @@ extern class NativeSocket `{ int* `}
                } else {
                        return;
                }
-               fcntl(*recv, F_SETFL, flags);
+               fcntl(*self, F_SETFL, flags);
        `}
 end
 
@@ -260,19 +260,19 @@ extern class NativeSocketAddrIn `{ struct sockaddr_in* `}
                return sai;
        `}
 
-       fun address: String import NativeString.to_s `{ return NativeString_to_s((char*)inet_ntoa(recv->sin_addr)); `}
+       fun address: String import NativeString.to_s `{ return NativeString_to_s((char*)inet_ntoa(self->sin_addr)); `}
 
-       fun family: NativeSocketAddressFamilies `{ return recv->sin_family; `}
+       fun family: NativeSocketAddressFamilies `{ return self->sin_family; `}
 
-       fun port: Int `{ return ntohs(recv->sin_port); `}
+       fun port: Int `{ return ntohs(self->sin_port); `}
 
-       fun destroy `{ free(recv); `}
+       fun destroy `{ free(self); `}
 end
 
 extern class NativeSocketHostent `{ struct hostent* `}
-       private fun native_h_aliases(i: Int): String import NativeString.to_s `{ return NativeString_to_s(recv->h_aliases[i]); `}
+       private fun native_h_aliases(i: Int): String import NativeString.to_s `{ return NativeString_to_s(self->h_aliases[i]); `}
 
-       private fun native_h_aliases_reachable(i: Int): Bool `{ return (recv->h_aliases[i] != NULL); `}
+       private fun native_h_aliases_reachable(i: Int): Bool `{ return (self->h_aliases[i] != NULL); `}
 
        fun h_aliases: Array[String]
        do
@@ -286,13 +286,13 @@ extern class NativeSocketHostent `{ struct hostent* `}
                return d
        end
 
-       fun h_addr: String import NativeString.to_s `{ return NativeString_to_s((char*)inet_ntoa(*(struct in_addr*)recv->h_addr)); `}
+       fun h_addr: String import NativeString.to_s `{ return NativeString_to_s((char*)inet_ntoa(*(struct in_addr*)self->h_addr)); `}
 
-       fun h_addrtype: Int `{ return recv->h_addrtype; `}
+       fun h_addrtype: Int `{ return self->h_addrtype; `}
 
-       fun h_length: Int `{ return recv->h_length; `}
+       fun h_length: Int `{ return self->h_length; `}
 
-       fun h_name: String import NativeString.to_s `{ return NativeString_to_s(recv->h_name); `}
+       fun h_name: String import NativeString.to_s `{ return NativeString_to_s(self->h_name); `}
 end
 
 extern class NativeTimeval `{ struct timeval* `}
@@ -304,11 +304,11 @@ extern class NativeTimeval `{ struct timeval* `}
                return tv;
        `}
 
-       fun seconds: Int `{ return recv->tv_sec; `}
+       fun seconds: Int `{ return self->tv_sec; `}
 
-       fun microseconds: Int `{ return recv->tv_usec; `}
+       fun microseconds: Int `{ return self->tv_usec; `}
 
-       fun destroy `{ free(recv); `}
+       fun destroy `{ free(self); `}
 end
 
 extern class NativeSocketSet `{ fd_set* `}
@@ -318,15 +318,15 @@ extern class NativeSocketSet `{ fd_set* `}
                return f;
        `}
 
-       fun set(s: NativeSocket) `{ FD_SET(*s, recv); `}
+       fun set(s: NativeSocket) `{ FD_SET(*s, self); `}
 
-       fun is_set(s: NativeSocket): Bool `{ return FD_ISSET(*s, recv); `}
+       fun is_set(s: NativeSocket): Bool `{ return FD_ISSET(*s, self); `}
 
-       fun zero `{ FD_ZERO(recv); `}
+       fun zero `{ FD_ZERO(self); `}
 
-       fun clear(s: NativeSocket) `{ FD_CLR(*s, recv); `}
+       fun clear(s: NativeSocket) `{ FD_CLR(*s, self); `}
 
-       fun destroy `{ free(recv); `}
+       fun destroy `{ free(self); `}
 end
 
 class NativeSocketObserver
@@ -479,6 +479,6 @@ extern class NativeSocketPollValues `{ int `}
 
        # Combines two NativeSocketPollValues
        private fun +(other: NativeSocketPollValues): NativeSocketPollValues `{
-               return recv | other;
+               return self | other;
        `}
 end
index 6419ea8..dd45211 100644 (file)
@@ -29,7 +29,7 @@ end
 
 extern class Sqlite3Code `{int`}
        new ok `{ return SQLITE_OK; `} #         0   /* Successful result */
-       fun is_ok: Bool `{ return recv == SQLITE_OK; `}
+       fun is_ok: Bool `{ return self == SQLITE_OK; `}
 
        # new  `{ return SQLITE_ERROR; `} #      1   /* SQL error or missing database */
        # new  `{ return SQLITE_INTERNAL; `} #    2   /* Internal logic error in SQLite */
@@ -61,14 +61,14 @@ extern class Sqlite3Code `{int`}
        # new  `{ return SQLITE_WARNING; `} #    28   /* Warnings from sqlite3_log() */
 
        new row `{ return SQLITE_ROW; `} #        100  /* sqlite3_step() has another row ready */
-       fun is_row: Bool `{ return recv == SQLITE_ROW; `}
+       fun is_row: Bool `{ return self == SQLITE_ROW; `}
 
        new done `{ return SQLITE_DONE; `} #       101  /* sqlite3_step() has finished executing */
-       fun is_done: Bool `{ return recv == SQLITE_DONE; `}
+       fun is_done: Bool `{ return self == SQLITE_DONE; `}
 
-       redef fun to_s: String import NativeString.to_s `{
+       redef fun to_s import NativeString.to_s `{
 #if SQLITE_VERSION_NUMBER >= 3007015
-               char *err = (char *)sqlite3_errstr(recv);
+               char *err = (char *)sqlite3_errstr(self);
 #else
                char *err = "sqlite3_errstr supported only by version >= 3.7.15";
 #endif
@@ -82,11 +82,11 @@ extern class NativeStatement `{sqlite3_stmt*`}
 
        # Evaluate the statement
        fun step: Sqlite3Code `{
-               return sqlite3_step(recv);
+               return sqlite3_step(self);
        `}
 
        fun column_name(i: Int) : String import NativeString.to_s `{
-               const char * name = (sqlite3_column_name(recv, i));
+               const char * name = (sqlite3_column_name(self, i));
                if(name == NULL){
                        name = "";
                }
@@ -96,37 +96,37 @@ extern class NativeStatement `{sqlite3_stmt*`}
 
        # Number of bytes in the blob or string at row `i`
        fun column_bytes(i: Int) : Int `{
-               return sqlite3_column_bytes(recv, i);
+               return sqlite3_column_bytes(self, i);
        `}
 
        fun column_double(i: Int) : Float `{
-               return sqlite3_column_double(recv, i);
+               return sqlite3_column_double(self, i);
        `}
 
        fun column_int(i: Int) : Int `{
-               return sqlite3_column_int(recv, i);
+               return sqlite3_column_int(self, i);
        `}
 
        fun column_text(i: Int): NativeString `{
-               return (char *)sqlite3_column_text(recv, i);
+               return (char *)sqlite3_column_text(self, i);
        `}
 
        # Type of the entry at row `i`
        fun column_type(i: Int): DataType `{
-               return sqlite3_column_type(recv, i);
+               return sqlite3_column_type(self, i);
        `}
 
-       fun column_blob(i: Int): Pointer `{ return (void*)sqlite3_column_blob(recv, i); `}
+       fun column_blob(i: Int): Pointer `{ return (void*)sqlite3_column_blob(self, i); `}
 
        fun column_count: Int `{
-               return sqlite3_column_count(recv);
+               return sqlite3_column_count(self);
        `}
 
        # Reset this statement to its original state, to be reexecuted
-       fun reset: Sqlite3Code `{ return sqlite3_reset(recv); `}
+       fun reset: Sqlite3Code `{ return sqlite3_reset(self); `}
 
        # Delete this statement
-       fun finalize: Sqlite3Code `{ return sqlite3_finalize(recv); `}
+       fun finalize: Sqlite3Code `{ return sqlite3_finalize(self); `}
 end
 
 # A database connection
@@ -155,24 +155,24 @@ extern class NativeSqlite3 `{sqlite3 *`}
        # Close this connection
        fun close `{
 #if SQLITE_VERSION_NUMBER >= 3007014
-               sqlite3_close_v2(recv);
+               sqlite3_close_v2(self);
 #else
                // A program using the older version should not rely on the garbage-collector
                // to close its connections. They must be closed manually after the associated
                // prepare statements have been finalized.
-               sqlite3_close(recv);
+               sqlite3_close(self);
 #endif
        `}
 
        # Execute a SQL statement
        fun exec(sql: String): Sqlite3Code import String.to_cstring `{
-               return sqlite3_exec(recv, String_to_cstring(sql), 0, 0, 0);
+               return sqlite3_exec(self, String_to_cstring(sql), 0, 0, 0);
        `}
 
        # Prepare a SQL statement
        fun prepare(sql: String): nullable NativeStatement import String.to_cstring, NativeStatement.as nullable `{
                sqlite3_stmt *stmt;
-               int res = sqlite3_prepare_v2(recv, String_to_cstring(sql), -1, &stmt, 0);
+               int res = sqlite3_prepare_v2(self, String_to_cstring(sql), -1, &stmt, 0);
                if (res == SQLITE_OK)
                        return NativeStatement_as_nullable(stmt);
                else
@@ -180,21 +180,21 @@ extern class NativeSqlite3 `{sqlite3 *`}
        `}
 
        fun last_insert_rowid: Int `{
-               return sqlite3_last_insert_rowid(recv);
+               return sqlite3_last_insert_rowid(self);
        `}
 
        fun error: Sqlite3Code `{
-               return sqlite3_errcode(recv);
+               return sqlite3_errcode(self);
        `}
 end
 
 # Sqlite data types
 extern class DataType `{ int `}
-       fun is_integer: Bool `{ return recv == SQLITE_INTEGER; `}
-       fun is_float: Bool `{ return recv == SQLITE_FLOAT; `}
-       fun is_blob: Bool `{ return recv == SQLITE_BLOB; `}
-       fun is_null: Bool `{ return recv == SQLITE_NULL; `}
-       fun is_text: Bool `{ return recv == SQLITE_TEXT; `}
+       fun is_integer: Bool `{ return self == SQLITE_INTEGER; `}
+       fun is_float: Bool `{ return self == SQLITE_FLOAT; `}
+       fun is_blob: Bool `{ return self == SQLITE_BLOB; `}
+       fun is_null: Bool `{ return self == SQLITE_NULL; `}
+       fun is_text: Bool `{ return self == SQLITE_TEXT; `}
 
-       fun to_i: Int `{ return recv; `}
+       fun to_i: Int `{ return self; `}
 end
index 0fe8050..5f90801 100644 (file)
@@ -257,7 +257,7 @@ class StatementIterator
 
        redef var item: StatementRow is noinit
 
-       redef var is_ok: Bool is noinit
+       redef var is_ok is noinit
 
        # require: `self.statement.is_open`
        redef fun next
index ecef9e5..c5ed9df 100644 (file)
@@ -1,4 +1,4 @@
-# This file is part of NIT ( http://www.nitlanguage.org ).
+# This file is part of NIT (http://www.nitlanguage.org).
 #
 # Copyright 2014 Julien PagΓ¨s <julien.pages@lirmm.fr>
 #
@@ -6,7 +6,7 @@
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
 #
-#     http://www.apache.org/licenses/LICENSE-2.0
+#       http://www.apache.org/licenses/LICENSE-2.0
 #
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
@@ -24,43 +24,43 @@ in "C header" `{
        #include <assert.h>
 `}
 
-# Add support of binary operations related 
-# to binary level of Integer
-# For compatibility reasons, xor, and, or methods 
-# are still in the math.nit module
+# Add support of binary operations related to binary level of Integer
+# For compatibility reasons, xor, and, or methods are still in the `math` module.
 redef class Int
 
-       # Sets the i-bit of self to the given value
-       #     assert 11.setbit(0, 0) == 10
-       #     assert 10.setbit(0, 1) == 11 
+       # Sets the i-bit of self to the given `value`
+       #
+       #        assert 11.setbit(0, 0) == 10
+       #        assert 10.setbit(0, 1) == 11
        fun setbit(index: Int, value: Int): Int `{
                assert(index >= 0 && index < 32);
 
                if(value == 1)
-                       return recv | (1 << index);
+                       return self | (1 << index);
                else
-                       return recv & ~(1 << index);
+                       return self & ~(1 << index);
        `}
 
-       # Returns the i-bit value of self Integer
-       #     assert 10.getbit(0) == 0
-       #     assert 10.getbit(3) == 1
+       # Returns the i-bit value of `self`
+       #
+       #        assert 10.getbit(0) == 0
+       #        assert 10.getbit(3) == 1
        fun getbit(index: Int): Int `{
                assert(index >= 0 && index < 32);
 
                int op = 1 << index;
-               
-               if((recv & op) == 0)
+
+               if((self & op) == 0)
                        return 0;
                else
                        return 1;
        `}
 
        # Give a binary representation of self Integer
-       fun bits : Array[Int]
+       fun bits: Array[Int]
        do
-               var bits = new Array[Int].with_capacity(32) 
-               
+               var bits = new Array[Int].with_capacity(32)
+
                for i in [0..32[
                do
                        bits[i] = getbit(i)
@@ -69,10 +69,10 @@ redef class Int
                return bits
        end
 
-       # Returns the number of bits of specified value (0 or 1)
-       # in self 
-       #     assert 10.number_bits(1) == 2
-       #     assert 10.number_bits(0) == 30
+       # Returns the number of bits of specified value (0 or 1) in `self`
+       #
+       #        assert 10.number_bits(1) == 2
+       #        assert 10.number_bits(0) == 30
        fun number_bits(value: Int): Int `{
                assert(value == 0 || value == 1);
 
@@ -84,7 +84,7 @@ redef class Int
                {
                        for(i=bound; i>0; i/=2)
                        {
-                               if(recv & i)
+                               if(self & i)
                                        count++;
                        }
                }
@@ -92,27 +92,29 @@ redef class Int
                {
                        for(i=bound; i>0; i/=2)
                        {
-                               if(!(recv & i))
+                               if(!(self & i))
                                        count++;
                        }
                }
                return count;
        `}
 
-       # Returns the position of the highest bit
-       # set to 1 in self (the rightest bit is at position 0)
-       #     assert 10.highest_bit == 3
-       #     assert 1.highest_bit == 0
-       fun highest_bit: Int `{ 
+       # Returns the position of the highest bit set to 1 in `self`
+       #
+       # The rightmost bit is at position 0.
+       #
+       #        assert 10.highest_bit == 3
+       #        assert 1.highest_bit == 0
+       fun highest_bit: Int `{
                long int msb = 1L << 31;
                int pos = 31;
-               
-               while(msb > 0 && !(recv & msb))
+
+               while(msb > 0 && !(self & msb))
                {
                        msb /= 2;
                        pos--;
                }
-               
+
                return pos;
        `}
 end
index b300298..b9b39fd 100644 (file)
@@ -31,7 +31,7 @@ class Bytes
        private var items: NativeString
 
        # Number of bytes in the array
-       redef var length: Int
+       redef var length
 
        # Capacity of the array
        private var capacity: Int
@@ -58,7 +58,7 @@ class Bytes
        #     var b = new Bytes.empty
        #     b.add 101
        #     assert b[0] == 101
-       redef fun [](i: Int): Int do
+       redef fun [](i) do
                assert i >= 0
                assert i < length
                return items[i].ascii
@@ -67,7 +67,7 @@ class Bytes
        #     var b = new Bytes.with_capacity(1)
        #     b[0] = 101
        #     assert b.to_s == "e"
-       redef fun []=(i: Int, v: Int) do
+       redef fun []=(i, v) do
                if persisted then regen
                assert i >= 0
                assert i <= length
@@ -78,7 +78,7 @@ class Bytes
        #     var b = new Bytes.empty
        #     b.add 101
        #     assert b.to_s == "e"
-       redef fun add(c: Int) do
+       redef fun add(c) do
                if persisted then regen
                if length >= capacity then
                        enlarge(length)
@@ -90,7 +90,7 @@ class Bytes
        #     var b = new Bytes.empty
        #     b.append([104, 101, 108, 108, 111])
        #     assert b.to_s == "hello"
-       redef fun append(arr: Collection[Int]) do
+       redef fun append(arr) do
                if arr isa Bytes then
                        append_ns(arr.items, arr.length)
                else
@@ -147,7 +147,7 @@ private class BytesIterator
 
        var tgt: NativeString
 
-       redef var index: Int
+       redef var index
 
        var max: Int
 
index 8b01780..16e4b1e 100644 (file)
@@ -317,7 +317,7 @@ private class ContainerIterator[E]
 
        redef fun next do is_ok = false
 
-       redef var is_ok: Bool = true
+       redef var is_ok = true
 
        var container: Container[E]
 end
@@ -1100,7 +1100,7 @@ end
 private class CoupleMapIterator[K, V]
        super MapIterator[K, V]
        redef fun item do return _iter.item.second
-       
+
        #redef fun item=(e) do _iter.item.second = e
 
        redef fun key do return _iter.item.first
index b3ec382..de66e21 100644 (file)
@@ -5,7 +5,7 @@
 #
 # This file is free software, which comes along with NIT.  This software is
 # distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
-# without  even  the implied warranty of  MERCHANTABILITY or  FITNESS FOR A 
+# without  even  the implied warranty of  MERCHANTABILITY or  FITNESS FOR A
 # PARTICULAR PURPOSE.  You can modify it is you want,  provided this header
 # is kept unaltered, and a notification of the changes is added.
 # You  are  allowed  to  redistribute it and sell it, alone or is a part of
@@ -65,8 +65,7 @@ abstract class AbstractArrayRead[E]
 
        redef fun last_index_of(item) do return last_index_of_from(item, length-1)
 
-       redef fun index_of_from(item, pos)
-       do
+       redef fun index_of_from(item, pos) do
                var i = pos
                var len = length
                while i < len do
@@ -78,8 +77,7 @@ abstract class AbstractArrayRead[E]
                return -1
        end
 
-       redef fun last_index_of_from(item, pos)
-       do
+       redef fun last_index_of_from(item, pos) do
                var i = pos
                while i >= 0 do
                        if self[i] == item then
@@ -242,8 +240,7 @@ abstract class AbstractArray[E]
                self[0] = item
        end
 
-       redef fun insert(item: E, pos: Int)
-       do
+       redef fun insert(item, pos) do
                enlarge(length + 1)
                copy_to(pos, length-pos, self, pos + 1)
                self[pos] = item
index c611ec1..29fa17e 100644 (file)
@@ -19,7 +19,7 @@ import abstract_collection
 class Range[E: Discrete]
        super Collection[E]
 
-       redef var first: E
+       redef var first
 
        # Get the last element.
        var last: E
index f4c6baa..b44b7f9 100644 (file)
@@ -115,8 +115,7 @@ class DisjointSet[E]
        #     s.add(1)
        #     assert s.has(1)
        #     assert not s.has(2)
-       redef fun has(e)
-       do
+       redef fun has(e) do
                return nodes.has_key(e)
        end
 
@@ -126,8 +125,7 @@ class DisjointSet[E]
        # Initially it is in its own disjoint subset
        #
        # ENSURE: `has(e)`
-       redef fun add(e:E)
-       do
+       redef fun add(e) do
                if nodes.has_key(e) then return
                var ne = new DisjointSetNode
                nodes[e] = ne
index 3548a25..3bad3f3 100644 (file)
@@ -135,7 +135,7 @@ class FileReader
        end
 
        # End of file?
-       redef var end_reached: Bool = false
+       redef var end_reached = false
 
        # Open the file at `path` for reading.
        #
@@ -299,7 +299,7 @@ class Stdin
                prepare_buffer(1)
        end
 
-       redef fun poll_in: Bool is extern "file_stdin_poll_in"
+       redef fun poll_in is extern "file_stdin_poll_in"
 end
 
 # Standard output stream.
@@ -1056,12 +1056,12 @@ redef class NativeString
                struct stat* stat_element;
                int res;
                stat_element = malloc(sizeof(struct stat));
-               res = lstat(recv, stat_element);
+               res = lstat(self, stat_element);
                if (res == -1) return NULL;
                return stat_element;
        `}
        private fun file_mkdir: Bool is extern "string_NativeString_NativeString_file_mkdir_0"
-       private fun rmdir: Bool `{ return !rmdir(recv); `}
+       private fun rmdir: Bool `{ return !rmdir(self); `}
        private fun file_delete: Bool is extern "string_NativeString_NativeString_file_delete_0"
        private fun file_chdir: Bool is extern "string_NativeString_NativeString_file_chdir_0"
        private fun file_realpath: NativeString is extern "file_NativeString_realpath"
@@ -1081,19 +1081,19 @@ private extern class NativeFileStat `{ struct stat * `}
        fun size: Int is extern "file_FileStat_FileStat_size_0"
 
        # Returns true if it is a regular file (not a device file, pipe, sockect, ...)
-       fun is_reg: Bool `{ return S_ISREG(recv->st_mode); `}
+       fun is_reg: Bool `{ return S_ISREG(self->st_mode); `}
        # Returns true if it is a directory
-       fun is_dir: Bool `{ return S_ISDIR(recv->st_mode); `}
+       fun is_dir: Bool `{ return S_ISDIR(self->st_mode); `}
        # Returns true if it is a character device
-       fun is_chr: Bool `{ return S_ISCHR(recv->st_mode); `}
+       fun is_chr: Bool `{ return S_ISCHR(self->st_mode); `}
        # Returns true if it is a block device
-       fun is_blk: Bool `{ return S_ISBLK(recv->st_mode); `}
+       fun is_blk: Bool `{ return S_ISBLK(self->st_mode); `}
        # Returns true if the type is fifo
-       fun is_fifo: Bool `{ return S_ISFIFO(recv->st_mode); `}
+       fun is_fifo: Bool `{ return S_ISFIFO(self->st_mode); `}
        # Returns true if the type is a link
-       fun is_lnk: Bool `{ return S_ISLNK(recv->st_mode); `}
+       fun is_lnk: Bool `{ return S_ISLNK(self->st_mode); `}
        # Returns true if the type is a socket
-       fun is_sock: Bool `{ return S_ISSOCK(recv->st_mode); `}
+       fun is_sock: Bool `{ return S_ISSOCK(self->st_mode); `}
 end
 
 # Instance of this class are standard FILE * pointers
@@ -1102,11 +1102,11 @@ private extern class NativeFile `{ FILE* `}
        fun io_write(buf: NativeString, len: Int): Int is extern "file_NativeFile_NativeFile_io_write_2"
        fun write_byte(value: Int): Int `{
                unsigned char b = (unsigned char)value;
-               return fwrite(&b, 1, 1, recv);
+               return fwrite(&b, 1, 1, self);
        `}
        fun io_close: Int is extern "file_NativeFile_NativeFile_io_close_0"
        fun file_stat: NativeFileStat is extern "file_NativeFile_NativeFile_file_stat_0"
-       fun fileno: Int `{ return fileno(recv); `}
+       fun fileno: Int `{ return fileno(self); `}
        # Flushes the buffer, forcing the write operation
        fun flush: Int is extern "fflush"
        # Used to specify how the buffering will be handled for the current stream.
@@ -1126,12 +1126,12 @@ private extern class NativeDir `{ DIR* `}
        new opendir(path: NativeString) `{ return opendir(path); `}
 
        # Close a directory
-       fun closedir `{ closedir(recv); `}
+       fun closedir `{ closedir(self); `}
 
        # Read the next directory entry
        fun readdir: NativeString `{
                struct dirent *de;
-               de = readdir(recv);
+               de = readdir(self);
                if (!de) return NULL;
                return de->d_name;
        `}
index 85386b4..ffd684a 100644 (file)
@@ -5,7 +5,7 @@
 #
 # This file is free software, which comes along with NIT.  This software is
 # distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
-# without  even  the implied warranty of  MERCHANTABILITY or  FITNESS FOR A 
+# without  even  the implied warranty of  MERCHANTABILITY or  FITNESS FOR A
 # PARTICULAR PURPOSE.  You can modify it is you want,  provided this header
 # is kept unaltered, and a notification of the changes is added.
 # You  are  allowed  to  redistribute it and sell it, alone or is a part of
@@ -128,7 +128,7 @@ interface Comparable
        type OTHER: Comparable
 
        # Is `self` lesser than `other`?
-       fun <(other: OTHER): Bool is abstract 
+       fun <(other: OTHER): Bool is abstract
 
        # not `other` < `self`
        # Note, the implementation must ensure that: `(x<=y) == (x<y or x==y)`
@@ -331,10 +331,10 @@ universal Float
        redef fun !=(i) is intern
        redef fun output is intern
 
-       redef fun <=(i): Bool is intern
-       redef fun <(i): Bool is intern
-       redef fun >=(i): Bool is intern
-       redef fun >(i): Bool is intern
+       redef fun <=(i) is intern
+       redef fun <(i) is intern
+       redef fun >=(i) is intern
+       redef fun >(i) is intern
 
        redef fun +(i) is intern
        redef fun - is intern
@@ -483,9 +483,9 @@ universal Int
 
        redef fun is_between(c, d)
        do
-               if self < c or d < self then 
+               if self < c or d < self then
                        return false
-               else 
+               else
                        return true
                end
        end
@@ -536,7 +536,7 @@ universal Int
                # count digits
                while n > 0 do
                        d += 1
-                       n = n / b       # euclidian division /
+                       n = n / b       # euclidian division /
                end
                return d
        end
index 9e1744f..8b5fecb 100644 (file)
@@ -47,7 +47,7 @@ redef class Int
        # Returns the square root of `self`
        #
        #     assert 16.sqrt == 4
-       fun sqrt: Int `{ return sqrt(recv); `}
+       fun sqrt: Int `{ return sqrt(self); `}
 
        # Returns the greatest common divisor of `self` and `o`
        #
@@ -158,7 +158,7 @@ redef class Float
        #     assert 12.0.abs == 12.0
        #     assert (-34.56).abs == 34.56
        #     assert -34.56.abs == -34.56
-       fun abs: Float `{ return fabs(recv); `}
+       fun abs: Float `{ return fabs(self); `}
 
        # Returns `self` raised at `e` power.
        #
@@ -186,13 +186,13 @@ redef class Float
        #     assert 1.9.ceil == 2.0
        #     assert 2.0.ceil == 2.0
        #     assert (-1.5).ceil == -1.0
-       fun ceil: Float `{ return ceil(recv); `}
+       fun ceil: Float `{ return ceil(self); `}
 
        #     assert 1.1.floor == 1.0
        #     assert 1.9.floor == 1.0
        #     assert 2.0.floor == 2.0
        #     assert (-1.5).floor == -2.0
-       fun floor: Float `{ return floor(recv); `}
+       fun floor: Float `{ return floor(self); `}
 
        # Rounds the value of a float to its nearest integer value
        #
index 1fe850d..7f4b24b 100644 (file)
@@ -61,22 +61,22 @@ extern class Passwd `{struct passwd*`}
        new from_name(name: String) import String.to_cstring `{ return getpwnam( String_to_cstring(name) ); `}
 
        # Username
-       fun name: String import NativeString.to_s `{ return NativeString_to_s(recv->pw_name); `}
+       fun name: String import NativeString.to_s `{ return NativeString_to_s(self->pw_name); `}
 
        # User password
-       fun passwd: String import NativeString.to_s `{ return NativeString_to_s(recv->pw_passwd); `}
+       fun passwd: String import NativeString.to_s `{ return NativeString_to_s(self->pw_passwd); `}
 
        # User ID
-       fun uid: Int `{ return recv->pw_uid; `}
+       fun uid: Int `{ return self->pw_uid; `}
 
        # Group ID
-       fun gid: Int `{ return recv->pw_gid; `}
+       fun gid: Int `{ return self->pw_gid; `}
 
        # Home directory
-       fun dir: String import NativeString.to_s `{ return NativeString_to_s(recv->pw_dir); `}
+       fun dir: String import NativeString.to_s `{ return NativeString_to_s(self->pw_dir); `}
 
        # Shell program
-       fun shell: String import NativeString.to_s `{ return NativeString_to_s(recv->pw_shell); `}
+       fun shell: String import NativeString.to_s `{ return NativeString_to_s(self->pw_shell); `}
 end
 
 # Information on a user group
@@ -88,13 +88,13 @@ extern class Group `{struct group*`}
        new from_name(name: String) import String.to_cstring `{ return getgrnam( String_to_cstring(name) ); `}
 
        # Name of this ground
-       fun name: String import NativeString.to_s `{ return NativeString_to_s(recv->gr_name); `}
+       fun name: String import NativeString.to_s `{ return NativeString_to_s(self->gr_name); `}
 
        # Encrypted password of this group
-       fun passwd: String import NativeString.to_s `{ return NativeString_to_s(recv->gr_passwd); `}
+       fun passwd: String import NativeString.to_s `{ return NativeString_to_s(self->gr_passwd); `}
 
        # Id of this group
-       fun gid: Int `{ return recv->gr_gid; `}
+       fun gid: Int `{ return self->gr_gid; `}
 
        # List of the members of the group
        fun mem: Array[String] import Array[String], Array[String].add, NativeString.to_s `{
@@ -102,7 +102,7 @@ extern class Group `{struct group*`}
                int m;
                Array_of_String ret;
 
-               mem = recv->gr_mem;
+               mem = self->gr_mem;
                ret = new_Array_of_String();
 
                for (m = 0; mem[m] != NULL; m++)
index a58aba0..24637cb 100644 (file)
@@ -42,7 +42,7 @@ private extern class NativeRegex `{ regex_t* `}
 
        # Compile the regular expression `regex` into a form that is suitable for subsequent `regexec` searches
        fun regcomp(regex: NativeString, cflags: Int): Int `{
-               return regcomp(recv, regex, cflags);
+               return regcomp(self, regex, cflags);
        `}
 
        # Match `string` against the precompiled pattern buffer of `self`, locating matches
@@ -50,32 +50,32 @@ private extern class NativeRegex `{ regex_t* `}
        # `nmatch` and `pmatch` are used to provide information regarding the location of any matches.
        # `eflags` may be the bitwise-or of one or both of `flag_notbol` and `flag_noteol`.
        fun regexec(string: NativeString, nmatch: Int, pmatch: NativeMatchArray, eflags: Int): Int `{
-               return regexec(recv, string, nmatch, pmatch, eflags);
+               return regexec(self, string, nmatch, pmatch, eflags);
        `}
 
        # Match `string` against the precompiled pattern buffer of `self`, do not locate matches
        #
        # `eflags` may be the bitwise-or of one or both of `flag_notbol` and `flag_noteol`.
        fun regexec_match_only(string: NativeString, eflags: Int): Int `{
-               return regexec(recv, string, 0, NULL, eflags);
+               return regexec(self, string, 0, NULL, eflags);
        `}
 
        # Free the memory allocated to the pattern buffer by the compiling process
        #
        # Does not free the memory holding `self`, use `free` for this purpose.
-       fun regfree `{ regfree(recv); `}
+       fun regfree `{ regfree(self); `}
 
        # Turn the error codes that can be returned by both `regcomp` and `regexec` into error message strings
        fun regerror(errcode: Int): NativeString `{
-               size_t len = regerror(errcode, recv, NULL, 0);
+               size_t len = regerror(errcode, self, NULL, 0);
                char *message = malloc(len);
-               regerror(errcode, recv, message, len);
+               regerror(errcode, self, message, len);
 
                return message;
        `}
 
        # Number of parenthetical subexpressions in this compiled regular expression
-       fun re_nsub: Int `{ return recv->re_nsub; `}
+       fun re_nsub: Int `{ return self->re_nsub; `}
 end
 
 # Flags for `NativeRegex::regcomp`
@@ -96,7 +96,7 @@ private fun error_nomatch: Int `{ return REG_NOMATCH; `}
 private fun error_espace: Int `{ return REG_ESPACE; `}
 
 redef universal Int
-       private fun is_nomatch: Bool `{ return recv == REG_NOMATCH; `}
+       private fun is_nomatch: Bool `{ return self == REG_NOMATCH; `}
 end
 
 # An array of `regmatch_t` or a pointer to one
@@ -105,17 +105,17 @@ private extern class NativeMatchArray `{ regmatch_t* `}
        new malloc(length: Int) `{ return malloc(length * sizeof(regmatch_t)); `}
 
        # The offset in string of the beginning of a substring
-       fun rm_so: Int `{ return recv->rm_so; `}
+       fun rm_so: Int `{ return self->rm_so; `}
 
        # The offset in string of the end of the substring
-       fun rm_eo: Int `{ return recv->rm_eo; `}
+       fun rm_eo: Int `{ return self->rm_eo; `}
 
        # Get a pointer to the element at `index`, can also be used as a subarray
-       fun [](index: Int): NativeMatchArray `{ return recv + index; `}
+       fun [](index: Int): NativeMatchArray `{ return self + index; `}
 end
 
 redef extern class NativeString
-       private fun substring_from(index: Int): NativeString `{ return recv + index; `}
+       private fun substring_from(index: Int): NativeString `{ return self + index; `}
 end
 
 redef class Text
index 5ac6ee2..902649a 100644 (file)
@@ -74,7 +74,7 @@ end
 private class Concat
        super RopeString
 
-       redef var length: Int is noinit
+       redef var length is noinit
 
        redef fun substrings do return new RopeSubstrings(self)
 
@@ -159,7 +159,6 @@ private class Concat
        end
 
        redef fun copy_to_native(dest, n, src_offset, dest_offset) do
-               var remlen = n
                var subs = new RopeSubstrings.from(self, src_offset)
                var st = src_offset - subs.pos
                var off = dest_offset
@@ -827,7 +826,7 @@ class RopeBufferIter
        # Maximum position iterable.
        var maxpos: Int
 
-       redef var index: Int
+       redef var index
 
        # Init the iterator from a RopeBuffer.
        init(t: RopeBuffer) is old_style_init do
@@ -877,7 +876,7 @@ class RopeBufferReviter
        # Current position in `ns`.
        var pns: Int
 
-       redef var index: Int
+       redef var index
 
        # Init the iterator from a RopeBuffer.
        init(tgt: RopeBuffer) is old_style_init do
index 61af948..60f3af9 100644 (file)
@@ -898,8 +898,8 @@ abstract class Text
        #
        # REQUIRE: `n` must be large enough to contain `len` bytes
        #
-       #       var ns = new NativeString(8)
-       #       "Text is String".copy_to_native(ns, 8, 2, 0)
+       #       var ns = new NativeString(8)
+       #       "Text is String".copy_to_native(ns, 8, 2, 0)
        #       assert ns.to_s_with_length(8) == "xt is St"
        #
        fun copy_to_native(dest: NativeString, n, src_offset, dest_offset: Int) do
@@ -945,7 +945,7 @@ abstract class FlatText
        # copy locally the char* as Nit Strings are immutable.
        private fun fast_cstring: NativeString is abstract
 
-       redef var length: Int = 0
+       redef var length = 0
 
        redef fun output
        do
@@ -1194,7 +1194,7 @@ class FlatString
        # Indes in _items of the last item of the string
        private var index_to: Int is noinit
 
-       redef var chars: SequenceRead[Char] = new FlatStringCharView(self) is lazy
+       redef var chars = new FlatStringCharView(self) is lazy
 
        redef fun [](index)
        do
@@ -1319,8 +1319,7 @@ class FlatString
                index_to = to
        end
 
-       redef fun to_cstring: NativeString
-       do
+       redef fun to_cstring do
                if real_items != null then
                        return real_items.as(not null)
                else
@@ -1738,8 +1737,7 @@ class FlatBuffer
                capacity = c
        end
 
-       redef fun to_s: String
-       do
+       redef fun to_s do
                written = true
                if length == 0 then items = new NativeString(1)
                return new FlatString.with_infos(items, length, 0, length - 1)
index e0b3867..99a9f35 100644 (file)
@@ -41,20 +41,20 @@ extern class TimeT `{time_t`}
        new from_i(i: Int) `{ return i; `}
 
        # Update current time.
-       fun update `{ time(&recv); `}
+       fun update `{ time(&self); `}
 
        # Convert `self` to a human readable String.
        fun ctime: String import NativeString.to_s_with_copy `{
-               return NativeString_to_s_with_copy( ctime(&recv) );
+               return NativeString_to_s_with_copy( ctime(&self) );
        `}
 
        # Difference in secondes from start (self if the end time)
-       fun difftime(start: TimeT): Float `{ return difftime(recv, start); `}
+       fun difftime(start: TimeT): Float `{ return difftime(self, start); `}
 
        redef fun to_s do return ctime.replace("\n", "")
 
        # Convert self to Int (expressed as seconds since epoch).
-       fun to_i: Int `{ return (int)recv; `}
+       fun to_i: Int `{ return (int)self; `}
 end
 
 # Time structure
@@ -91,38 +91,38 @@ extern class Tm `{struct tm *`}
        `}
 
        # Convert `self` as a TimeT.
-       fun to_timet: TimeT `{ return mktime(recv); `}
+       fun to_timet: TimeT `{ return mktime(self); `}
 
        # Seconds after the minute.
-       fun sec: Int `{ return recv->tm_sec; `}
+       fun sec: Int `{ return self->tm_sec; `}
 
        # Minutes after the hour.
-       fun min: Int `{ return recv->tm_min; `}
+       fun min: Int `{ return self->tm_min; `}
 
        # hours since midnight.
-       fun hour: Int `{ return recv->tm_hour; `}
+       fun hour: Int `{ return self->tm_hour; `}
 
        # Day of the month.
-       fun mday: Int `{ return recv->tm_mday; `}
+       fun mday: Int `{ return self->tm_mday; `}
 
        # Months since January.
-       fun mon: Int `{ return recv->tm_mon; `}
+       fun mon: Int `{ return self->tm_mon; `}
 
        # Years since 1900.
-       fun year: Int `{ return recv->tm_year; `}
+       fun year: Int `{ return self->tm_year; `}
 
        # Days since Sunday.
-       fun wday: Int `{ return recv->tm_wday; `}
+       fun wday: Int `{ return self->tm_wday; `}
 
        # Days since January 1st.
-       fun yday: Int `{ return recv->tm_yday; `}
+       fun yday: Int `{ return self->tm_yday; `}
 
        # Is `self` in Daylight Saving Time.
-       fun is_dst: Bool `{ return recv->tm_isdst; `}
+       fun is_dst: Bool `{ return self->tm_isdst; `}
 
        # Convert `self` to a human readable String.
        fun asctime: String import NativeString.to_s_with_copy `{
-               return NativeString_to_s_with_copy( asctime(recv) );
+               return NativeString_to_s_with_copy( asctime(self) );
        `}
 
        # Convert `self` to a human readable String corresponding to `format`.
@@ -134,7 +134,7 @@ extern class Tm `{struct tm *`}
                buf = (char*)malloc(100);
                c_format = String_to_cstring(format);
 
-               res = strftime(buf, 100, c_format, recv);
+               res = strftime(buf, 100, c_format, self);
                String s = NativeString_to_s_with_copy(buf);
                free(buf);
                return s;
index ec66af6..b3a2450 100644 (file)
@@ -57,8 +57,8 @@ extern class UTF8Char `{ UTF8Char* `}
        #  4       | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
        # ~~~
        private fun len: Int `{
-               char* ns = recv->ns;
-               int pos = recv->pos;
+               char* ns = self->ns;
+               int pos = self->pos;
                char nspos = ns[pos];
                if((nspos & 0x80) == 0x00){ return 1;}
                if((nspos & 0xE0) == 0xC0){ return 2;}
@@ -70,34 +70,34 @@ extern class UTF8Char `{ UTF8Char* `}
 
        # Position in containing NativeString
        private fun pos: Int `{
-               return recv->pos;
+               return self->pos;
        `}
 
-       private fun pos=(p: Int) `{recv->pos = p;`}
+       private fun pos=(p: Int) `{self->pos = p;`}
 
        # C char* wrapping the char
        fun ns: NativeString `{
-               return recv->ns;
+               return self->ns;
        `}
 
        # Returns the Unicode code point representing the character
        #
        # Note : A unicode character might not be a visible glyph, but it will be used to determine canonical equivalence
        fun code_point: Int import UTF8Char.len `{
-               switch(UTF8Char_len(recv)){
+               switch(UTF8Char_len(self)){
                        case 1:
-                               return (long)(0x7F & (unsigned char)recv->ns[recv->pos]);
+                               return (long)(0x7F & (unsigned char)self->ns[self->pos]);
                        case 2:
-                               return 0 | ((0x1F & (unsigned char)recv->ns[recv->pos]) << 6) | (0x3F & (unsigned char)recv->ns[recv->pos+1]);
+                               return 0 | ((0x1F & (unsigned char)self->ns[self->pos]) << 6) | (0x3F & (unsigned char)self->ns[self->pos+1]);
                        case 3:
-                               return 0 | ((0x0F & (unsigned char)recv->ns[recv->pos]) << 12) |
-                               ((0x3F & (unsigned char)recv->ns[recv->pos+1]) << 6) |
-                               (0x3F & (unsigned char)recv->ns[recv->pos+2]);
+                               return 0 | ((0x0F & (unsigned char)self->ns[self->pos]) << 12) |
+                               ((0x3F & (unsigned char)self->ns[self->pos+1]) << 6) |
+                               (0x3F & (unsigned char)self->ns[self->pos+2]);
                        case 4:
-                               return 0 | ((0x07 & (unsigned char)recv->ns[recv->pos]) << 18) |
-                               ((0x3F & (unsigned char)recv->ns[recv->pos+1]) << 12) |
-                               ((0x3F & (unsigned char)recv->ns[recv->pos+2]) << 6) |
-                               (0x3F & (unsigned char)recv->ns[recv->pos+3]);
+                               return 0 | ((0x07 & (unsigned char)self->ns[self->pos]) << 18) |
+                               ((0x3F & (unsigned char)self->ns[self->pos+1]) << 12) |
+                               ((0x3F & (unsigned char)self->ns[self->pos+2]) << 6) |
+                               (0x3F & (unsigned char)self->ns[self->pos+3]);
                }
        `}
 
@@ -106,11 +106,11 @@ extern class UTF8Char `{ UTF8Char* `}
        # NOTE : Works only on ASCII chars
        # TODO : Support unicode for to_upper
        fun to_upper: UTF8Char import UTF8Char.code_point `{
-               int cp = UTF8Char_code_point(recv);
-               if(cp < 97 || cp > 122){ return recv; }
+               int cp = UTF8Char_code_point(self);
+               if(cp < 97 || cp > 122){ return self; }
                char* ns = malloc(2);
                ns[1] = '\0';
-               char c = recv->ns[recv->pos];
+               char c = self->ns[self->pos];
                ns[0] = c - 32;
                UTF8Char* ret = malloc(sizeof(UTF8Char));
                ret->ns = ns;
@@ -123,11 +123,11 @@ extern class UTF8Char `{ UTF8Char* `}
        # NOTE : Works only on ASCII chars
        # TODO : Support unicode for to_upper
        fun to_lower: UTF8Char import UTF8Char.code_point `{
-               int cp = UTF8Char_code_point(recv);
-               if(cp < 65 || cp > 90){ return recv; }
+               int cp = UTF8Char_code_point(self);
+               if(cp < 65 || cp > 90){ return self; }
                char* ns = malloc(2);
                ns[1] = '\0';
-               char c = recv->ns[recv->pos];
+               char c = self->ns[self->pos];
                ns[0] = c + 32;
                UTF8Char* ret = malloc(sizeof(UTF8Char));
                ret->ns = ns;
@@ -148,27 +148,27 @@ extern class UTF8Char `{ UTF8Char* `}
        end
 
        redef fun output import UTF8Char.code_point `{
-               switch(UTF8Char_len(recv)){
+               switch(UTF8Char_len(self)){
                        case 1:
-                               printf("%c", recv->ns[recv->pos]);
+                               printf("%c", self->ns[self->pos]);
                                break;
                        case 2:
-                               printf("%c%c", recv->ns[recv->pos], recv->ns[recv->pos + 1]);
+                               printf("%c%c", self->ns[self->pos], self->ns[self->pos + 1]);
                                break;
                        case 3:
-                               printf("%c%c%c", recv->ns[recv->pos], recv->ns[recv->pos + 1], recv->ns[recv->pos + 2]);
+                               printf("%c%c%c", self->ns[self->pos], self->ns[self->pos + 1], self->ns[self->pos + 2]);
                                break;
                        case 4:
-                               printf("%c%c%c%c", recv->ns[recv->pos], recv->ns[recv->pos + 1], recv->ns[recv->pos + 2], recv->ns[recv->pos + 3]);
+                               printf("%c%c%c%c", self->ns[self->pos], self->ns[self->pos + 1], self->ns[self->pos + 2], self->ns[self->pos + 3]);
                                break;
                }
        `}
 
        redef fun to_s import NativeString.to_s_with_length `{
-               int len = utf8___UTF8Char_len___impl(recv);
+               int len = utf8___UTF8Char_len___impl(self);
                char* r = malloc(len + 1);
                r[len] = '\0';
-               char* src = (recv->ns + recv->pos);
+               char* src = (self->ns + self->pos);
                memcpy(r, src, len);
                return NativeString_to_s_with_length(r, len);
        `}
@@ -182,14 +182,14 @@ private extern class StringIndex `{ UTF8Char* `}
        new(size: Int) `{ return malloc(size*sizeof(UTF8Char)); `}
 
        # Sets the character at `index` as `item`
-       fun []=(index: Int, item: UTF8Char) `{ recv[index] = *item; `}
+       fun []=(index: Int, item: UTF8Char) `{ self[index] = *item; `}
 
        # Gets the character at position `id`
-       fun [](id: Int): UTF8Char `{ return &recv[id]; `}
+       fun [](id: Int): UTF8Char `{ return &self[id]; `}
 
        # Copies a part of self starting at index `my_from` of length `length` into `other`, starting at `its_from`
        fun copy_to(other: StringIndex, my_from: Int, its_from: Int, length: Int)`{
-               UTF8Char* myfrom = recv + my_from*(sizeof(UTF8Char));
+               UTF8Char* myfrom = self + my_from*(sizeof(UTF8Char));
                UTF8Char* itsfrom = other + its_from*(sizeof(UTF8Char));
                memcpy(itsfrom, myfrom, length);
        `}
@@ -380,7 +380,7 @@ redef class NativeString
                while(pos < length){
                        UTF8Char* curr = &index[index_pos];
                        curr->pos = pos;
-                       curr->ns = recv;
+                       curr->ns = self;
                        pos += UTF8Char_len(curr);
                        index_pos ++;
                }
@@ -394,7 +394,7 @@ redef class NativeString
                return to_s_with_length(len)
        end
 
-       redef fun to_s_with_length(len: Int): FlatString
+       redef fun to_s_with_length(len)
        do
                var real_len = new Container[Int](0)
                var x = make_index(len, real_len)
index 2875a8b..8756838 100644 (file)
@@ -63,7 +63,7 @@ extern class UnicodeChar `{ uint32_t* `}
        #  4       | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
        # ~~~
        fun len: Int `{
-               uint32_t s = *recv;
+               uint32_t s = *self;
                if(s <= 127) {return 1;}
                if(s >= 49280 && s <= 57279) {return 2;}
                if(s >= 14712960 && s <= 15712191) {return 3;}
@@ -76,11 +76,11 @@ extern class UnicodeChar `{ uint32_t* `}
        #
        # Note : A unicode character might not be a visible glyph, but it will be used to determine canonical equivalence
        fun code_point: Int import UnicodeChar.len `{
-               uint32_t val = *recv;
+               uint32_t val = *self;
                uint32_t ret = 0;
-               switch(UnicodeChar_len(recv)){
+               switch(UnicodeChar_len(self)){
                        case 1:
-                               ret = *recv;
+                               ret = *self;
                                break;
                        case 2:
                                ret = 0 | ((val & 0x00001F00) >> 2) | (val & 0x0000003F);
@@ -106,9 +106,9 @@ extern class UnicodeChar `{ uint32_t* `}
        # NOTE : Works only on ASCII chars
        # TODO : Support unicode for to_upper
        fun to_upper: UnicodeChar import UnicodeChar.code_point `{
-               if(*recv < 97 || *recv > 122){ return recv; }
+               if(*self < 97 || *self > 122){ return self; }
                uint32_t* ret = calloc(1,4);
-               *ret = *recv - 32;
+               *ret = *self - 32;
                return ret;
        `}
 
@@ -117,9 +117,9 @@ extern class UnicodeChar `{ uint32_t* `}
        # NOTE : Works only on ASCII chars
        # TODO : Support unicode for to_upper
        fun to_lower: UnicodeChar import UnicodeChar.code_point `{
-               if(*recv < 65 || *recv > 90){ return recv; }
+               if(*self < 65 || *self > 90){ return self; }
                uint32_t* ret = calloc(1,4);
-               *ret = *recv + 32;
+               *ret = *self + 32;
                return ret;
        `}
 
@@ -131,13 +131,13 @@ extern class UnicodeChar `{ uint32_t* `}
        end
 
        redef fun output import UnicodeChar.len `{
-               uint32_t self = *recv;
+               uint32_t self0 = *self;
                if(!IS_BIG_ENDIAN){
-                       uint32_t tmp = ntohl(self);
-                       memcpy(&self, &tmp, 4);
+                       uint32_t tmp = ntohl(self0);
+                       memcpy(&self0, &tmp, 4);
                }
-               unsigned char* s = (unsigned char*) &self;
-               switch(UnicodeChar_len(recv)){
+               unsigned char* s = (unsigned char*) &self0;
+               switch(UnicodeChar_len(self0)){
                        case 1:
                                printf("%c", s[3]);
                                break;
@@ -154,10 +154,10 @@ extern class UnicodeChar `{ uint32_t* `}
        `}
 
        redef fun to_s: FlatString import FlatString.full, UnicodeChar.len `{
-               int len = UnicodeChar_len(recv);
+               int len = UnicodeChar_len(self);
                char* r = malloc(len + 1);
                r[len] = '\0';
-               uint32_t src = *recv;
+               uint32_t src = *self;
                if(!IS_BIG_ENDIAN){
                        uint32_t tmp = htonl(src);
                        memcpy(&src, &tmp, 4);
@@ -271,7 +271,7 @@ redef class FlatString
        redef type OTHER: FlatString
 
        # Length in bytes of the string (e.g. the length of the C string)
-       redef var bytelen: Int
+       redef var bytelen
 
        # Cache for the last accessed character in the char
        var cache = new CharCache(-1,-1)
@@ -289,9 +289,9 @@ redef class FlatString
 
        # Length implementation
        private fun length_l: Int import FlatString.items, FlatString.index_to, FlatString.index_from `{
-               char* ns = FlatString_items(recv);
-               int i = FlatString_index_from(recv);
-               int max = FlatString_index_to(recv);
+               char* ns = FlatString_items(self);
+               int i = FlatString_index_from(self);
+               int max = FlatString_index_to(self);
                int length = 0;
                while(i <= max){
                        char c = ns[i];
@@ -475,7 +475,7 @@ redef class FlatString
        end
 
        # O(n)
-       redef fun substring(from: Int, count: Int) do
+       redef fun substring(from, count) do
                assert count >= 0
 
                if from < 0 then
@@ -518,7 +518,7 @@ end
 
 redef class FlatBuffer
 
-       redef var bytelen: Int
+       redef var bytelen
 
        redef init from(s) do
                if s isa Concat then
@@ -558,20 +558,20 @@ redef class FlatBuffer
 
        # Shifts the content of the buffer by `len` bytes to the right, starting at byte `from`
        fun rshift_bytes(from: Int, len: Int) import FlatBuffer.bytelen, FlatBuffer.bytelen=, FlatBuffer.items `{
-               long bt = FlatBuffer_bytelen(recv);
-               char* ns = FlatBuffer_items(recv);
+               long bt = FlatBuffer_bytelen(self);
+               char* ns = FlatBuffer_items(self);
                int off = from + len;
                memmove(ns + off, ns + from, bt - from);
-               FlatBuffer_bytelen__assign(recv, bt + len);
+               FlatBuffer_bytelen__assign(self, bt + len);
        `}
 
        # Shifts the content of the buffer by `len` bytes to the left, starting at `from`
        fun lshift_bytes(from: Int, len: Int) import FlatBuffer.bytelen, FlatBuffer.bytelen=, FlatBuffer.items `{
-               long bt = FlatBuffer_bytelen(recv);
-               char* ns = FlatBuffer_items(recv);
+               long bt = FlatBuffer_bytelen(self);
+               char* ns = FlatBuffer_items(self);
                int off = from - len;
                memmove(ns + off, ns + from, bt - from);
-               FlatBuffer_bytelen__assign(recv, bt - len);
+               FlatBuffer_bytelen__assign(self, bt - len);
        `}
 
        # Get the Unicode char stored at `index` in `self`
@@ -717,7 +717,7 @@ redef class NativeString
                return to_s_with_length(len)
        end
 
-       redef fun to_s_with_length(len: Int): FlatString
+       redef fun to_s_with_length(len)
        do
                return new FlatString.with_bytelen(self, 0, len - 1, len)
        end
index b67df17..fc37617 100644 (file)
@@ -200,7 +200,7 @@ class Template
        end
 
        # Do the full rendering and write the final content to a stream
-       redef fun write_to(stream: Writer)
+       redef fun write_to(stream)
        do
                assert not is_writing
                is_writing = true
index 3f6e3ee..6c53124 100644 (file)
@@ -37,7 +37,7 @@ extern class XdgBasedir `{ xdgHandle* `}
        fun is_valid: Bool do return not address_is_null
 
        # Wipe handle of XDG data cache.
-       fun destroy `{ xdgWipeHandle(recv); `}
+       fun destroy `{ xdgWipeHandle(self); `}
 
        # Update the data cache.
        #
@@ -46,21 +46,21 @@ extern class XdgBasedir `{ xdgHandle* `}
        # be used to access XDG data as it was before `update` was called.
        #
        # Returns `true` if the update was successful.
-       fun update: Bool `{ return xdgUpdateData(recv); `}
+       fun update: Bool `{ return xdgUpdateData(self); `}
 
        # Base directory for user specific data files.
        fun data_home: String import NativeString.to_s `{
-               return NativeString_to_s((char*)xdgDataHome(recv));
+               return NativeString_to_s((char*)xdgDataHome(self));
        `}
 
        # Base directory for user specific configuration files.
        fun config_home: String import NativeString.to_s `{
-               return NativeString_to_s((char*)xdgConfigHome(recv));
+               return NativeString_to_s((char*)xdgConfigHome(self));
        `}
 
        # Base directory for user specific non-essential data files.
        fun cache_home: String import NativeString.to_s `{
-               return NativeString_to_s((char*)xdgCacheHome(recv));
+               return NativeString_to_s((char*)xdgCacheHome(self));
        `}
 
        # Preference-ordered set of base directories to search for data files
@@ -68,7 +68,7 @@ extern class XdgBasedir `{ xdgHandle* `}
        fun data_dirs: Array[String] do return native_data_dirs.to_string_array
 
        private fun native_data_dirs: ConstPointer `{
-               return xdgDataDirectories(recv);
+               return xdgDataDirectories(self);
        `}
 
        # Preference-ordered set of base directories to search for data files
@@ -82,7 +82,7 @@ extern class XdgBasedir `{ xdgHandle* `}
        end
 
        private fun native_searchable_data_dirs: ConstPointer `{
-               return xdgSearchableDataDirectories(recv);
+               return xdgSearchableDataDirectories(self);
        `}
 
        # Preference-ordered set of base directories to search for configuration
@@ -90,7 +90,7 @@ extern class XdgBasedir `{ xdgHandle* `}
        fun config_dirs: Array[String] do return native_config_dirs.to_string_array
 
        private fun native_config_dirs: ConstPointer `{
-               return xdgConfigDirectories(recv);
+               return xdgConfigDirectories(self);
        `}
 
        # Preference-ordered set of base directories to search for configuration
@@ -104,7 +104,7 @@ extern class XdgBasedir `{ xdgHandle* `}
        end
 
        private fun native_searchable_config_dirs: ConstPointer `{
-               return xdgSearchableConfigDirectories(recv);
+               return xdgSearchableConfigDirectories(self);
        `}
 end
 
@@ -112,7 +112,7 @@ private extern class ConstPointer `{ const void * `}
        # Convert a C `char **` to a Nit `Array[String]`
        fun to_string_array: Array[String]
        import Array[String], Array[String].add, NativeString.to_s `{
-               char **strings = (char**)recv;
+               char **strings = (char**)self;
 
                Array_of_String aos = new_Array_of_String();
                int p = 0;
index 8b8f9de..edf0a16 100644 (file)
@@ -107,11 +107,11 @@ redef class MExplicitCall
                if mproperty.is_init then
                        var recv_mtype = recv_mtype
                        recv_var = nitni_visitor.init_instance_or_extern(recv_mtype)
-                       nitni_visitor.add("{mtype.ctype} recv /* var self: {mtype} */;")
-                       nitni_visitor.add("recv = {recv_var};")
+                       nitni_visitor.add("{mtype.ctype} self /* var self: {mtype} */;")
+                       nitni_visitor.add("self = {recv_var};")
                else
                        mtype = mtype.anchor_to(v.compiler.mainmodule, recv_mtype)
-                       recv_var = nitni_visitor.var_from_c("recv", mtype)
+                       recv_var = nitni_visitor.var_from_c("self", mtype)
                        recv_var = nitni_visitor.box_extern(recv_var, mtype)
                end
 
@@ -226,7 +226,7 @@ redef class MExplicitSuper
 
                var vars = new Array[RuntimeVariable]
 
-               var recv_var = nitni_visitor.var_from_c("recv", mclass_type)
+               var recv_var = nitni_visitor.var_from_c("self", mclass_type)
                recv_var = nitni_visitor.box_extern(recv_var, mclass_type)
                vars.add(recv_var)
 
index 6cd6083..8f0467d 100644 (file)
@@ -27,16 +27,26 @@ import model_ext
 # It is a placeholder to share data between each phase.
 class DocModel
 
-       # `DocPage` composing the documentation.
+       # `DocPage` composing the documentation associated to their ids.
        #
        # This is where `DocPhase` store and access pages to produce documentation.
-       var pages = new Array[DocPage]
+       #
+       # See `add_page`.
+       var pages: Map[String, DocPage] = new HashMap[String, DocPage]
 
        # Nit `Model` from which we extract the documentation.
        var model: Model is writable
 
        # The entry point of the `model`.
        var mainmodule: MModule is writable
+
+       # Add a `page` to this documentation.
+       fun add_page(page: DocPage) do
+               if pages.has_key(page.id) then
+                       print "Warning: multiple page with the same id `{page.id}`"
+               end
+               pages[page.id] = page
+       end
 end
 
 # A documentation page abstraction.
@@ -45,6 +55,17 @@ end
 # the page.
 class DocPage
 
+       # Page uniq id.
+       #
+       # The `id` is used as name for the generated file corresponding to the page
+       # (if any).
+       # Because multiple pages can be generated in the same directory it should be
+       # uniq.
+       #
+       # The `id` can also be used to establish links between pages (HTML links,
+       # HTML anchors, vim links, etc.).
+       var id: String is writable
+
        # Title of this page.
        var title: String is writable
 
@@ -229,10 +250,30 @@ class PropertyGroup[E: MProperty]
 end
 
 redef class MEntity
+       # ID used as a unique ID and in file names.
+       #
+       # **Must** match the following (POSIX ERE) regular expression:
+       #
+       # ~~~POSIX ERE
+       # ^[A-Za-z_][A-Za-z0-9._-]*$
+       # ~~~
+       #
+       # That way, the ID is always a valid URI component and a valid XML name.
+       fun nitdoc_id: String do return full_name.to_cmangle
+
        # Name displayed in console for debug and tests.
        fun nitdoc_name: String do return name.html_escape
 end
 
+redef class MModule
+
+       # Avoid id conflict with group
+       redef fun nitdoc_id do
+               if mgroup == null then return super
+               return "{mgroup.full_name}::{full_name}".to_cmangle
+       end
+end
+
 redef class MClassDef
        redef fun nitdoc_name do return mclass.nitdoc_name
 end
index d1ada76..cca6346 100644 (file)
@@ -23,7 +23,7 @@ class ConcernsPhase
 
        # Populates the given DocModel.
        redef fun apply do
-               for page in doc.pages do page.build_concerns(doc)
+               for page in doc.pages.values do page.build_concerns(doc)
        end
 end
 
index dbd1d39..f927fd9 100644 (file)
@@ -19,6 +19,7 @@
 module doc_console
 
 import semantize
+import doc_extract
 import doc::console_templates
 
 # Nitx handles console I/O.
@@ -138,7 +139,7 @@ interface NitxQuery
 
        # Pretty prints the results for the console.
        fun make_results(nitx: Nitx, results: Array[NitxMatch]): DocPage do
-               var page = new DocPage("Results")
+               var page = new DocPage("results", "Results")
                page.root.add_child(new QueryResultArticle(self, results))
                return page
        end
@@ -203,7 +204,7 @@ class CommentQuery
        redef fun perform(nitx, doc) do
                var name = args.first
                var res = new Array[NitxMatch]
-               for mentity in doc.search_mentities(name) do
+               for mentity in doc.mentities_by_name(name) do
                        res.add new MEntityMatch(self, mentity)
                end
                return res
@@ -214,7 +215,7 @@ class CommentQuery
                if len == 1 then
                        var res = results.first.as(MEntityMatch)
                        var mentity = res.mentity
-                       var page = new DocPage("Results")
+                       var page = new DocPage("resultats", "Results")
                        var article = new DefinitionArticle(mentity)
                        article.cs_title = mentity.name
                        article.cs_subtitle = mentity.cs_declaration
@@ -317,7 +318,7 @@ class DocQuery
        redef fun perform(nitx, doc) do
                var res = new Array[NitxMatch]
                var name = args.first
-               for page in doc.pages do
+               for page in doc.pages.values do
                        if name == "*" then # FIXME dev only
                                res.add new PageMatch(self, page)
                        else if page.title == name then
@@ -377,7 +378,7 @@ class CodeQuery
                        return res
                end
                # else, lookup the model by name
-               for mentity in doc.search_mentities(name) do
+               for mentity in doc.mentities_by_name(name) do
                        if mentity isa MClass then continue
                        if mentity isa MProperty then continue
                        res.add new CodeMatch(self, mentity.cs_location, mentity.cs_source_code)
@@ -386,7 +387,7 @@ class CodeQuery
        end
 
        redef fun make_results(nitx, results) do
-               var page = new DocPage("Code Results")
+               var page = new DocPage("results", "Code Results")
                for res in results do
                        page.add new CodeQueryArticle(self, res.as(CodeMatch))
                end
@@ -435,32 +436,6 @@ end
 
 ## exploration
 
-redef class DocModel
-
-       # Lists all MEntities in the model.
-       private var mentities: Collection[MEntity] is lazy do
-               var res = new HashSet[MEntity]
-               res.add_all mprojects
-               res.add_all mgroups
-               res.add_all mmodules
-               res.add_all mclasses
-               res.add_all mclassdefs
-               res.add_all mproperties
-               res.add_all mpropdefs
-               return res
-       end
-
-       # Search MEntities that match `name` by their name or namespace.
-       private fun search_mentities(name: String): Array[MEntity] do
-               var res = new Array[MEntity]
-               for mentity in mentities do
-                       if mentity.name != name and mentity.cs_namespace != name then continue
-                       res.add mentity
-               end
-               return res
-       end
-end
-
 # Visitor looking for initialized `MType` (new T).
 #
 # See `NewQuery`.
index 53adeac..456d545 100644 (file)
@@ -146,4 +146,78 @@ redef class DocModel
                        end
                end
        end
+
+       # Lists all MEntities in the model.
+       #
+       # FIXME invalidate cache if `self` is modified.
+       var mentities: Collection[MEntity] is lazy do
+               var res = new HashSet[MEntity]
+               res.add_all mprojects
+               res.add_all mgroups
+               res.add_all mmodules
+               res.add_all mclasses
+               res.add_all mclassdefs
+               res.add_all mproperties
+               res.add_all mpropdefs
+               return res
+       end
+
+       # Searches MEntities that match `name`.
+       fun mentities_by_name(name: String): Array[MEntity] do
+               var res = new Array[MEntity]
+               for mentity in mentities do
+                       if mentity.name != name then continue
+                       res.add mentity
+               end
+               return res
+       end
+
+       # Looks up a MEntity by its `namespace`.
+       #
+       # Usefull when `mentities_by_name` by return conflicts.
+       #
+       # Path can be the shortest possible to disambiguise like `Class::property`.
+       # In case of larger conflicts, a more complex namespace can be given like
+       # `project::module::Class::prop`.
+       fun mentities_by_namespace(namespace: String): Array[MEntity] do
+               var res = new Array[MEntity]
+               for mentity in mentities do
+                       mentity.mentities_by_namespace(namespace, res)
+               end
+               return res
+       end
+end
+
+redef class MEntity
+       # Looks up a MEntity by its `namespace` from `self`.
+       private fun mentities_by_namespace(namespace: String, res: Array[MEntity]) do end
+
+       private fun lookup_in(mentities: Collection[MEntity], namespace: String, res: Array[MEntity]) do
+               var parts = namespace.split_once_on("::")
+               var name = parts.shift
+               for mentity in mentities do
+                       if mentity.name != name then continue
+                       if parts.is_empty then
+                               res.add mentity
+                       else
+                               mentity.mentities_by_namespace(parts.first, res)
+                       end
+               end
+       end
+end
+
+redef class MProject
+       redef fun mentities_by_namespace(namespace, res) do lookup_in(mgroups, namespace, res)
+end
+
+redef class MGroup
+       redef fun mentities_by_namespace(namespace, res) do lookup_in(mmodules, namespace, res)
+end
+
+redef class MModule
+       redef fun mentities_by_namespace(namespace, res) do lookup_in(mclassdefs, namespace, res)
+end
+
+redef class MClassDef
+       redef fun mentities_by_namespace(namespace, res) do lookup_in(mpropdefs, namespace, res)
 end
index 07b7c99..1339d09 100644 (file)
@@ -36,7 +36,7 @@ class GraphPhase
 
        redef fun apply do
                if ctx.opt_nodot.value then return
-               for page in doc.pages do
+               for page in doc.pages.values do
                        var article = page.build_graph(self, doc)
                        if article == null then continue
                        # FIXME avoid diff
index 5bfbfb1..eecc95b 100644 (file)
@@ -26,7 +26,7 @@ class InheritanceListsPhase
        var name_sorter = new MEntityNameSorter
 
        redef fun apply do
-               for page in doc.pages do
+               for page in doc.pages.values do
                        if page isa MEntityPage then page.build_inh_list(self, doc)
                end
        end
index 156a650..0c843bb 100644 (file)
@@ -104,7 +104,7 @@ class RenderHTMLPhase
 
        redef fun apply do
                init_output_dir
-               for page in doc.pages do
+               for page in doc.pages.values do
                        page.render(self, doc).write_to_file("{ctx.output_dir.to_s}/{page.html_url}")
                end
        end
@@ -187,7 +187,7 @@ redef class DocPage
        # all properties below are roughly copied from `doc_pages`
 
        # Build page title string
-       fun init_title(v: RenderHTMLPhase, doc: DocModel) is abstract
+       fun init_title(v: RenderHTMLPhase, doc: DocModel) do end
 
        # Build top menu template if any.
        fun init_topmenu(v: RenderHTMLPhase, doc: DocModel) do
index 54f7c18..5ed6f78 100644 (file)
@@ -24,7 +24,7 @@ class IntroRedefListPhase
        super DocPhase
 
        redef fun apply do
-               for page in doc.pages do
+               for page in doc.pages.values do
                        if not page isa MEntityPage then continue
                        page.root.build_intro_redef_list(self, doc, page)
                end
index eda76ba..c36756c 100644 (file)
@@ -25,7 +25,7 @@ class LinListPhase
        private var lin_sorter = new MEntityNameSorter
 
        redef fun apply do
-               for page in doc.pages do page.apply_linearization(self, doc)
+               for page in doc.pages.values do page.apply_linearization(self, doc)
        end
 end
 
index e468cb6..3f83001 100644 (file)
@@ -23,19 +23,19 @@ class MakePagePhase
 
        # Instanciates documentation pages for the given DocModel.
        redef fun apply do
-               doc.pages.add new OverviewPage("Overview")
-               doc.pages.add new SearchPage("Index")
+               doc.add_page new OverviewPage("overview", "Overview")
+               doc.add_page new SearchPage("search", "Index")
                for mgroup in doc.mgroups do
-                       doc.pages.add new MGroupPage(mgroup.nitdoc_name, mgroup)
+                       doc.add_page new MGroupPage(mgroup)
                end
                for mmodule in doc.mmodules do
-                       doc.pages.add new MModulePage(mmodule.nitdoc_name, mmodule)
+                       doc.add_page new MModulePage(mmodule)
                end
                for mclass in doc.mclasses do
-                       doc.pages.add new MClassPage(mclass.nitdoc_name, mclass)
+                       doc.add_page new MClassPage(mclass)
                end
                for mproperty in doc.mproperties do
-                       doc.pages.add new MPropertyPage(mproperty.nitdoc_name, mproperty)
+                       doc.add_page new MPropertyPage(mproperty)
                end
        end
 end
@@ -52,6 +52,7 @@ end
 
 # A DocPage documenting a MEntity.
 class MEntityPage
+       autoinit mentity
        super DocPage
 
        # Type of MEntity documented by this page.
@@ -59,6 +60,9 @@ class MEntityPage
 
        # MEntity documented by this page.
        var mentity: MENTITY
+
+       redef var id is lazy do return mentity.nitdoc_id
+       redef var title is lazy do return mentity.nitdoc_name
 end
 
 # A documentation page about a MGroup.
index fd38e0f..0c610d4 100644 (file)
@@ -23,7 +23,7 @@ class POSetPhase
 
        # Populates the given DocModel.
        redef fun apply do
-               for page in doc.pages do
+               for page in doc.pages.values do
                        if page isa MEntityPage then page.build_poset(self, doc)
                end
        end
index 507a0a4..7491e4b 100644 (file)
@@ -33,7 +33,7 @@ class StructurePhase
 
        # Populates the given DocModel.
        redef fun apply do
-               for page in doc.pages do page.apply_structure(self, doc)
+               for page in doc.pages.values do page.apply_structure(self, doc)
        end
 end
 
index cd6974c..bc8ccbe 100644 (file)
@@ -22,17 +22,6 @@ import html::bootstrap
 import ordered_tree
 
 redef class MEntity
-       # ID used as a HTML unique ID and in file names.
-       #
-       # **Must** match the following (POSIX ERE) regular expression:
-       #
-       # ~~~POSIX ERE
-       # ^[A-Za-z_][A-Za-z0-9._-]*$
-       # ~~~
-       #
-       # That way, the ID is always a valid URI component and a valid XML name.
-       fun nitdoc_id: String is abstract
-
        # URL of this entity’s Nitdoc page.
        fun nitdoc_url: String is abstract
 
index ba6c2e0..7a5dec0 100644 (file)
@@ -85,7 +85,7 @@ class CPPLanguage
                # Will convert C arguments to C++ and call the C++ implementation function.
                fc = new CFunction(indirection_sig)
                if not mproperty.is_init then
-                       var param_name = "recv"
+                       var param_name = "self"
                        var type_name = to_cpp_call_context.name_mtype(mclass_type)
                        if mclass_type.mclass.ftype isa ForeignCppType then
                                fc.exprs.add("{type_name} {param_name}_for_cpp = static_cast<{type_name}>({param_name});\n")
index ae37d9d..41c9c26 100644 (file)
@@ -105,7 +105,7 @@ class JavaLanguage
                        jni_signature_alt = mclass_type.jni_signature_alt
                        return_type = mclass_type
                else
-                       params.add "recv"
+                       params.add "self"
                        if signature.return_mtype != null then
                                var ret_mtype = signature.return_mtype
                                ret_mtype = ret_mtype.resolve_for(mclass_type, mclass_type, mmodule, true)
@@ -637,7 +637,7 @@ redef class MMethod
                cparams.add "jclass clazz"
 
                if not self.is_init then
-                       cparams.add "{call_context.name_mtype(recv_mtype)} recv"
+                       cparams.add "{call_context.name_mtype(recv_mtype)} self"
                end
                for p in signature.mparameters do
                        var param_mtype = p.mtype.resolve_for(recv_mtype, recv_mtype, from_mmodule, true)
index 0d0e51a..f1cce80 100644 (file)
@@ -299,25 +299,19 @@ redef class ModelBuilder
                                        abort
                                end
                        end
-               else if noautoinit != null then
-                       if initializers.is_empty then
-                               warning(noautoinit, "useless-noautoinit", "Warning: the list of autoinit is already empty.")
-                       end
-                       # Just clear initializers
-                       mparameters.clear
-                       initializers.clear
                else
                        # Search the longest-one and checks for conflict
                        var longest = spropdefs.first
                        if spropdefs.length > 1 then
-                               # Check for conflict in the order of initializers
-                               # Each initializer list must me a prefix of the longest list
                                # part 1. find the longest list
                                for spd in spropdefs do
                                        if spd.initializers.length > longest.initializers.length then longest = spd
                                end
                                # part 2. compare
-                               for spd in spropdefs do
+                               # Check for conflict in the order of initializers
+                               # Each initializer list must me a prefix of the longest list
+                               # If `noautoinit` is set, just ignore conflicts
+                               if noautoinit == null then for spd in spropdefs do
                                        var i = 0
                                        for p in spd.initializers do
                                                if p != longest.initializers[i] then
@@ -330,17 +324,27 @@ redef class ModelBuilder
                                end
                        end
 
-                       # Can we just inherit?
-                       if spropdefs.length == 1 and mparameters.is_empty and defined_init == null then
-                               self.toolcontext.info("{mclassdef} inherits the basic constructor {longest}", 3)
-                               mclassdef.mclass.root_init = longest
-                               return
-                       end
+                       if noautoinit != null then
+                               # If there is local or inherited initializers, then complain.
+                               if initializers.is_empty and longest.initializers.is_empty then
+                                       warning(noautoinit, "useless-noautoinit", "Warning: the list of autoinit is already empty.")
+                               end
+                               # Just clear initializers
+                               mparameters.clear
+                               initializers.clear
+                       else
+                               # Can we just inherit?
+                               if spropdefs.length == 1 and mparameters.is_empty and defined_init == null then
+                                       self.toolcontext.info("{mclassdef} inherits the basic constructor {longest}", 3)
+                                       mclassdef.mclass.root_init = longest
+                                       return
+                               end
 
-                       # Combine the inherited list to what is collected
-                       if longest.initializers.length > 0 then
-                               mparameters.prepend longest.new_msignature.mparameters
-                               initializers.prepend longest.initializers
+                               # Combine the inherited list to what is collected
+                               if longest.initializers.length > 0 then
+                                       mparameters.prepend longest.new_msignature.mparameters
+                                       initializers.prepend longest.initializers
+                               end
                        end
                end
 
@@ -656,6 +660,8 @@ redef class APropdef
                return true
        end
 
+       # Checks for useless type in redef signatures.
+       private fun check_repeated_types(modelbuilder: ModelBuilder) do end
 end
 
 redef class ASignature
@@ -1051,6 +1057,28 @@ redef class AMethPropdef
                        var nt = nsig.n_type
                        if nt != null then modelbuilder.check_visibility(nt, nt.mtype.as(not null), mpropdef)
                end
+               check_repeated_types(modelbuilder)
+       end
+
+       # For parameters, type is always useless in a redef.
+       # For return type, type is useless if not covariant with introduction.
+       redef fun check_repeated_types(modelbuilder) do
+               if mpropdef.is_intro or n_signature == null then return
+               # check params
+               for param in n_signature.n_params do
+                       if param.n_type != null then
+                               modelbuilder.advice(param.n_type, "useless-signature", "Warning: useless type repetition on parameter `{param.n_id.text}` for redefined method `{mpropdef.name}`")
+                       end
+               end
+               # get intro
+               var intro = mpropdef.mproperty.intro
+               var n_intro = modelbuilder.mpropdef2npropdef.get_or_null(intro)
+               if n_intro == null or not n_intro isa AMethPropdef then return
+               # check return type
+               var ret_type = n_signature.ret_type
+               if ret_type != null and ret_type == n_intro.n_signature.ret_type then
+                       modelbuilder.advice(n_signature.n_type, "useless-signature", "Warning: useless return type repetition for redefined method `{mpropdef.name}`")
+               end
        end
 end
 
@@ -1346,6 +1374,7 @@ redef class AAttrPropdef
                if mlazypropdef != null then
                        mlazypropdef.static_mtype = modelbuilder.model.get_mclasses_by_name("Bool").first.mclass_type
                end
+               check_repeated_types(modelbuilder)
        end
 
        redef fun check_signature(modelbuilder)
@@ -1450,6 +1479,25 @@ redef class AAttrPropdef
                        end
                end
        end
+
+       # Type is useless if the attribute type is the same thant the intro.
+       redef fun check_repeated_types(modelbuilder) do
+               if mreadpropdef.is_intro or n_type == null then return
+               # get intro
+               var intro = mreadpropdef.mproperty.intro
+               var n_intro = modelbuilder.mpropdef2npropdef.get_or_null(intro)
+               if n_intro == null then return
+               # get intro type
+               var ntype = null
+               if n_intro isa AMethPropdef then
+                       ntype = n_intro.n_signature.ret_type
+               else if n_intro isa AAttrPropdef and n_intro.n_type != null then
+                       ntype = n_intro.n_type.mtype
+               end
+               # check
+               if ntype ==null or ntype != n_type.mtype then return
+               modelbuilder.advice(n_type, "useless-signature", "Warning: useless type repetition on redefined attribute `{mpropdef.name}`")
+       end
 end
 
 redef class ATypePropdef
index 631421a..7de8053 100644 (file)
@@ -72,7 +72,7 @@ redef class MMethod
 
                var cparams = new List[String]
                if not self.is_init then
-                       cparams.add( "{call_context.name_mtype(recv_mtype)} recv" )
+                       cparams.add( "{call_context.name_mtype(recv_mtype)} self" )
                end
                for p in signature.mparameters do
                        var param_mtype = p.mtype.resolve_for(recv_mtype, recv_mtype, from_mmodule, true)
@@ -110,7 +110,7 @@ redef class MMethod
 
                var cparams = new List[String]
                if not self.is_init then
-                       cparams.add(call_context.cast_to(recv_mtype, "recv{param_suffix}"))
+                       cparams.add(call_context.cast_to(recv_mtype, "self{param_suffix}"))
                end
 
                for p in signature.mparameters do
index 44cab72..4d00945 100644 (file)
@@ -49,7 +49,7 @@ var model = new Model
 # A model builder to parse files
 var modelbuilder = new ModelBuilder(model, toolcontext)
 
-# Here we load an process all modules passed on the command line
+# Here we load and process all modules passed on the command line
 var mmodules = modelbuilder.parse_full(arguments)
 toolcontext.mmodules_to_check.add_all mmodules
 
index 9c3d516..7de400a 100644 (file)
@@ -105,9 +105,11 @@ class VirtualMachine super NaiveInterpreter
 
                assert sup isa MClassType
 
-               # `sub` and `sup` can be discovered inside a Generic type during the subtyping test
-               if not sup.mclass.loaded then create_class(sup.mclass)
-               if not sub.mclass.loaded then create_class(sub.mclass)
+               # and `sup` can be discovered inside a Generic type during the subtyping test
+               if not sub.mclass.loaded then load_class(sub.mclass)
+
+               # If the target of the test is not-loaded yet, the subtyping-test will be false
+               if not sup.mclass.abstract_loaded then return false
 
                # For now, always use perfect hashing for subtyping test
                var super_id = sup.mclass.vtable.id
@@ -159,7 +161,7 @@ class VirtualMachine super NaiveInterpreter
        # Redef init_instance to simulate the loading of a class
        redef fun init_instance(recv: Instance)
        do
-               if not recv.mtype.as(MClassType).mclass.loaded then create_class(recv.mtype.as(MClassType).mclass)
+               if not recv.mtype.as(MClassType).mclass.loaded then load_class(recv.mtype.as(MClassType).mclass)
 
                recv.vtable = recv.mtype.as(MClassType).mclass.vtable
 
@@ -172,7 +174,7 @@ class VirtualMachine super NaiveInterpreter
        # Associate a `PrimitiveInstance` to its `VTable`
        redef fun init_instance_primitive(recv: Instance)
        do
-               if not recv.mtype.as(MClassType).mclass.loaded then create_class(recv.mtype.as(MClassType).mclass)
+               if not recv.mtype.as(MClassType).mclass.loaded then load_class(recv.mtype.as(MClassType).mclass)
 
                recv.vtable = recv.mtype.as(MClassType).mclass.vtable
        end
@@ -192,8 +194,33 @@ class VirtualMachine super NaiveInterpreter
                return attributes;
        `}
 
-       # Creates the runtime structures for this class
-       fun create_class(mclass: MClass) do     mclass.make_vt(self)
+       # Load the class and create its runtime structures, this loading is explicit
+       fun load_class(mclass: MClass)
+       do
+               if mclass.loaded then return
+
+               # Recursively load superclasses
+               for parent in mclass.in_hierarchy(mainmodule).direct_greaters do load_class_indirect(parent)
+
+               if mclass.abstract_loaded then
+                       mclass.allocate_vtable(self)
+               else
+                       mclass.make_vt(self, true)
+               end
+       end
+
+       # This method is called to handle an implicitly loaded class,
+       # i.e. a superclass of an explicitly loaded class
+       # A class loaded implicitly will not be fully allocated
+       fun load_class_indirect(mclass: MClass)
+       do
+               # It the class was already implicitly loaded
+               if mclass.abstract_loaded then return
+
+               for parent in mclass.in_hierarchy(mainmodule).direct_greaters do load_class_indirect(parent)
+
+               mclass.make_vt(self, false)
+       end
 
        # Execute `mproperty` for a `args` (where `args[0]` is the receiver).
        redef fun send(mproperty: MMethod, args: Array[Instance]): nullable Instance
@@ -212,8 +239,9 @@ class VirtualMachine super NaiveInterpreter
        # returns the most specific local method in the class corresponding to `vtable`
        private fun method_dispatch(mproperty: MMethod, vtable: VTable, recv: Instance): MMethodDef
        do
-               if mproperty.intro_mclassdef.mclass.positions_methods[recv.mtype.as(MClassType).mclass] != -1 then
-                       return method_dispatch_sst(vtable.internal_vtable, mproperty.absolute_offset)
+               var position = recv.mtype.as(MClassType).mclass.get_position_methods(mproperty.intro_mclassdef.mclass)
+               if position > 0 then
+                       return method_dispatch_sst(vtable.internal_vtable, mproperty.offset + position)
                else
                        return method_dispatch_ph(vtable.internal_vtable, vtable.mask,
                                mproperty.intro_mclassdef.mclass.vtable.id, mproperty.offset)
@@ -254,10 +282,10 @@ class VirtualMachine super NaiveInterpreter
                assert recv isa MutableInstance
 
                var i: Instance
-
-               if mproperty.intro_mclassdef.mclass.positions_attributes[recv.mtype.as(MClassType).mclass] != -1 then
+               var position = recv.mtype.as(MClassType).mclass.get_position_attributes(mproperty.intro_mclassdef.mclass)
+               if position > 0 then
                        # if this attribute class has an unique position for this receiver, then use direct access
-                       i = read_attribute_sst(recv.internal_attributes, mproperty.absolute_offset)
+                       i = read_attribute_sst(recv.internal_attributes, position + mproperty.offset)
                else
                        # Otherwise, read the attribute value with perfect hashing
                        var id = mproperty.intro_mclassdef.mclass.vtable.id
@@ -312,9 +340,10 @@ class VirtualMachine super NaiveInterpreter
                assert recv isa MutableInstance
 
                # Replace the old value of mproperty in recv
-               if mproperty.intro_mclassdef.mclass.positions_attributes[recv.mtype.as(MClassType).mclass] != -1 then
+               var position = recv.mtype.as(MClassType).mclass.get_position_attributes(mproperty.intro_mclassdef.mclass)
+               if position > -1 then
                        # if this attribute class has an unique position for this receiver, then use direct access
-                       write_attribute_sst(recv.internal_attributes, mproperty.absolute_offset, value)
+                       write_attribute_sst(recv.internal_attributes, position + mproperty.offset, value)
                else
                        # Otherwise, use perfect hashing to replace the old value
                        var id = mproperty.intro_mclassdef.mclass.vtable.id
@@ -376,18 +405,35 @@ redef class MClass
        # True when the class is effectively loaded by the vm, false otherwise
        var loaded: Bool = false
 
+       # Indicate this class was partially loaded (it only has its identifier allocated)
+       var abstract_loaded: Bool = false
+
        # Color for Cohen subtyping test : the absolute position of the id
        # of this class in virtual tables
        var color: Int
 
-       # For each loaded subclass, keep the position of the group of attributes
-       # introduced by self class in the object
+       # For superclasses which have a non-invariant position, keep their position in attribute table
        var positions_attributes: HashMap[MClass, Int] = new HashMap[MClass, Int]
 
-       # For each loaded subclass, keep the position of the group of methods
-       # introduced by self class in the vtable
+       # For superclasses which have a non-invariant position, keep their position in virtual table
        var positions_methods: HashMap[MClass, Int] = new HashMap[MClass, Int]
 
+       # The position of the class' block in virtual table,
+       # the position is set to -1 when the invariant position is no longer satisfied
+       var position_attributes: Int
+
+       # The position of the class' block in attribute table
+       # the position is set to -1 when the invariant position is no longer satisfied
+       var position_methods: Int
+
+       # The chosen prefix for this class.
+       # The prefix is the direct superclass which has the most properties,
+       # this class will stay at its usual position in virtual table and attribute table
+       var prefix: nullable MClass
+
+       # The linear extension of all superclasses with the prefix rule
+       var ordering: Array[MClass]
+
        # The `MAttribute` this class introduced
        var intro_mattributes = new Array[MAttribute]
 
@@ -401,15 +447,14 @@ redef class MClass
        var mmethods = new Array[MMethod]
 
        # Allocates a VTable for this class and gives it an id
-       private fun make_vt(v: VirtualMachine)
+       # * `vm` The currently executed VirtualMachine
+       # * `explicit` Indicate if this class was directly instantiated (i.e. not indirectly loaded)
+       private fun make_vt(vm: VirtualMachine, explicit: Bool)
        do
-               if loaded then return
+               # `ordering` contains the order of superclasses for virtual tables
+               ordering = superclasses_ordering(vm)
+               ordering.remove(self)
 
-               # `superclasses` contains the order of superclasses for virtual tables
-               var superclasses = superclasses_ordering(v)
-               superclasses.remove(self)
-
-               # Make_vt for super-classes
                var ids = new Array[Int]
                var nb_methods = new Array[Int]
                var nb_attributes = new Array[Int]
@@ -422,11 +467,10 @@ redef class MClass
                # and the second and third are respectively class id and delta
                var offset_methods = 3
 
-               # The previous element in `superclasses`
-               var previous_parent: nullable MClass = null
-               if superclasses.length > 0 then previous_parent = superclasses[0]
-               for parent in superclasses do
-                       if not parent.loaded then parent.make_vt(v)
+               var parent
+               var prefix_index = ordering.index_of(prefix.as(not null))
+               for i in [0..ordering.length[ do
+                       parent = ordering[i]
 
                        # Get the number of introduced methods and attributes for this class
                        var methods = parent.intro_mmethods.length
@@ -440,63 +484,80 @@ redef class MClass
                        nb_methods.push(methods)
                        nb_attributes.push(attributes)
 
-                       # Update `positions_attributes` and `positions_methods` in `parent`.
-                       # If the position is invariant for this parent, store this position
-                       # else store a special value (-1)
-                       var pos_attr = -1
-                       var pos_meth = -1
-
-                       if previous_parent.as(not null).positions_attributes[parent] == offset_attributes then pos_attr = offset_attributes
-                       if previous_parent.as(not null).positions_methods[parent] == offset_methods then pos_meth = offset_methods
-
-                       parent.update_positions(pos_attr, pos_meth, self)
+                       # If the class is in the suffix part of the order
+                       if i > prefix_index then
+                               moved_class_attributes(vm, ordering[i], offset_attributes)
+                               moved_class_methods(vm, ordering[i], offset_methods)
+                       end
 
                        offset_attributes += attributes
                        offset_methods += methods
                        offset_methods += 2 # Because each block starts with an id and the delta
                end
 
-               # When all super-classes have their identifiers and vtables, allocate current one
-               allocate_vtable(v, ids, nb_methods, nb_attributes, offset_attributes, offset_methods)
-               loaded = true
+               # Update the positions of the class
+               update_positions(offset_attributes, offset_methods)
 
-               # Set the absolute position of the identifier of this class in the virtual table
-               color = offset_methods - 2
+               ordering.add(self)
 
-               # The virtual table now needs to be filled with pointer to methods
-               superclasses.add(self)
-               for cl in superclasses do
-                       fill_vtable(v, vtable.as(not null), cl)
+               # Compute the identifier with Perfect Hashing
+               compute_identifier(vm, ids, offset_methods)
+
+               # Update caches and offsets of methods and attributes for this class
+               # If the loading was explicit, the virtual table will be allocated and filled
+               set_offsets(vm, explicit)
+
+               if not explicit then
+                       # Just init the C-pointer to NULL to avoid errors
+                       vtable.internal_vtable = vm.memory_manager.null_ptr
                end
        end
 
-       # Allocate a single vtable
-       # * `ids : Array of superclasses identifiers
-       # * `nb_methods : Array which contain the number of introduced methods for each class in ids
-       # * `nb_attributes : Array which contain the number of introduced attributes for each class in ids
-       # * `offset_attributes : Offset from the beginning of the table of the group of attributes
+       # Allocate a unique identifier to the class with perfect hashing
+       # * `vm` The currently executed VirtualMachine
+       # * `ids` Array of superclasses identifiers
        # * `offset_methods : Offset from the beginning of the table of the group of methods
-       private fun allocate_vtable(v: VirtualMachine, ids: Array[Int], nb_methods: Array[Int], nb_attributes: Array[Int],
-                       offset_attributes: Int, offset_methods: Int)
+       private fun compute_identifier(vm: VirtualMachine, ids: Array[Int], offset_methods: Int)
        do
                vtable = new VTable
                var idc = new Array[Int]
 
-               vtable.mask = v.ph.pnand(ids, 1, idc) - 1
+               # Give an identifier to the class and put it inside the virtual table
+               vtable.mask = vm.ph.pnand(ids, 1, idc) - 1
                vtable.id = idc[0]
                vtable.classname = name
 
-               # Add current id to Array of super-ids
-               var ids_total = new Array[Int]
-               ids_total.add_all(ids)
-               ids_total.push(vtable.id)
+               # Set the color for subtyping tests in SST of this class
+               color = offset_methods - 2
 
-               var nb_methods_total = new Array[Int]
-               var nb_attributes_total = new Array[Int]
+               # Indicate the class has its identifier computed
+               abstract_loaded = true
+       end
 
-               var self_methods = 0
-               var nb_introduced_attributes = 0
+       # Update the positions of this class
+       # * `offset_attributes` The offset of the block of attributes of this class
+       # * `offset_methods` The offset of the block of methods of this class
+       private fun update_positions(offset_attributes: Int, offset_methods: Int)
+       do
+               # Recopy the position tables of the prefix in `self`
+               for key, value in prefix.positions_methods do
+                       positions_methods[key] = value
+               end
 
+               for key, value in prefix.positions_attributes do
+                       positions_attributes[key] = value
+               end
+
+               # Save the offsets of self class
+               position_attributes = offset_attributes
+               position_methods = offset_methods
+       end
+
+       # Set the offsets for the properties introduced by `self` class
+       # * `vm` The currently executed VirtualMachine
+       # * `explicit` Indicate if this class was explicitly loaded
+       private fun set_offsets(vm: VirtualMachine, explicit: Bool)
+       do
                # Fixing offsets for self attributes and methods
                var relative_offset_attr = 0
                var relative_offset_meth = 0
@@ -508,17 +569,13 @@ redef class MClass
                        for p in classdef.intro_mproperties do
                                # Collect properties and fixing offsets
                                if p isa MMethod then
-                                       self_methods += 1
                                        p.offset = relative_offset_meth
-                                       p.absolute_offset = offset_methods + relative_offset_meth
                                        relative_offset_meth += 1
 
                                        intro_mmethods.add(p)
                                end
                                if p isa MAttribute then
-                                       nb_introduced_attributes += 1
                                        p.offset = relative_offset_attr
-                                       p.absolute_offset = offset_attributes + relative_offset_attr
                                        relative_offset_attr += 1
 
                                        intro_mattributes.add(p)
@@ -530,34 +587,50 @@ redef class MClass
                mattributes.add_all(intro_mattributes)
                mmethods.add_all(intro_mmethods)
 
-               nb_methods_total.add_all(nb_methods)
-               nb_methods_total.push(self_methods)
+               if explicit then allocate_vtable(vm)
+       end
 
-               nb_attributes_total.add_all(nb_attributes)
-               nb_attributes_total.push(nb_introduced_attributes)
+       # Allocate a single vtable
+       # * `vm` The currently executed VirtualMachine
+       private fun allocate_vtable(vm: VirtualMachine)
+       do
+               var ids = new Array[Int]
+               var nb_methods_total = new Array[Int]
+               var nb_attributes_total = new Array[Int]
 
-               # Save the offsets of self class
-               update_positions(offset_attributes, offset_methods, self)
+               for cl in ordering do
+                       ids.add(cl.vtable.id)
+                       nb_methods_total.add(cl.intro_mmethods.length)
+                       nb_attributes_total.add(cl.intro_mattributes.length)
+               end
 
-               # Since we have the number of attributes for each class, calculate the delta
+               # Calculate the delta to prepare object structure
                var deltas = calculate_delta(nb_attributes_total)
-               vtable.internal_vtable = v.memory_manager.init_vtable(ids_total, nb_methods_total, deltas, vtable.mask)
+               vtable.internal_vtable = vm.memory_manager.init_vtable(ids, nb_methods_total, deltas, vtable.mask)
+
+               # The virtual table now needs to be filled with pointer to methods
+               for cl in ordering do
+                       fill_vtable(vm, vtable.as(not null), cl)
+               end
+
+               loaded = true
        end
 
-       # Fill the vtable with methods of `self` class
-       # * `v` : Current instance of the VirtualMachine
-       # * `table` : the table of self class, will be filled with its methods
-       private fun fill_vtable(v:VirtualMachine, table: VTable, cl: MClass)
+       # Fill the vtable with local methods for `self` class
+       # * `vm` Current instance of the VirtualMachine
+       # * `table` the table of self class, will be filled with its methods
+       # * `cl` The class which introduced the methods
+       private fun fill_vtable(vm: VirtualMachine, table: VTable, cl: MClass)
        do
                var methods = new Array[MMethodDef]
                for m in cl.intro_mmethods do
                        # `propdef` is the most specific implementation for this MMethod
-                       var propdef = m.lookup_first_definition(v.mainmodule, self.intro.bound_mtype)
+                       var propdef = m.lookup_first_definition(vm.mainmodule, self.intro.bound_mtype)
                        methods.push(propdef)
                end
 
                # Call a method in C to put propdefs of self methods in the vtables
-               v.memory_manager.put_methods(vtable.internal_vtable, vtable.mask, cl.vtable.id, methods)
+               vm.memory_manager.put_methods(vtable.internal_vtable, vtable.mask, cl.vtable.id, methods)
        end
 
        # Computes delta for each class
@@ -594,6 +667,7 @@ redef class MClass
                        return ordering
                else
                        # There is no super-class, self is Object
+                       prefix = self
                        return superclasses
                end
        end
@@ -625,6 +699,8 @@ redef class MClass
                        end
 
                        if prefix != null then
+                               if self.prefix == null then self.prefix = prefix
+
                                # Add the prefix class ordering at the beginning of our sequence
                                var prefix_res = new Array[MClass]
                                prefix_res = prefix.dfs(v, prefix_res)
@@ -646,6 +722,8 @@ redef class MClass
                        res.push(self)
                else
                        if direct_parents.length > 0 then
+                               if prefix == null then prefix = direct_parents.first
+
                                res = direct_parents.first.dfs(v, res)
                        end
                end
@@ -655,31 +733,138 @@ redef class MClass
                return res
        end
 
-       # Update positions of the class `cl`
-       # * `attributes_offset`: absolute offset of introduced attributes
-       # * `methods_offset`: absolute offset of introduced methods
-       private fun update_positions(attributes_offsets: Int, methods_offset:Int, cl: MClass)
+       # This method is called when `current_class` class is moved in virtual table of `self`
+       # *`vm` Running instance of the virtual machine
+       # *`current_class` The class which was moved in `self` structures
+       # *`offset` The offset of block of methods of `current_class` in `self`
+       fun moved_class_methods(vm: VirtualMachine, current_class: MClass, offset: Int)
        do
-               positions_attributes[cl] = attributes_offsets
-               positions_methods[cl] = methods_offset
+               # `current_class` was moved in `self` method table
+               if current_class.position_methods > 0 then
+                       # The invariant position is no longer satisfied
+                       current_class.positions_methods[current_class] = current_class.position_methods
+                       current_class.position_methods = - current_class.position_methods
+               else
+                       # The class has already several positions and an update is needed
+                       current_class.positions_methods[current_class] = -current_class.positions_methods[current_class]
+
+                       for sub in ordering do
+                               if sub == current_class then continue
+
+                               var super_id = current_class.vtable.id
+                               var mask = sub.vtable.mask
+                               vm.load_class(sub)
+
+                               if vm.inter_is_subtype_ph(super_id, mask, sub.vtable.internal_vtable) then
+                                       if not sub.positions_methods.has_key(current_class) then
+                                               sub.positions_methods[current_class] = current_class.position_methods
+                                       else
+                                               var old_position = sub.positions_methods[current_class]
+                                               if old_position > 0 then
+                                                       # Indicate this class can not used anymore single inheritance implementation
+                                                       sub.positions_methods[current_class] = - old_position
+                                               end
+                                       end
+                               end
+                       end
+               end
+
+               # Save the position of `current_class` in `self`
+               positions_methods[current_class] = offset
        end
+
+       # This method is called when `current_class` class is moved in attribute table of `self`
+       # *`vm` Running instance of the virtual machine
+       # *`current_class` The class which was moved in `self` structures
+       # *`offset` The offset of block of attributes of `current_class` in `self`
+       fun moved_class_attributes(vm: VirtualMachine, current_class: MClass, offset: Int)
+       do
+               # `current_class` was moved in `self` attribute table
+               if not current_class.positions_attributes.has_key(current_class) then
+                       # The invariant position is no longer satisfied
+                       current_class.positions_attributes[current_class] = current_class.position_attributes
+                       current_class.position_attributes = - current_class.position_attributes
+               else
+                       # The class has already several positions and an update is needed
+                       current_class.positions_attributes[current_class] = - current_class.positions_attributes[current_class]
+
+                       for sub in ordering do
+                               if sub == current_class then continue
+
+                               var super_id = current_class.vtable.id
+                               var mask = sub.vtable.mask
+                               vm.load_class(sub)
+
+                               if vm.inter_is_subtype_ph(super_id, mask, sub.vtable.internal_vtable) then
+                                       if not sub.positions_methods.has_key(current_class) then
+                                               sub.positions_attributes[current_class] = current_class.position_attributes
+                                       else
+                                               var old_position = sub.positions_attributes[current_class]
+                                               if old_position > 0 then
+                                                       # Indicate this class can not used anymore single inheritance implementation
+                                                       sub.positions_attributes[current_class] = - old_position
+                                               end
+                                       end
+                               end
+                       end
+               end
+
+               # Save the position of `current_class` in `self`
+               positions_attributes[current_class] = offset
+       end
+
+       # Return the position of the method's block of class `cl` in `self` if `cl` has an invariant position in self,
+       # Otherwise return a negative position
+       fun get_position_methods(cl: MClass): Int
+       do
+               # The class has an invariant position in all subclasses
+               if cl.position_methods > 0 then return cl.position_methods
+
+               # The position has an invariant position for this class and its subclasses only
+               if positions_methods.has_key(cl) then
+                       var pos = positions_methods[cl]
+                       if pos > 0 then return pos
+                       return -1
+               end
+
+               # No invariant position at all, the caller must use a multiple inheritance implementation
+               return -1
+       end
+
+       # Return the position of the attribute's block of class `cl` in `self` if `cl` has an invariant position in self,
+       # Otherwise return a negative position
+       fun get_position_attributes(cl: MClass): Int
+       do
+               # The class has an invariant position in all subclasses
+               if cl.position_attributes > 0 then return cl.position_attributes
+
+               # The position has an invariant position for this class and its subclasses only
+               if positions_attributes.has_key(cl) then
+                       var pos = positions_attributes[cl]
+                       if pos > 0 then return pos
+                       return -1
+               end
+
+               # No invariant position at all, the caller must use a multiple inheritance implementation
+               return -1
+       end
+end
+
+redef class MProperty
+       # Relative offset of this in the runtime instance
+       # (beginning of the block of its introducing class for attributes or methods)
+       var offset: Int
 end
 
 redef class MAttribute
        # Relative offset of this attribute in the runtime instance
        # (beginning of the block of its introducing class)
-       var offset: Int
-
-       # Absolute offset of this attribute in the runtime instance (beginning of the attribute table)
-       var absolute_offset: Int
+       redef var offset: Int
 end
 
 redef class MMethod
        # Relative offset of this method in the virtual table (from the beginning of the block)
-       var offset: Int
-
-       # Absolute offset of this method in the virtual table (from the beginning of the vtable)
-       var absolute_offset: Int
+       redef var offset: Int
 end
 
 # Redef MutableInstance to improve implementation of attributes in objects
@@ -818,4 +1003,9 @@ class MemoryManager
                        MMethodDef_incr_ref(method);
                }
        `}
+
+       # Return a NULL pointer, used to initialize virtual tables
+       private fun null_ptr: Pointer `{
+               return NULL;
+       `}
 end
index 6f3c201..514d3d1 100644 (file)
@@ -66,6 +66,8 @@ redef class VirtualMachine
                                callsite.id, callsite.offset)
                end
 
+               #TODO : we need recompilations here
+               callsite.status = 0
                return self.call(propdef, args)
        end
 end
@@ -92,9 +94,10 @@ redef class AAttrFormExpr
        # * `recv` The receiver (The object) of the access
        protected fun optimize(mproperty: MAttribute, recv: MutableInstance)
        do
-               if mproperty.intro_mclassdef.mclass.positions_attributes[recv.mtype.as(MClassType).mclass] != -1 then
+               var position = recv.mtype.as(MClassType).mclass.get_position_attributes(mproperty.intro_mclassdef.mclass)
+               if position > 0 then
                        # if this attribute class has an unique position for this receiver, then use direct access
-                       offset = mproperty.absolute_offset
+                       offset = position + mproperty.offset
                        status = 1
                else
                        # Otherwise, perfect hashing must be used
@@ -134,6 +137,9 @@ redef class AAttrExpr
                        abort
                end
 
+               #TODO : we need recompilations here
+               status = 0
+
                return i
        end
 end
@@ -163,6 +169,9 @@ redef class AAttrAssignExpr
                        v.write_attribute_ph(recv.internal_attributes, recv.vtable.internal_vtable,
                                        recv.vtable.mask, id, offset, i)
                end
+
+               #TODO : we need recompilations here
+               status = 0
        end
 end
 
@@ -189,8 +198,9 @@ redef class CallSite
        # Otherwise we must use perfect hashing
        fun optimize(recv: Instance)
        do
-               if mproperty.intro_mclassdef.mclass.positions_methods[recv.mtype.as(MClassType).mclass] != -1 then
-                       offset = mproperty.absolute_offset
+               var position = recv.mtype.as(MClassType).mclass.get_position_methods(mproperty.intro_mclassdef.mclass)
+               if position > 0 then
+                       offset = position + mproperty.offset
                        status = 1
                else
                        offset = mproperty.offset
@@ -222,7 +232,7 @@ redef class AIsaExpr
                var recv = v.expr(self.n_expr)
                if recv == null then return null
 
-               if status == 0 then optimize(v, recv.mtype, self.cast_type.as(not null))
+               optimize(v, recv.mtype, self.cast_type.as(not null))
                var mtype = v.unanchor_type(self.cast_type.as(not null))
 
                # If this test can be optimized, directly call appropriate subtyping methods
@@ -248,20 +258,18 @@ redef class AIsaExpr
                        return
                end
 
-               if not target.mclass.loaded then return
+               if not target.mclass.abstract_loaded then return
 
-               # Try to get the position of the target type in source's structures
-               var value = source.mclass.positions_methods.get_or_null(target.mclass)
-
-               if value != null then
-                       if value != -1 then
-                               # Store informations for Cohen test
-                               position = target.mclass.color
-                               status = 1
-                       else
-                               # We use perfect hashing
-                               status = 2
-                       end
+               # If the value is positive, the target class has an invariant position in source's structures
+               var value = source.mclass.get_position_methods(target.mclass)
+
+               if value > 0 then
+                       # `value - 2` is the position of the target identifier in source vtable
+                       position = value - 2
+                       status = 1
+               else
+                       # We use perfect hashing
+                       status = 2
                end
                id = target.mclass.vtable.id
        end
@@ -289,7 +297,7 @@ redef class AAsCastExpr
                var recv = v.expr(self.n_expr)
                if recv == null then return null
 
-               if status == 0 then optimize(v, recv.mtype, self.mtype.as(not null))
+               optimize(v, recv.mtype, self.mtype.as(not null))
 
                var mtype = self.mtype.as(not null)
                var amtype = v.unanchor_type(mtype)
@@ -324,18 +332,16 @@ redef class AAsCastExpr
 
                if not target.mclass.loaded then return
 
-               # Try to get the position of the target type in source's structures
-               var value = source.mclass.positions_methods.get_or_null(target.mclass)
-
-               if value != null then
-                       if value != -1 then
-                               # Store informations for Cohen test
-                               position = target.mclass.color
-                               status = 1
-                       else
-                               # We use perfect hashing
-                               status = 2
-                       end
+               # If the value is positive, the target class has an invariant position in source's structures
+               var value = source.mclass.get_position_methods(target.mclass)
+
+               if value > 0 then
+                       # `value - 2` is the position of the target identifier in source vtable
+                       position = value - 2
+                       status = 1
+               else
+                       # We use perfect hashing
+                       status = 2
                end
                id = target.mclass.vtable.id
        end
index 37c2cb2..51cb465 100644 (file)
@@ -40,7 +40,7 @@ class E
        noautoinit #alt6#
        #alt6,7# autoinit
        super A
-       var a: A
+       var a: A #alt9#
 end
 
 class F
diff --git a/tests/nitpick.args b/tests/nitpick.args
new file mode 100644 (file)
index 0000000..3ae7a2a
--- /dev/null
@@ -0,0 +1 @@
+--no-color -W test_advice_repeated_types.nit
diff --git a/tests/sav/base_init_autoinit3_alt9.res b/tests/sav/base_init_autoinit3_alt9.res
new file mode 100644 (file)
index 0000000..6851c6d
--- /dev/null
@@ -0,0 +1,8 @@
+1
+2
+false
+3
+3.300000
+4
+true
+4.400000
diff --git a/tests/sav/nitpick_args1.res b/tests/sav/nitpick_args1.res
new file mode 100644 (file)
index 0000000..38f9166
--- /dev/null
@@ -0,0 +1,12 @@
+../lib/standard/bytes.nit:51,7--19: Documentation warning: Undocumented property `with_capacity`
+../lib/standard/bytes.nit:164,6--13: Documentation warning: Undocumented property `to_bytes`
+../lib/standard/stream.nit:425,6--17: Documentation warning: Undocumented property `buffer_reset`
+../lib/standard/file.nit:444,6--19: Documentation warning: Undocumented property `read_all_bytes`
+test_advice_repeated_types.nit:36,15--20: Warning: useless type repetition on redefined attribute `_a`
+test_advice_repeated_types.nit:37,18--20: Warning: useless type repetition on parameter `b1` for redefined method `b`
+test_advice_repeated_types.nit:38,18--20: Warning: useless type repetition on parameter `c1` for redefined method `c`
+test_advice_repeated_types.nit:38,27--29: Warning: useless type repetition on parameter `c2` for redefined method `c`
+test_advice_repeated_types.nit:39,15--20: Warning: useless return type repetition for redefined method `d`
+test_advice_repeated_types.nit:40,18--20: Warning: useless type repetition on parameter `e1` for redefined method `e`
+test_advice_repeated_types.nit:40,24--29: Warning: useless return type repetition for redefined method `e`
+test_advice_repeated_types.nit:49,18--20: Warning: useless type repetition on parameter `e1` for redefined method `e`
index b63845a..4c208ff 100644 (file)
@@ -53,7 +53,7 @@ private class A
                printf( "received msg: %s, of length = %d\n", c_msg, msg_len );
 
                /* A_my_attr is a callback to the getter of self.my_attr */
-               printf( "old attr %d\n", A_my_attr(recv) );
+               printf( "old attr %d\n", A_my_attr(self) );
 
                if(chose)
                        truc;
@@ -61,21 +61,21 @@ private class A
                        chose;
 
                /* A_my_attr is a callback to the setter of self.my_attr= */
-               A_my_attr__assign( recv, msg_len );
+               A_my_attr__assign( self, msg_len );
        `}
 end
 
 extern class TimeT `{time_t`}
        new `{ return time(NULL); `}
        new from_i(i: Int) `{ return i; `}
-       fun update `{ time(&recv); `}
+       fun update `{ time(&self); `}
 
        fun ctime: String import NativeString.to_s_with_copy `{
-               return NativeString_to_s_with_copy( ctime(&recv) );
+               return NativeString_to_s_with_copy( ctime(&self) );
        `}
 
        # Difference in secondes from start (self if the end time)
-       fun difftime(start: TimeT): Float `{ return difftime(recv, start); `}
+       fun difftime(start: TimeT): Float `{ return difftime(self, start); `}
 
        private fun intern_poll(in_fds: Array[Int], out_fds: Array[Int]): nullable Int is
                extern import Array[Int].length, Array[Int].[], Int.as(nullable Int) `{`}
@@ -83,4 +83,4 @@ end
 
 fun address_is_null: Bool is extern "address_is_null"
 
-fun free `{ free(recv); `}
+fun free `{ free(self); `}
index 415c33f..9a17fac 100644 (file)
@@ -53,7 +53,7 @@ private class A
                printf( "received msg: %s, of length = %d\n", c_msg, msg_len );
 
                /* A_my_attr is a callback to the getter of self.my_attr */
-               printf( "old attr %d\n", A_my_attr(recv) );
+               printf( "old attr %d\n", A_my_attr(self) );
 
                if(chose)
                        truc;
@@ -61,7 +61,7 @@ private class A
                        chose;
 
                /* A_my_attr is a callback to the setter of self.my_attr= */
-               A_my_attr__assign( recv, msg_len );
+               A_my_attr__assign( self, msg_len );
        `}
 end
 
@@ -69,14 +69,14 @@ extern class TimeT `{time_t`}
        new `{ return time(NULL); `}
        new from_i(i: Int) `{ return i; `}
 
-       fun update `{ time(&recv); `}
+       fun update `{ time(&self); `}
 
        fun ctime: String import NativeString.to_s_with_copy `{
-               return NativeString_to_s_with_copy( ctime(&recv) );
+               return NativeString_to_s_with_copy( ctime(&self) );
        `}
 
        # Difference in secondes from start (self if the end time)
-       fun difftime(start: TimeT): Float `{ return difftime(recv, start); `}
+       fun difftime(start: TimeT): Float `{ return difftime(self, start); `}
 
        private fun intern_poll(in_fds: Array[Int], out_fds: Array[Int]): nullable Int is
                extern import Array[Int].length, Array[Int].[], Int.as(nullable Int) `{`}
@@ -84,5 +84,5 @@ end
 
 fun address_is_null: Bool is extern "address_is_null"
 
-fun free `{ free(recv); `}
+fun free `{ free(self); `}
 
index 7a38c28..b69dc33 100644 (file)
@@ -13,9 +13,6 @@ redef class Deserializer
                if name == "Array[nullable Object]" then return new Array[nullable Object].from_deserializer(self)
                if name == "Array[Serializable]" then return new Array[Serializable].from_deserializer(self)
                if name == "Array[String]" then return new Array[String].from_deserializer(self)
-               if name == "HashMap[Serializable, Array[Couple[Serializable, Int]]]" then return new HashMap[Serializable, Array[Couple[Serializable, Int]]].from_deserializer(self)
-               if name == "Array[Couple[Serializable, Int]]" then return new Array[Couple[Serializable, Int]].from_deserializer(self)
-               if name == "Couple[Serializable, Int]" then return new Couple[Serializable, Int].from_deserializer(self)
                return super
        end
 end
index 43e3636..209563a 100644 (file)
@@ -1,4 +1,4 @@
-Runtime error: Cast failed. Expected `E`, got `Bool` (../lib/standard/collection/array.nit:960)
+Runtime error: Cast failed. Expected `E`, got `Bool` (../lib/standard/collection/array.nit:957)
 NativeString
 N
 Nit
diff --git a/tests/sav/utf_noindex_test.res b/tests/sav/utf_noindex_test.res
deleted file mode 100644 (file)
index b5e3e16..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-28
-ハaロЖー𐍃aδΈ–η•Œ α“€ . α“‚ A,𐍆 aζ—₯本Aθͺžaです
-ハaロЖー𐍃aδΈ–η•Œ α“€ . α“‚ A,𐍆 aζ—₯本Aθͺžaです
-すでaθͺžA本ζ—₯a π†,A α“‚ . α“€ η•ŒδΈ–a𐍃ーЖロaハ
-ー𐍃aδΈ–
-δΈ–a𐍃ー
-δΈ–a𐍃ー
-ー𐍃aδΈ–
-すでaθͺžA本ζ—₯a π†,A α“‚ . α“€ η•ŒδΈ–a𐍃ーЖロaハ
-ハaロЖー𐍃aδΈ–η•Œ α“€ . α“‚ A,𐍆 aζ—₯本Aθͺžaです
-ハAロЖー𐍃AδΈ–η•Œ α“€ . α“‚ A,𐍆 Aζ—₯本AθͺžAです
-ハaロЖー𐍃aδΈ–η•Œ α“€ . α“‚ a,𐍆 aζ—₯本aθͺžaです
-aハロЖー𐍃aδΈ–η•Œ α“€ . α“‚ A,𐍆 aζ—₯本Aθͺžaです
-aハロЖー𐍃aδΈ–η•Œ α“€ . α“‚ a,𐍆 aζ—₯本aθͺžaです
-AハロЖー𐍃AδΈ–η•Œ α“€ . α“‚ A,𐍆 Aζ—₯本AθͺžAです
-すでAθͺžA本ζ—₯A π†,A α“‚ . α“€ η•ŒδΈ–A𐍃ーЖロハA
index 427d28c..a94d2f0 100644 (file)
@@ -29,10 +29,10 @@ class StringTest
                char* string = "This is a test string";
 
                FlatString ref_string = NativeString_to_s(string);
-               StringTest_ref_test(recv, ref_string);
+               StringTest_ref_test(self, ref_string);
 
                FlatString copy_string = NativeString_to_s_with_copy(string);
-               StringTest_copy_test(recv, copy_string);
+               StringTest_copy_test(self, copy_string);
 
                int same_refs = FlatString_items(copy_string) == FlatString_items(ref_string);
 
diff --git a/tests/test_advice_repeated_types.nit b/tests/test_advice_repeated_types.nit
new file mode 100644 (file)
index 0000000..21f1a04
--- /dev/null
@@ -0,0 +1,56 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+class A
+       var a: Object
+       fun b(b1: Int) is abstract
+       fun c(c1: Int, c2: Int) is abstract
+       fun d: Object is abstract
+       fun e(e1: Int): Object is abstract
+end
+
+class B
+       super A
+
+       redef var a
+       redef fun b(b1) do end
+       redef fun c(c1, c2) do end
+       redef fun d do return ""
+       redef fun e(e1) do return ""
+end
+
+class C
+       super A
+
+       redef var a: Object
+       redef fun b(b1: Int) do end
+       redef fun c(c1: Int, c2: Int) do end
+       redef fun d: Object do return ""
+       redef fun e(e1: Int): Object do return ""
+end
+
+class D
+       super A
+
+       redef fun b(b1) do end
+       redef fun c(c1, c2) do end
+       redef fun d: Int do return 1
+       redef fun e(e1: Int): Numeric do return 1
+end
+
+class E
+       super A
+
+       redef var d: Int = 1
+end
index 79cdb5b..1b8bc03 100644 (file)
@@ -99,7 +99,7 @@ assert infoResp:info != null
 info = curl.easy_getinfo_long(new CURLInfoLong.rtsp_server_cseq)
 assert infoResp:info != null
 
-info = curl.easy_getinfo_long(new CURLInfoLong.rtsp_cseq_recv)
+info = curl.easy_getinfo_long(new CURLInfoLong.rtsp_cseq_self)
 assert infoResp:info != null
 
 # Double
index ad76c0a..71634fd 100644 (file)
@@ -21,12 +21,12 @@ class A
 
        fun print_all import String.to_cstring, r, rw `{
                printf( "%s %s\n",
-                       String_to_cstring( A_r( recv ) ),
-                       String_to_cstring( A_rw( recv ) ) );
+                       String_to_cstring( A_r( self ) ),
+                       String_to_cstring( A_rw( self ) ) );
        `}
        fun modify import NativeString.to_s, w=, rw= `{
-               A_w__assign( recv, NativeString_to_s( "w set from native" ) );
-               A_rw__assign( recv, NativeString_to_s( "rw set from native" ) );
+               A_w__assign( self, NativeString_to_s( "w set from native" ) );
+               A_rw__assign( self, NativeString_to_s( "rw set from native" ) );
        `}
 end
 
index 3fe526c..7e05520 100644 (file)
@@ -33,7 +33,7 @@ extern class Test
         int i;
         for(i = 0; i < 2000; ++i) {
             printf("%d\n", i);
-            Test_foo(recv, NativeString_to_s("asdf"));
+            Test_foo(self, NativeString_to_s("asdf"));
         }
     `}
 
index 5445bbf..f84ac24 100644 (file)
@@ -21,7 +21,7 @@ end
 fun foo do print "foo"
 
 fun call_a_fun import foo `{
-       Sys_foo(recv);
+       Sys_foo(self);
 `}
 
 fun call_a_constructor import A, A.bar `{
index db8c50b..1554719 100644 (file)
@@ -21,18 +21,18 @@ class FibonacciEngine
                if ( n == 1 )
                    return 1;
                else
-                   return FibonacciEngine_fibonacci( recv, n-1 ) + FibonacciEngine_fibonacci( recv,  n-2 );
+                   return FibonacciEngine_fibonacci( self, n-1 ) + FibonacciEngine_fibonacci( self,  n-2 );
        `}
 end
 
 redef class Int
        fun fibonacci : Int import fibonacci `{
-               if ( recv == 0 )
+               if ( self == 0 )
                    return 0;
-               else if ( recv == 1 )
+               else if ( self == 1 )
                    return 1;
                else
-                   return Int_fibonacci( recv-1 ) + Int_fibonacci( recv-2 );
+                   return Int_fibonacci( self-1 ) + Int_fibonacci( self-2 );
        `}
 end
 
index 79c2654..d6abce2 100644 (file)
@@ -20,12 +20,12 @@ extern class As `{ A* `}
        `}
 
        fun []=(i: Int, v: A) `{
-               recv[i] = v;
+               self[i] = v;
                A_incr_ref(v);
        `}
 
        fun [](i: Int): A `{
-               return recv[i];
+               return self[i];
        `}
 end
 
index 7e9ec29..24d152d 100644 (file)
@@ -47,7 +47,7 @@ extern class A
        `}
 
        fun p : Int import m `{
-               return A_m( recv ) + 5;
+               return A_m( self ) + 5;
        `}
 
        fun in_language : Int is extern in "C" `{
index 5fb5b35..1b927aa 100644 (file)
@@ -33,7 +33,7 @@ fun in2(i: Float) do print "Back in Nit: in2"
 
 fun out(i: Int, f: Float): Int import in1, in2, A, A.alt, A.to_i `{
        printf("From C, beginning out: %ld\n", i);
-       Sys_in1(recv, i);
+       Sys_in1(self, i);
        A a = new_A();
        A b = new_A_alt(10);
        printf("From C, a=%ld\n", A_to_i(a));
index 6f5a95a..7e826eb 100644 (file)
@@ -32,7 +32,7 @@ extern class A `{int *`}
 
        fun a do print "a"
        fun p `{
-           printf( "allo from %i\n", *recv );
+           printf( "allo from %i\n", *self );
        `}
        fun d : A import d, A `{
         return new_A();
index e9b46d2..1a15da1 100644 (file)
@@ -24,9 +24,9 @@ extern class IntPtr `{ int* `}
        `}
 
        redef fun to_s import NativeString, NativeString.to_s `{
-               int len = snprintf(NULL, 0, "%d", *recv) + 1;
+               int len = snprintf(NULL, 0, "%d", *self) + 1;
                char *c = new_NativeString(len);
-               sprintf(c, "%d", *recv);
+               sprintf(c, "%d", *self);
                return NativeString_to_s(c);
        `}
 end
index 80a3025..d78ceac 100644 (file)
@@ -20,100 +20,100 @@ class A
        init(value: Int) do self.value = value
 
        fun +(other: A): A import value, A `{
-               int s = A_value( recv );
+               int s = A_value( self );
                int o = A_value( other );
 
                return new_A( s + o );
        `}
 
        fun +: A import value, A `{
-               int s = A_value(recv);
+               int s = A_value(self);
                return new_A(+s);
        `}
 
        fun -(other: A): A import value, A `{
-               int s = A_value( recv );
+               int s = A_value( self );
                int o = A_value( other );
 
                return new_A( s - o );
        `}
 
        fun -: A import value, A `{
-               int s = A_value(recv);
+               int s = A_value(self);
                return new_A(-s);
        `}
 
        fun *(by: Int): A import value, A `{
-               int s = A_value( recv );
+               int s = A_value( self );
 
                return new_A( s * by );
        `}
 
        fun /(by: Int): A import value, A `{
-               int s = A_value( recv );
+               int s = A_value( self );
 
                return new_A( s / by );
        `}
 
        redef fun ==(other) import value, nullable Object.as(A) `{
                if ( nullable_Object_is_a_A( other ) &&
-                        A_value( nullable_Object_as_A(other) ) == A_value( recv ) )
+                        A_value( nullable_Object_as_A(other) ) == A_value( self ) )
                        return 1;
                else
                        return 0;
        `}
 
        fun %(other: A): A import value, A `{
-               return new_A( A_value( recv ) % A_value( other ) );
+               return new_A( A_value( self ) % A_value( other ) );
        `}
 
        fun <=>(other: A): A import value, A `{
-               return new_A( A_value( recv )* 1024 );
+               return new_A( A_value( self )* 1024 );
        `}
 
        fun >(other: A): Bool import value `{
-               return A_value( recv ) > A_value( other );
+               return A_value( self ) > A_value( other );
        `}
 
        fun <(other: A): Bool import value `{
-               return A_value( recv ) < A_value( other );
+               return A_value( self ) < A_value( other );
        `}
 
        fun >=(other: A): Bool import value `{
-               return A_value( recv ) >= A_value( other );
+               return A_value( self ) >= A_value( other );
        `}
 
        fun <=(other: A): Bool import value `{
-               return A_value( recv ) <= A_value( other );
+               return A_value( self ) <= A_value( other );
        `}
 
        fun >>(other: A): A import value, value=, A `{
-               int new_val = A_value( recv ) >> A_value( other );
+               int new_val = A_value( self ) >> A_value( other );
                return new_A(new_val);
        `}
 
        fun <<(other: A): A import value, A `{
-               int new_val = A_value( recv ) << A_value( other );
+               int new_val = A_value( self ) << A_value( other );
                return new_A(new_val);
        `}
 
        fun |(other: A): A import value, A `{
-               int new_val = A_value( recv ) | A_value( other );
+               int new_val = A_value( self ) | A_value( other );
                return new_A(new_val);
        `}
 
        fun ^(other: A): A import value, A `{
-               int new_val = A_value( recv ) ^ A_value( other );
+               int new_val = A_value( self ) ^ A_value( other );
                return new_A(new_val);
        `}
 
        fun ~: A import value, A `{
-               int new_val = ~A_value( recv );
+               int new_val = ~A_value( self );
                return new_A(new_val);
        `}
 
        fun &(other: A): A import value, A `{
-               int new_val = A_value( recv ) & A_value( other );
+               int new_val = A_value( self ) & A_value( other );
                return new_A(new_val);
        `}
 
index 8b241ff..e3052cf 100644 (file)
@@ -24,7 +24,7 @@ class B
        redef fun id : String import super, NativeString.to_s, String.to_cstring `{
                char *new_name;
                char *prefix = "B special ";
-               char *super_name = String_to_cstring( B_id___super( recv ) );
+               char *super_name = String_to_cstring( B_id___super( self ) );
 
                new_name = calloc( strlen( prefix )+strlen( super_name )+1, sizeof(char) );
                strcpy( new_name, prefix );
index 071fa86..7607127 100644 (file)
@@ -16,7 +16,7 @@ extern class A in "C" `{struct s_a*`}
                return v;
        `}
        fun p `{
-               printf( "A< %d %d >\n", recv->x, recv->y );
+               printf( "A< %d %d >\n", self->x, self->y );
        `}
 end
 
@@ -32,8 +32,8 @@ extern class B in "C" `{struct s_b*`}
        `}
        redef fun p import super `{
                printf( "B< " );
-               B_p___super(recv);
-               printf( "   %d %d >\n", recv->w, recv->h );
+               B_p___super(self);
+               printf( "   %d %d >\n", self->w, self->h );
        `}
 end
 
@@ -46,7 +46,7 @@ extern class C
                return v;
        `}
        redef fun p `{
-               printf( "C< %d %d >\n", recv->x, recv->y );
+               printf( "C< %d %d >\n", self->x, self->y );
        `}
 end
 
index e212c32..f899a47 100644 (file)
@@ -33,23 +33,23 @@ extern class CppVector in "C++" `{vector<int>*`}
 
        # Adds an element to the end of the vector
        fun push(v: Int) in "C++" `{
-               recv->push_back(v);
+               self->push_back(v);
        `}
 
        # Pops an element from the end of the vector
        fun pop: Int in "C++" `{
-               long val = recv->back();
-               recv->pop_back();
+               long val = self->back();
+               self->pop_back();
                return val;
        `}
 
        fun safe_pop_with_default(default_return: Int): Int import report_error in "C++" `{
-               if (recv->empty()) {
-                       CppVector_report_error(recv);
+               if (self->empty()) {
+                       CppVector_report_error(self);
                        return default_return;
                } else {
-                       long val = recv->back();
-                       recv->pop_back();
+                       long val = self->back();
+                       self->pop_back();
                        return val;
                }
        `}
index 5b6c59f..7b9c3b0 100644 (file)
@@ -35,24 +35,24 @@ extern class CppVector in "C++" `{vector<int>*`}
 
        # Adds an element to the end of the vector
        fun push(v: Int) in "C++" `{
-               recv->push_back(v);
+               self->push_back(v);
        `}
 
        # Pops an element from the end of the vector
        fun pop: Int in "C++" `{
-               long val = recv->back();
-               recv->pop_back();
+               long val = self->back();
+               self->pop_back();
                return val;
        `}
 
        # Uses a callback to report when receiver is empty
        fun safe_pop_with_default(default_return: Int): Int import report_error in "C++" `{
-               if (recv->empty()) {
-                       CppVector_report_error(recv);
+               if (self->empty()) {
+                       CppVector_report_error(self);
                        return default_return;
                } else {
-                       long val = recv->back();
-                       recv->pop_back();
+                       long val = self->back();
+                       self->pop_back();
                        return val;
                }
        `}
@@ -62,13 +62,13 @@ extern class CppVector in "C++" `{vector<int>*`}
 
        # Prints the given string when receiver is empty
        fun safe_pop_with_custom_error(default_return: Int, error_msg: String): Int import String.to_cpp_string in "C++" `{
-               if (recv->empty()) {
+               if (self->empty()) {
                        string *cpp_error_msg = String_to_cpp_string(error_msg);
                        cout << *cpp_error_msg << "\n";
                        return default_return;
                } else {
-                       long val = recv->back();
-                       recv->pop_back();
+                       long val = self->back();
+                       self->pop_back();
                        return val;
                }
        `}
index 6cdd3f5..364ec9e 100644 (file)
@@ -33,13 +33,13 @@ extern class CppVector in "C++" `{vector<int>*`}
 
        # Adds an element to the end of the vector
        fun push(v: Int) in "C++" `{
-               recv->push_back(v);
+               self->push_back(v);
        `}
 
        # Pops an element from the end of the vector
        fun pop: Int in "C++" `{
-               long val = recv->back();
-               recv->pop_back();
+               long val = self->back();
+               self->pop_back();
                return val;
        `}
 end
index 4fcdbf6..6f438be 100644 (file)
@@ -24,8 +24,8 @@ class A
        fun i: Int do return 777
 
        fun foo import bar, i in "Java" `{
-               A_bar(recv);
-               long i = A_i(recv);
+               A_bar(self);
+               long i = A_i(self);
                System.out.println(i);
        `}
 
index 8c968fd..3ceb224 100644 (file)
@@ -28,12 +28,12 @@ extern class JavaQueueOfString in "Java" `{ java.util.Queue<String> `}
                return new LinkedBlockingQueue<String>();
        `}
 
-       fun offer(o: JavaString) in "Java" `{ recv.offer(o); `}
+       fun offer(o: JavaString) in "Java" `{ self.offer(o); `}
 
-       fun remove: JavaString in "Java" `{ return recv.remove(); `}
+       fun remove: JavaString in "Java" `{ return self.remove(); `}
 
        redef fun output in "Java" `{
-               for (String s: recv) {
+               for (String s: self) {
                        System.out.println(s);
                }
        `}
index 5f5819d..40fbf84 100644 (file)
@@ -30,7 +30,7 @@ class A
                System.out.println(input);
 
                // Callback Nit with string
-               String str = A_bar(recv, "Created in Java");
+               String str = A_bar(self, "Created in Java");
                System.out.println(str);
 
                // Send back a string
index 19ca640..cbdfa0f 100644 (file)
@@ -27,16 +27,16 @@ extern class JavaArrayList in "Java" `{ java.util.ArrayList `}
                return new ArrayList();
        `}
 
-       fun add(o: JavaString) in "Java" `{ recv.add(o); `}
+       fun add(o: JavaString) in "Java" `{ self.add(o); `}
 
        redef fun output in "Java" `{
-               for (Object i: recv) {
+               for (Object i: self) {
                        System.out.println((String)i);
                }
        `}
 
        fun sort in "Java" `{
-               Collections.sort(recv);         
+               Collections.sort(self);
        `}
 end
 
index 4512519..6869ac9 100644 (file)
@@ -24,7 +24,7 @@ import bar, String.to_cstring, Int.+ in "ObjC" `{
 
        printf("From Objective-C: %ld %f %s\n", ii, f, cstr);
 
-       Sys_bar(recv, ii, f, s);
+       Sys_bar(self, ii, f, s);
 `}
 
 fun bar(i: Int, f: Float, s: String)
index d2fc373..715ccb0 100644 (file)
@@ -52,7 +52,7 @@ private class A
                printf( "received msg: %s, of length = %d\n", c_msg, msg_len );
 
                /* A_my_attr is a callback to the getter of self.my_attr */
-               printf( "old attr %d\n", A_my_attr(recv) );
+               printf( "old attr %d\n", A_my_attr(self) );
 
                if(chose)
                        truc;
@@ -60,7 +60,7 @@ private class A
                        chose;
 
                /* A_my_attr is a callback to the setter of self.my_attr= */
-               A_my_attr__assign( recv, msg_len );
+               A_my_attr__assign( self, msg_len );
     `}
 end
 
@@ -68,19 +68,19 @@ extern class TimeT `{time_t`}
        new `{ return time(NULL); `}
        new from_i(i: Int) `{ return i; `}
 
-       fun update `{ time(&recv); `}
+       fun update `{ time(&self); `}
 
        fun ctime: String import NativeString.to_s_with_copy `{
-               return NativeString_to_s_with_copy( ctime(&recv) );
+               return NativeString_to_s_with_copy( ctime(&self) );
        `}
 
        # Difference in secondes from start (self if the end time)
-       fun difftime(start: TimeT): Float `{ return difftime(recv, start); `}
+       fun difftime(start: TimeT): Float `{ return difftime(self, start); `}
 
        private fun intern_poll(in_fds: Array[Int], out_fds: Array[Int]) : nullable Int is extern import Array[Int].length, Array[Int].[], Int.as(nullable Int) `{`}
 end
 
 fun address_is_null: Bool is extern "address_is_null"
 
-fun free `{ free(recv); `}
+fun free `{ free(self); `}
 
diff --git a/tests/utf_noindex_test.nit b/tests/utf_noindex_test.nit
deleted file mode 100644 (file)
index 5353bdb..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# This file is free software, which comes along with NIT.  This software is
-# distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
-# without  even  the implied warranty of  MERCHANTABILITY or  FITNESS FOR A
-# PARTICULAR PURPOSE.  You can modify it is you want,  provided this header
-# is kept unaltered, and a notification of the changes is added.
-# You  are  allowed  to  redistribute it and sell it, alone or is a part of
-# another product.
-
-import standard
-intrude import string_experimentations::utf8_noindex
-
-var s = "aàハ𐍆".as(FlatString)
-assert s.char_at(0).code_point == 97
-assert s.char_at(1).code_point == 224
-assert s.char_at(2).code_point == 12495
-assert s.char_at(3).code_point == 66374
-
-var str = "ハaロЖー𐍃aδΈ–η•Œ α“€ . α“‚ A,𐍆 aζ—₯本Aθͺžaです".as(FlatString)
-
-print str.length
-print str
-
-for i in [0 .. str.length[ do
-       str.char_at(i).output
-end
-
-'\n'.output
-
-var ss = str.reversed.as(FlatString)
-
-for i in [0 .. ss.length[ do ss.char_at(i).output
-
-'\n'.output
-
-var x = str.substring(4,4).as(FlatString)
-
-for i in [0 .. x.length[ do x.char_at(i).output
-
-'\n'.output
-
-var xx = x.reversed.as(FlatString)
-
-for i in [0 .. xx.length[ do xx.char_at(i).output
-
-'\n'.output
-
-var it = new FlatStringReviter(x)
-for i in it do
-       i.output
-end
-
-'\n'.output
-
-var it2 = new FlatStringIter(x)
-for i in it2 do
-       i.output
-end
-
-'\n'.output
-
-it = new FlatStringReviter(str)
-for i in it do
-       i.output
-end
-
-'\n'.output
-
-it2 = new FlatStringIter(str)
-for i in it2 do
-       i.output
-end
-
-'\n'.output
-
-assert str * 2 == str + str
-
-assert x * 2 == x + x
-
-print str.to_upper
-
-print str.to_lower
-
-var buf = new FlatBuffer.from(str)
-
-buf.append str
-
-var bf = new FlatBuffer.from(str)
-
-bf.times(2)
-
-assert bf == buf
-
-var bf2 = new FlatBuffer.from(str)
-
-bf2.char_at(0) = str.char_at(1)
-bf2.char_at(1) = str.char_at(0)
-
-for i in [0 .. bf2.length[ do bf2.char_at(i).output
-
-'\n'.output
-
-bf2.lower
-
-for i in [0 .. bf2.length[ do bf2.char_at(i).output
-
-'\n'.output
-
-bf2.upper
-
-for i in [0 .. bf2.length[ do bf2.char_at(i).output
-
-'\n'.output
-
-bf2.reverse
-
-for i in [0 .. bf2.length[ do bf2.char_at(i).output
-
-'\n'.output