+++ /dev/null
-# 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.
-
-import kernel
-
-interface I
-end
-
-abstract class AC
-end
-
-class C
-end
-
-enum E
-end
-
-extern class EC
- #alt1# super I
- #alt2# super AC
- #alt3# super C
- #alt4# super E
- fun foo do 1.output
- #alt5# var x: Int
-end
-
-class I2
- #alt6# super EC
-end
-
-class AC2
- #alt7# super EC
-end
-
-class C2
- #alt8# super EC
-end
-
-class E2
- #alt9# super EC
-end
-
-fun inita: EC is extern
-
-var a = inita
-#alt10# a = new EC
-a.foo
-
+++ /dev/null
-alt/base_ni_alt10.nit:57,5--10: Error: Method 'init' doesn't exists in EC.
+++ /dev/null
-alt/base_ni_alt2.nit:29,14--15: Special error: Extern class EC try to specialise class AC.
+++ /dev/null
-alt/base_ni_alt3.nit:29,14--15: Special error: Extern class EC try to specialise class C.
+++ /dev/null
-alt/base_ni_alt4.nit:29,14--15: Special error: Class EC try to specialise enum class E.
-alt/base_ni_alt4.nit:29,14--15: Special error: Extern class EC try to specialise class E.
+++ /dev/null
-alt/base_ni_alt5.nit:35,6: Error: Attempt to define attribute x in the extern class EC.
+++ /dev/null
-alt/base_ni_alt6.nit:38,7--8: Special error: Class I2 try to specialise extern class EC.
+++ /dev/null
-alt/base_ni_alt7.nit:42,7--9: Special error: Class AC2 try to specialise extern class EC.
+++ /dev/null
-alt/base_ni_alt8.nit:46,7--8: Special error: Class C2 try to specialise extern class EC.
+++ /dev/null
-alt/base_ni_alt9.nit:50,7--8: Special error: Class E2 try to specialise extern class EC.
+++ /dev/null
-test_ni_cast_extra.nit:50,21--28: Warning: comparaison between null and a non nullable value.
-a isa b false (expected: false)
-c isa a true (expected: true)
-d isa b true (expected: true)
-da is null? false (expected: false)
-db is null? false (expected: false)
-ab is null? true (expected: true)
+++ /dev/null
-foo
-bar
-baz
+++ /dev/null
-100==100
-33==33
+++ /dev/null
-nity
-nity
-nity1 3
-nity2 7 13
+++ /dev/null
-x
-y
-y
-y
-x
-y
-y
-y
-x
-y
-y
-y
-x
-y
-y
-y
-x
-y
-y
-y
-x
-y
-y
-y
+++ /dev/null
-true -? true
-false -? false
-false -? false
-true -? true
-false -? false
-is null, ok
-something
+++ /dev/null
-test_ni_operators.nit:77,7--25: Warning: comparaison between null and a non nullable value.
-11
-9
-22
-3
-false
-false
-false
-false
-true
-3
-4096
-true
-false
-false
-false
-false
-true
-true
-true
-false
-false
-true
-true
-52
-456
+++ /dev/null
-1
-2
-3
-3
-hello world
+++ /dev/null
-a from nit
-A
-a from extern
-A
-a from nit
-B
-a from extern
-B
+++ /dev/null
-0
-1
-2
-1234
+++ /dev/null
-test_ni_special_to_native.nit:37,1--7: Warning: Expression is already a A since it is a B.
-test_ni_special_to_native.nit:38,1--7: Warning: Expression is already a A since it is a B.
-A
-A from native
-B
-B from native
-B
-B from native
+++ /dev/null
-hello world...
-hello world?
-hello world!
-something
-9
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2011 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# 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
- readable var _r : String = "r"
- writable var _w : String = "w"
- readable writable var _rw : String = "rw"
-
- fun print_all is extern import String::to_cstring, r, rw
- fun modify is extern import NativeString::to_s, w=, rw=
-end
-
-class B
- fun print_and_modify( a : A ) is extern import A::rw, A::rw=, String::to_cstring, NativeString::to_s
-end
-
-var a = new A
-a.print_all
-a.modify
-a.print_all
-
-var b = new B
-b.print_and_modify( a )
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2011 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# 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
- fun isa_b : Bool is extern import A as(B)
- fun as_b : nullable B is extern import A as(B), A as(nullable B)
-end
-
-class B
-end
-
-class C
-super A
- fun isa_a : Bool is extern import C as(A)
-end
-
-class D # triangle
-super A
-super B
- init do end
- fun as_a : A is extern import D as(A)
-end
-
-# isa
-var a = new A
-var c = new C
-var d = new D
-
-print "a isa b {a.isa_b} (expected: false)"
-print "c isa a {c.isa_a} (expected: true)"
-print "d isa b {d.isa_b} (expected: true)"
-
-var da = d.as_a
-var db = d.as_b
-var ab = a.as_b
-
-print "da is null? {da==null} (expected: false)"
-print "db is null? {db==null} (expected: false)"
-print "ab is null? {ab==null} (expected: true)"
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2011 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# 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.
-
-fun s_to_o( s : String ) : Object is extern import String as ( Object )
-
-fun n_to_nn( s : String ) : nullable String is extern import String as nullable
-fun nn_to_n( s : nullable String ) : String is extern import nullable String as not nullable
-
-var o = s_to_o( "foo" )
-var nn = n_to_nn( "bar" )
-var n = nn_to_n( "baz" )
-
-print o
-
-if nn == null
-then
- print "null (not good)"
-else
- print nn
-end
-
-print n
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2011 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# 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 FibonacciEngine
- fun fibonacci( n : Int ) : Int is extern import fibonacci
-end
-
-redef class Int
- fun fibonacci : Int is extern import fibonacci
-end
-
-var engine = new FibonacciEngine
-print engine.fibonacci( 0 )
-print engine.fibonacci( 1 )
-print engine.fibonacci( 5 )
-print engine.fibonacci( 12 )
-# print engine.fibonacci( 123 )
-
-print 0.fibonacci
-print 1.fibonacci
-print 5.fibonacci
-print 12.fibonacci
-# print 123.fibonacci
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2012 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# 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
- fun f( b : B ) is extern import B::g
-end
-
-class B
- fun g do print "b"
-end
-
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2012 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# 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
- fun f( b : B ) is extern import B::g
-end
-
-class B
- fun g do print "b"
-end
-
-var b = new B
-var a = new A
-a.f( b )
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2011 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# 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 B
- var _i : Int = 0
-
- init do end
-
- init from( i : Int )
- do
- _i = i
- end
-
- fun i : Int do return _i end
-end
-
-class A
- fun ex_sees_b_attr( b : B ) : Int is extern import B::i
-
- fun ex_sees_b_init( i : Int ) : B is extern import B, B::from
-end
-
-var a = new A
-var b100 = new B.from( 100 )
-
-print "100=={a.ex_sees_b_attr( b100 )}"
-print "33=={a.ex_sees_b_init( 33 ).i}"
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2011 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# 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
- fun nity do print "nity"
- fun nity1 ( x : Int ) do print "nity1 {x}"
- fun nity2 ( x : Int, y : Int ) do print "nity2 {x} {y}"
-
- fun ex_sees_nity is extern import nity
-
- fun ex_sees_nities is extern import nity1, nity2
-end
-
-var a = new A
-a.ex_sees_nity
-a.ex_sees_nities
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2012 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# 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 ToBePreserved
- var id : String
-
- redef fun output do print id
-end
-
-class A
- fun run( a, b, c, d : ToBePreserved ) is extern import ToBePreserved::output, launch_gc
- fun run2( a, b, c, d : ToBePreserved ) is extern import ToBePreserved::output, launch_gc, run
-
- fun launch_gc do sys.force_garbage_collection
-end
-
-var x = new ToBePreserved( "x" )
-var y = new ToBePreserved( "y" )
-
-var a = new A
-a.run( x, y, y, y )
-a.run2( x, y, y, y )
-
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2011 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# 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.
-
-extern A super Pointer
- new is extern import p
- new with_args( x : Int, a : A ) is extern
-
- fun a do print "a"
- fun p is extern
- fun d : A is extern import d, A
-end
-
-class B
- init do end
-end
-
-var a = new A
-var b = new A.with_args( 2345, a )
-a.a
-b.a
-
-a.p # 1234
-b.p # 2345
-new A.with_args( 3456, b ).p # 3456
-
-a.d.p #
-b.d.p #
-
-var c = new B
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2011 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# 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
- fun is_int_null( ni : nullable Int ) : Bool is extern import Int as not nullable
- fun is_a_null( na : nullable A ) : Bool is extern import A as not nullable
-
- fun get_nullable_string( get_nulled : Bool ) : nullable String is extern import NativeString::to_s, String as nullable
-end
-
-var a = new A
-
-print "true -? {a.is_int_null( null )}"
-print "false -? {a.is_int_null( 0 )}"
-print "false -? {a.is_int_null( 1234 )}"
-
-print "true -? {a.is_a_null( null )}"
-print "false -? {a.is_a_null( a )}"
-
-var nstr = a.get_nullable_string( true )
-if nstr == null then print "is null, ok" else print nstr # expects "is null"
-
-nstr = a.get_nullable_string( false )
-if nstr == null then print "is null, error" else print nstr # expects "something"
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2011 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# 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 value : Int
-
- init ( value : Int ) do self.value = value
-
- fun +( other : A ) : A is extern import value, A
-
- fun -( other : A ) : A is extern import value, A
-
- fun *( by : Int ) : A is extern import value, A
-
- fun /( by : Int ) : A is extern import value, A
-
- redef fun ==( other ) is extern import value, nullable Object as(A)
-
- fun %( other : A ) : A is extern import value, A
-
-# fun +=( other : A ) : A is extern import value, value=, A `{
-# int new_val = A_value( recv ) + A_value( other );
-# A_value__assign( recv, new_val );
-# return new_A( new_val );
-# `}
-
-# fun -=( other : A ) : A is extern import +=, A, value `{
-# A inv_other = new_A( -1*A_value( other ) );
-# return A__plus_equal( recv, int_other );
-# `}
-
- fun <=>( other : A ) : A is extern import value, A
-
-# fun @( other : A ) : A is extern import value, A `{
-# return new_A( A_value( recv )* 1000 );
-# `}
-
- fun >( other : A ) : Bool is extern import value
-
- fun <( other : A ) : Bool is extern import value
-
- fun >=( other : A ) : Bool is extern import value
-
- fun <=( other : A ) : Bool is extern import value
-
- fun >>( other : A ) is extern import value, value=, A
-
- fun <<( other : A ) is extern import value, A
-
- fun []( index : Int ) : A is extern import A
-
- fun []=( index : Int, value : A ) : A is extern import A
-
- redef fun to_s do return value.to_s
-end
-
-print new A( 1 ) + new A( 10 ) # 11
-print new A( 10 ) - new A( 1 ) # 9
-
-print new A( 2 ) * 11 # 22
-print new A( 33 ) / 11 # 3
-
-print new A( 44 ) == null # false
-print new A( 55 ) == 55 # false
-print new A( 33 ) == new A( 11 ) # false
-print new A( 22 ) == new A( 77 ) # false
-print new A( 11 ) == new A( 11 ) # true
-
-print new A( 147 ) % new A( 12 ) # 3
-print new A( 4 ) <=> new A( 123 ) # 4096
-
-print new A( 1 ) < new A( 100 ) # true
-print new A( 100 ) < new A( 100 ) # false
-print new A( 100 ) < new A( 1 ) # false
-
-print new A( 1 ) > new A( 100 ) # false
-print new A( 100 ) > new A( 100 ) # false
-print new A( 100 ) > new A( 1 ) # true
-
-print new A( 1 ) <= new A( 100 ) # true
-print new A( 100 ) <= new A( 100 ) # true
-print new A( 100 ) <= new A( 1 ) # false
-
-print new A( 1 ) >= new A( 100 ) # false
-print new A( 100 ) >= new A( 100 ) # true
-print new A( 100 ) >= new A( 1 ) # true
-
-#var x = new A( 1 )
-#x << new A( 5 )
-#print x # 16
-
-#var y = new A( 32 )
-#y >> new A( 2 )
-#print y # 8
-
-var a = new A( 456 )
-print a[ 52 ] # 52
-
-a[ 74 ] = new A( 96 )
-print a # 96
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2012 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# 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
- fun foo( i : Int, o : Object ) is extern
-end
-
-redef class Int
- fun bar( o : Object, u : nullable Object ) : Int is extern
-end
-
-(new A).foo( 1234, sys )
-print 2.bar( "titi", null )
-
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2011 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# 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
- init do end
-
- fun is_not_extern do end
-
- fun proc is extern
- fun function : Int is extern
-
- fun one( x : Int ) : Int is extern
- fun two( x : Int, y : Int ) : Int is extern
- fun three( x : Int, y : Int, z : Int ) : Int is extern
-end
-
-fun in_object( o : Object ) : Object is extern
-
-var a = new A
-print a.function
-print a.one( 2 )
-print a.two( 1, 2 )
-print a.three( 2, 4, 3 )
-print in_object( "hello world" )
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2011 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# 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.
-
-extern A
-super Pointer
- new is extern
-
- redef fun to_s : String is extern import NativeString::to_s
-end
-
-var a = new A
-print a
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2011 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# 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.
-
-fun opposite( v : Bool ) : Bool is extern
-fun plus_10( v : Char ) : Char is extern
-fun plus_1000( v : Int ) : Int is extern
-fun multiply_by_100( v : Float ) : Float is extern
-fun print_ns( s : NativeString ) is extern
-
-print opposite( true )
-print opposite( false )
-
-print plus_10( 'a' )
-
-print plus_1000( 1234 )
-
-print multiply_by_100( 123.45 )
-
-print_ns( "hello world".to_cstring )
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2011 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# 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
- fun work is extern
- fun call is extern import work
-end
-
-class B
-super A
- redef fun work is extern
-end
-
-var a = new A
-var b = new B
-
-a.call
-b.call
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2011 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# 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
- fun nity do print "A"
- fun exy is extern import nity
-end
-
-class B
-super A
- redef fun nity do print "B"
-end
-
-var a = new A
-print "a from nit"
-a.nity
-print "a from extern"
-a.exy
-
-var b = new B
-print "a from nit"
-b.nity
-print "a from extern"
-b.exy
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2011 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# 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.
-
-extern ExternInt super Pointer
- new as_0 is extern
- new as_1 is extern
- new as_2 is extern
-
- redef fun to_s : String is extern import NativeString::to_s
- fun to_i : Int is extern
-end
-
-redef class Int
- fun to_extern_int : ExternInt is extern
-end
-
-var i = new ExternInt.as_0
-print i.to_i
-
-i = new ExternInt.as_1
-print i.to_i
-
-i = new ExternInt.as_2
-print i.to_i
-
-i = 1234 .to_extern_int
-print i.to_i
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2011 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# 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
- fun extern_echo is extern
- fun echo do print "A"
-end
-
-class B
-super A
- redef fun extern_echo is extern
- redef fun echo do print "B"
-end
-
-var a = new A
-a.echo
-a.extern_echo
-
-var b = new B
-b.echo
-b.extern_echo
-
-# explicit casts
-b.as(A).echo
-b.as(A).extern_echo
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2011 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# 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
- fun get_str_from_nstr( nstr : NativeString ) : String is extern import NativeString::to_s
- fun get_str_from_nstr_with_len( nstr : NativeString ) : String is extern import NativeString::to_s_with_length, NativeString::cstring_length
-
- fun get_nstr_from_str( str : String ) : NativeString is extern import String::to_cstring
-
- fun get_something : String is extern import NativeString::to_s
-end
-
-var a = new A
-print a.get_str_from_nstr( "hello world...".to_cstring )
-print a.get_str_from_nstr_with_len( "hello world?".to_cstring )
-print a.get_nstr_from_str( "hello world!" ).to_s
-
-
-var something = a.get_something # expects "something"
-print something
-print something.length
+++ /dev/null
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2011 Alexis Laferrière <alexis.laf@xymus.net>
-#
-# 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
- fun id : String do return "A"
-end
-
-class B
-super A
- redef fun id : String is extern import super, NativeString::to_s, String::to_cstring
-end
-
-var a = new A
-print a.id
-
-var b = new B
-print b.id