/bitfield/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/bitfield/trunk

« back to all changes in this revision

Viewing changes to src/bit_map.vala

  • Committer: Gustav Hartvigsson
  • Date: 2020-11-03 19:35:25 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20201103193525-tewczqy146ln4spx
* Made it able to be compiled as a library
* Added C test
* Added more tests to main.vala

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
  
17
17
  private static GLib.Tree<FieldInfo?, uint16> mask_cache;
18
18
  
19
 
  void init () {
 
19
  public void init () {
20
20
    list_of_types = new GLib.Tree<string, Type?> ((a, b) => {
21
21
      return (GLib.strcmp (a,b));
22
22
    });
26
26
    });
27
27
  }
28
28
  
29
 
  void deinit () {
 
29
  public void deinit () {
30
30
    list_of_types.foreach ((_key, _val) => {
31
31
      list_of_types.remove (_key);
32
32
      
34
34
    });
35
35
  }
36
36
  
37
 
  static bool add_type_v (string name, FieldInfo first_field, ...) {
 
37
  public static bool add_type_v (string name, FieldInfo first_field, ...) {
38
38
    var va = va_list ();
39
39
    
40
40
    GLib.List<FieldInfo?> lst = new GLib.List<FieldInfo?> ();
47
47
    
48
48
    FieldInfo[] lst2 = new FieldInfo[lst.length ()];
49
49
    
50
 
    add_type (name, lst2);
51
 
    
52
 
    return false;
 
50
    for (uint i = 0; i < lst.length (); i++) {
 
51
      lst2[i] = lst.nth_data (i);
 
52
    }
 
53
   
 
54
    return add_type (name, lst2);
53
55
  }
54
56
  
55
57
  /**
177
179
    uint8 start;
178
180
    uint8 end;
179
181
    uint8 length;
180
 
    GLib.pointer padding;
181
182
    
182
183
    public FieldInfo (int field_id, uint8 start, uint8 end, uint8 length) {
183
184
      this.field_id = field_id;
184
185
      this.start = start;
185
186
      this.end = end;
186
187
      this.length = length; 
187
 
      this.padding = null;
188
188
    }
189
189
    
190
190
    public int compare (FieldInfo other) {
222
222
    }
223
223
    
224
224
    [CCode (cname = "bit_field_field_info_compare")]
225
 
    public static extern int static_campare (FieldInfo a, FieldInfo b);
 
225
    public static extern int static_compare (FieldInfo a, FieldInfo b);
 
226
    
226
227
    
227
228
    
228
229
    public bool overlap (FieldInfo other) {
230
231
    }
231
232
    
232
233
    [CCode (cname = "bit_field_field_info_overlap")]
233
 
    public static extern int static_overlap (FieldInfo a, FieldInfo b);
 
234
    public static extern bool static_overlap (FieldInfo a, FieldInfo b);
234
235
    
235
236
    
236
237
    public string to_string () {