/simpletypesystem/trunk

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

« back to all changes in this revision

Viewing changes to src/Matrix.c

  • Committer: Gustav Hartvigsson
  • Date: 2015-08-27 15:01:32 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20150827150132-pwijpi0k2f4f96rg
* Working on SMatrix to finish it off.
* Added (non working?) s_wstiring_to_string () to convert Wide Strings (wchar_t *) to Byte Strings (char *).
* fixed spelling of tuple in Matrix.[h,c]
* added documentation to different parts of the code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include "Matrix.h"
2
2
 
3
 
struct _SMatrix {
 
3
struct SMatrix {
4
4
  spointer * matrix; /* An array of pointers... */
5
5
  
6
6
  size_t height;
55
55
  if ((x < self->height) && (x < self->last_tuple)){
56
56
    ret = self->matrix[self->width * x + y];
57
57
  } else {
58
 
    fprintf (stderr, "WARN: The tuple requested does not exist.\n");
 
58
    s_warn_print ("The tuple requested does not exist.\n");
59
59
  }
60
60
  return ret;
61
61
}
67
67
}
68
68
 
69
69
spointer *
70
 
s_matrix_get_tupel (SMatrix * self, size_t x) {
 
70
s_matrix_get_tuple (SMatrix * self, size_t x) {
71
71
  spointer * tuple = NULL;
72
72
  if ((x < self->height) && (x < self->last_tuple)){
73
73
    tuple = calloc (self->width, sizeof (spointer));
75
75
      tuple[i] = s_matrix_get (self, x, i);
76
76
    }
77
77
  } else {
78
 
    fprintf (stderr, "WARN: The tuple requested does not exist.\n");
 
78
    s_warn_print ("The tuple requested does not exist.\n");
79
79
    print_backtrace ();
80
80
  }
81
81
  return tuple;
82
82
}
83
83
 
84
84
void
85
 
s_matrix_append (SMatrix * self, spointer data) {
 
85
s_matrix_append (SMatrix * self, spointer tuple) {
 
86
  if (!tuple){
 
87
    s_err_print ("Tuple is NULL, this is not allowed. Returning.\n");
 
88
    return;
 
89
  }
86
90
  
87
91
}
88
92
 
90
94
void
91
95
s_matrix_foreach (SMatrix * self, ForEachFunc callback, spointer data) {
92
96
  for (size_t i = 0; i <= self->height; i++) {
93
 
    callback (self, s_matrix_get_tupel (self, i), data);
 
97
    callback (self, s_matrix_get_tuple (self, i), data);
94
98
  }
95
99
}