~eda-qa/dhlib/main

« back to all changes in this revision

Viewing changes to haxe/InlineDerived.hx

  • Committer: edA-qa mort-ora-y
  • Date: 2010-02-16 05:36:32 UTC
  • Revision ID: eda-qa@disemia.com-20100216053632-60lt7fndfi3fgblw
first

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* <license>
 
2
 * This file is part of the dis-Emi-A HaXe Library. Copyright © edA-qa mort-ora-y
 
3
 * For full copyright and license information please refer to doc/license.txt.
 
4
 * </license> 
 
5
 */
 
6
/**
 
7
(reference for edA-qa) Attempt to reproduce errors when Matrix.get is inline:
 
8
sudoku/Board.hx:245: characters 4-81 : mathx.Matrix<Int> should be { set : Int -> Int -> Int -> Unknown<0>, get : Int -> Int -> Int }
 
9
sudoku/Board.hx:245: characters 4-81 : Inconsistent getter for field get : inline should be default
 
10
sudoku/Board.hx:245: characters 4-81 : For function argument 'remainInGroup'
 
11
*/
 
12
class Matrix<T>
 
13
{
 
14
        private var data : Array<T>;
 
15
        var sizex : Int;
 
16
        
 
17
        //HAXE: an "inline" here produces a compiler error!
 
18
        //inline
 
19
        public function get( x : Int, y : Int ) : T
 
20
        {
 
21
                return data[(((y))*sizex + ((x)))];
 
22
        }
 
23
        
 
24
        public function set( x : Int, y : Int, val : T )
 
25
        {
 
26
                data[(((y))*sizex + ((x)))] = val;
 
27
        }
 
28
        
 
29
        public function new( )
 
30
        {
 
31
                sizex = 0;
 
32
        }
 
33
}
 
34
 
 
35
class Board extends Matrix<Int>
 
36
{
 
37
        private function solve() 
 
38
        {
 
39
                var remainInGroup = new Matrix<Int>();
 
40
                solvePlace( get( 1, 2 ), 1, 2, remainInGroup );
 
41
        }
 
42
        
 
43
        private function solvePlace( value : Int, x : Int, y : Int, remainInGroup )
 
44
        {
 
45
                remainInGroup.set( x, y, remainInGroup.get(x,y)-1 );
 
46
        }
 
47
}
 
48
 
 
49
class InlineDerived extends haxe.unit.TestCase
 
50
{
 
51
        public function testCompile()
 
52
        {
 
53
                assertTrue( true );
 
54
        }
 
55
}