/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/Callback.h

  • Committer: Gustav Hartvigsson
  • Date: 2015-08-26 21:43:01 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20150826214301-a3ms101kvjx4g0qq
* General documentation clean up.
* Made the doxygen optimise for C
* Changed SBoxPrivate to use union
* Implemented the s_box_new_xxx functions
* moved free_func from SBoxClass to SBoxPrivate to lessen confusion with SObjectClass->free, and keep it private.
* Added S_ERROR_TYPE_ERROR to represent generic type errors.
* Added CALLBACK(k) macro
* Made a group for SMatrix.
* Added documentation for various functions and what not.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 * @sa GlobalNotify
21
21
 */
22
22
 
23
 
/**
24
 
 * An SCallbackEntry is used for convinience when installing callbacks into
25
 
 * SObjects. It may also be used in 
26
 
 */
27
 
typedef struct SCallbackEntry SCallbackEntry;
28
23
 
29
24
/**
30
25
 * The types for callbacks.
36
31
  S_CALLBACK_NOTIFY_CHANGE
37
32
} SCallbackType;
38
33
 
 
34
 
39
35
/**
40
36
 * A list containing the names of the callback types.
41
37
 */
48
44
  0x0,
49
45
};
50
46
 
51
 
 
52
 
struct
53
 
SCallbackEntry {
 
47
/**
 
48
 * An SCallbackEntry is used for convenience when installing callbacks into
 
49
 * SObjects.
 
50
 *
 
51
 * an example of how this could be used is:
 
52
 @code{.c}
 
53
const SCallbackEntry foo_callback_entries[] = {
 
54
  {"val_x_change", S_CALLBACK_NOTIFY_CHANGE, CALLBACK(foo_val_x_change_func)},
 
55
  {"used", S_CALLBACK_CALLBACK, CALLBACK(foo_used)}
 
56
};
 
57
s_object_install_callbacks (S_OBJECT(Foo), &foo_callback_entries);
 
58
 * @endcode
 
59
 * 
 
60
 * The callback must have the following signature:
 
61
 * @code{.c}
 
62
spointer
 
63
foo_some_func (SObject obj, spointer user_data) {
 
64
  // Do something
 
65
  return ret_val; // Must return something, Be it NULL or something important
 
66
}
 
67
 @endcode
 
68
 */
 
69
typedef struct SCallbackEntry {
54
70
  char * name; /**< The name that is used to invoke the callback. */
55
71
  SCallbackType type; /**< The type of the callback, is it a standard callback
56
72
                       * or a notify? */
57
73
  Callback callback; /**< The callback that will be invoked.*/
58
 
};
59
 
 
60
 
 
 
74
} SCallbackEntry;
61
75
 
62
76
/**
63
77
 * @}
66
80
 */
67
81
 
68
82
/**
69
 
 * Installs an array of callcackentries into an SObject.
 
83
 * Installs an array of callbackentries into an SObject.
70
84
 * 
71
85
 * @param obj The object to install the callback entries into.
72
86
 * @param callbackentries an array containing the callback entries.
84
98
s_object_install_callback (SObject * obj, SCallbackEntry * callbackentry);
85
99
 
86
100
/**
87
 
 * 
 
101
 * @breif Do a callback.
 
102
 *
 
103
 * When this function is called a on an SObject it calls the appropriate
 
104
 * callback that has been assigned the name.
 
105
 *
 
106
 * @param self The object to do the callback on.
 
107
 * @param name The name of the callback, can contain any valid non-null
 
108
 * character.
88
109
 */
89
110
spointer
90
 
s_object_notify (SObject * self, char * name, spointer * data);
 
111
s_object_notify (SObject * self, char * name, spointer * user_data);
91
112
 
92
113
/**
93
114
 * Alias to s_object_notify()