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 |
||
|
126.1.1
by Gustav Hartvigsson
* Using |
24 |
#pragma once
|
|
5.2.4
by Gustav Hartvigsson
Finished documenting the SMap and SMapItem interfaces. |
25 |
|
|
32
by Gustav Hartvigsson
* Added some compile options to the root CMakeLists.txt |
26 |
#include "defs.h" |
27 |
#include "utils.h" |
|
28 |
||
|
110
by Gustav Hartvigsson
* added S_ prifix to my macros. I should not be a scrub. |
29 |
S_BEGIN_DECLS
|
|
32
by Gustav Hartvigsson
* Added some compile options to the root CMakeLists.txt |
30 |
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
31 |
|
32 |
/** @file
|
|
33 |
* Generic function pointer definitions and data stuctures to do with
|
|
34 |
* functions.
|
|
|
109.1.1
by Gustav Hartvigsson
* SMap seems to be broken... Or could it be SObject's Callback stuff? Or SLinkedList? |
35 |
*
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
36 |
* @todo create an object type that can hold functions and be able to run them.
|
37 |
*/
|
|
38 |
||
39 |
||
|
5.2.4
by Gustav Hartvigsson
Finished documenting the SMap and SMapItem interfaces. |
40 |
/*
|
|
5.2.1
by Gustav Hartvigsson
Started work on the Map (SMap) data structure. |
41 |
* This data structure holds a pointer to a function.
|
42 |
*
|
|
43 |
* A Func object must hold a pointer to a function and can hold a string,
|
|
44 |
* representing its name.
|
|
45 |
*/
|
|
46 |
||
|
89
by Gustav Hartvigsson
* Started working on Threads |
47 |
#define METHOD(k) ((MethodFunc) k)
|
48 |
#define FUNCTION(k) ((FuncPointer) k)
|
|
49 |
#define FREEFUNC(k) ((FreeFunc) k)
|
|
50 |
#define CALLBACK(k) ((Callback) k)
|
|
51 |
#define FOREACHFUNC(k) ((ForEachFunc) k)
|
|
|
109.1.1
by Gustav Hartvigsson
* SMap seems to be broken... Or could it be SObject's Callback stuff? Or SLinkedList? |
52 |
#define COMPFUNC(k) ((CompFunc) k)
|
|
116.1.1
by Gustav Hartvigsson
* Implemented the SMainLoop |
53 |
#define RUNFUNC(k) ((RunFunc) k)
|
|
109.1.1
by Gustav Hartvigsson
* SMap seems to be broken... Or could it be SObject's Callback stuff? Or SLinkedList? |
54 |
|
|
5.2.1
by Gustav Hartvigsson
Started work on the Map (SMap) data structure. |
55 |
|
|
5.2.4
by Gustav Hartvigsson
Finished documenting the SMap and SMapItem interfaces. |
56 |
/*
|
|
5.2.1
by Gustav Hartvigsson
Started work on the Map (SMap) data structure. |
57 |
* Common types of function pointers:
|
58 |
*/
|
|
59 |
||
60 |
||
|
5.2.4
by Gustav Hartvigsson
Finished documenting the SMap and SMapItem interfaces. |
61 |
/**
|
62 |
* Generic function.
|
|
|
22
by Gustav Hartvigsson
* Made code compile |
63 |
*
|
64 |
* It can take any type of function, with any signature
|
|
65 |
*/
|
|
66 |
typedef void (* FuncPointer)(void); |
|
67 |
||
68 |
/**
|
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
69 |
* A generic callback function.
|
|
22
by Gustav Hartvigsson
* Made code compile |
70 |
*
|
|
109.1.1
by Gustav Hartvigsson
* SMap seems to be broken... Or could it be SObject's Callback stuff? Or SLinkedList? |
71 |
* @param obj The object to perform the callback on.
|
72 |
* @param user_data The user data to be passed to the function.
|
|
|
22
by Gustav Hartvigsson
* Made code compile |
73 |
*/
|
|
109.1.1
by Gustav Hartvigsson
* SMap seems to be broken... Or could it be SObject's Callback stuff? Or SLinkedList? |
74 |
typedef spointer (* Callback)(spointer obj, spointer user_data); |
|
22
by Gustav Hartvigsson
* Made code compile |
75 |
|
76 |
/**
|
|
77 |
*
|
|
78 |
*/
|
|
|
30
by Gustav Hartvigsson
* Made the code compile using CMake. |
79 |
typedef void (* FreeFunc)(spointer obj); |
80 |
||
|
89
by Gustav Hartvigsson
* Started working on Threads |
81 |
typedef spointer (* RunFunc)(spointer user_data); |
|
32
by Gustav Hartvigsson
* Added some compile options to the root CMakeLists.txt |
82 |
|
|
30
by Gustav Hartvigsson
* Made the code compile using CMake. |
83 |
/**
|
|
62
by Gustav Hartvigsson
* General documentation clean up. |
84 |
* @param obj The object that the function should be run on. Generally this
|
85 |
* should be ignored inside the function.
|
|
86 |
* @param item The item that the the function should act on. @newline
|
|
87 |
* This can be printing the data, erasing the it, modifying it,
|
|
88 |
* changing it or what ever.
|
|
89 |
* @param data The data that is passed to the _foreach () function. Often called
|
|
90 |
* the user data. Can also be used as an out parameter.
|
|
|
30
by Gustav Hartvigsson
* Made the code compile using CMake. |
91 |
*/
|
92 |
typedef void (* ForEachFunc)(spointer obj, spointer item, spointer data); |
|
|
22
by Gustav Hartvigsson
* Made code compile |
93 |
|
|
30
by Gustav Hartvigsson
* Made the code compile using CMake. |
94 |
|
|
5.2.4
by Gustav Hartvigsson
Finished documenting the SMap and SMapItem interfaces. |
95 |
/**
|
96 |
* A CompFunc represents a standard comparison function.
|
|
|
109.1.1
by Gustav Hartvigsson
* SMap seems to be broken... Or could it be SObject's Callback stuff? Or SLinkedList? |
97 |
*
|
|
5.2.4
by Gustav Hartvigsson
Finished documenting the SMap and SMapItem interfaces. |
98 |
* @param 1 object to compare
|
99 |
* @param 2 object to compare
|
|
|
109.1.1
by Gustav Hartvigsson
* SMap seems to be broken... Or could it be SObject's Callback stuff? Or SLinkedList? |
100 |
*
|
|
5.2.4
by Gustav Hartvigsson
Finished documenting the SMap and SMapItem interfaces. |
101 |
* compare parameter 1 with parameter 2.
|
102 |
*/
|
|
|
46
by Gustav Hartvigsson
* Renamed DynamicArray to SDynamicArray. |
103 |
typedef sboolean (* CompFunc)(void*, void*); |
|
5.2.1
by Gustav Hartvigsson
Started work on the Map (SMap) data structure. |
104 |
|
105 |
typedef char * (* CharFunc)(); |
|
106 |
||
|
46
by Gustav Hartvigsson
* Renamed DynamicArray to SDynamicArray. |
107 |
|
|
110
by Gustav Hartvigsson
* added S_ prifix to my macros. I should not be a scrub. |
108 |
S_END_DECLS
|