/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk
5.2.4 by Gustav Hartvigsson
Finished documenting the SMap and SMapItem interfaces.
1
/*
5.2.7 by Gustav Hartvigsson
* Switched licence to a more permisive one.
2
Copyright (c) 2013-2014 Gustav Hartvigsson
3
4
Permission is hereby granted, free of charge, to any person obtaining a copy
5
of this software and associated documentation files (the "Software"), to deal
6
in the Software without restriction, including without limitation the rights
7
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
copies of the Software, and to permit persons to whom the Software is
9
furnished to do so, subject to the following conditions:
10
11
The above copyright notice and this permission notice shall be included in
12
all copies or substantial portions of the Software.
13
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
THE SOFTWARE.
5.2.4 by Gustav Hartvigsson
Finished documenting the SMap and SMapItem interfaces.
21
*/
22
23
5.2.1 by Gustav Hartvigsson
Started work on the Map (SMap) data structure.
24
#ifndef __H_FUNC__
25
#define __H_FUNC__
5.2.4 by Gustav Hartvigsson
Finished documenting the SMap and SMapItem interfaces.
26
27
32 by Gustav Hartvigsson
* Added some compile options to the root CMakeLists.txt
28
#include "defs.h"
29
#include "utils.h"
30
31
BEGIN_DECLS
32
44 by Gustav Hartvigsson
* Started to structuce the dectumentation a little better.
33
34
/** @file
35
 * Generic function pointer definitions and data stuctures to do with
36
 * functions.
37
 * 
38
 * @todo create an object type that can hold functions and be able to run them.
39
 */
40
41
5.2.4 by Gustav Hartvigsson
Finished documenting the SMap and SMapItem interfaces.
42
/*
5.2.1 by Gustav Hartvigsson
Started work on the Map (SMap) data structure.
43
 * This data structure holds a pointer to a function.
44
 *
45
 * A Func object must hold a pointer to a function and can hold a string,
46
 * representing its name.
47
 */
48
89 by Gustav Hartvigsson
* Started working on Threads
49
#define METHOD(k) ((MethodFunc) k)
50
#define FUNCTION(k) ((FuncPointer) k)
51
#define FREEFUNC(k) ((FreeFunc) k)
52
#define CALLBACK(k) ((Callback) k)
53
#define FOREACHFUNC(k) ((ForEachFunc) k)
5.2.1 by Gustav Hartvigsson
Started work on the Map (SMap) data structure.
54
5.2.4 by Gustav Hartvigsson
Finished documenting the SMap and SMapItem interfaces.
55
/*
5.2.1 by Gustav Hartvigsson
Started work on the Map (SMap) data structure.
56
 * Common types of function pointers:
57
 */
58
59
5.2.4 by Gustav Hartvigsson
Finished documenting the SMap and SMapItem interfaces.
60
/**
61
 * Generic function.
22 by Gustav Hartvigsson
* Made code compile
62
 *
63
 * It can take any type of function, with any signature
64
 */
65
typedef void (* FuncPointer)(void);
66
67
/**
44 by Gustav Hartvigsson
* Started to structuce the dectumentation a little better.
68
 * A generic callback function.
22 by Gustav Hartvigsson
* Made code compile
69
 *
44 by Gustav Hartvigsson
* Started to structuce the dectumentation a little better.
70
 * A callback function can have any signature.
22 by Gustav Hartvigsson
* Made code compile
71
 */
72
typedef void (* Callback)(void);
73
74
/**
75
 *
76
 */
30 by Gustav Hartvigsson
* Made the code compile using CMake.
77
typedef void (* FreeFunc)(spointer obj);
78
89 by Gustav Hartvigsson
* Started working on Threads
79
typedef spointer (* RunFunc)(spointer user_data);
32 by Gustav Hartvigsson
* Added some compile options to the root CMakeLists.txt
80
30 by Gustav Hartvigsson
* Made the code compile using CMake.
81
/**
62 by Gustav Hartvigsson
* General documentation clean up.
82
 * @param obj The object that the function should be run on. Generally this
83
 *            should be ignored inside the function.
84
 * @param item The item that the the function should act on. @newline
85
 *             This can be printing the data, erasing the it, modifying it,
86
 *             changing it or what ever.
87
 * @param data The data that is passed to the _foreach () function. Often called
88
 *             the user data. Can also be used as an out parameter.
30 by Gustav Hartvigsson
* Made the code compile using CMake.
89
 */
90
typedef void (* ForEachFunc)(spointer obj, spointer item, spointer data);
22 by Gustav Hartvigsson
* Made code compile
91
30 by Gustav Hartvigsson
* Made the code compile using CMake.
92
5.2.4 by Gustav Hartvigsson
Finished documenting the SMap and SMapItem interfaces.
93
/**
94
 * A CompFunc represents a standard comparison function.
95
 * 
96
 * @param 1 object to compare
97
 * @param 2 object to compare
98
 * 
99
 * compare parameter 1 with parameter 2.
100
 */
46 by Gustav Hartvigsson
* Renamed DynamicArray to SDynamicArray.
101
typedef sboolean (* CompFunc)(void*, void*);
5.2.1 by Gustav Hartvigsson
Started work on the Map (SMap) data structure.
102
103
typedef char * (* CharFunc)();
104
46 by Gustav Hartvigsson
* Renamed DynamicArray to SDynamicArray.
105
22 by Gustav Hartvigsson
* Made code compile
106
END_DECLS
107
5.2.1 by Gustav Hartvigsson
Started work on the Map (SMap) data structure.
108
#endif