BadVPN – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /**
2 * @file NCDModuleIndex.h
3 * @author Ambroz Bizjak <ambrop7@gmail.com>
4 *
5 * @section LICENSE
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of the author nor the
15 * names of its contributors may be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29  
30 #ifndef BADVPN_NCDMODULEINDEX_H
31 #define BADVPN_NCDMODULEINDEX_H
32  
33 #include <misc/debug.h>
34 #include <structure/BAVL.h>
35 #include <structure/CHash.h>
36 #include <structure/LinkedList0.h>
37 #include <structure/Vector.h>
38 #include <base/DebugObject.h>
39 #include <ncd/NCDStringIndex.h>
40 #include <ncd/NCDModule.h>
41 #include <ncd/NCDMethodIndex.h>
42  
43 #define NCDMODULEINDEX_MODULES_HASH_SIZE 512
44 #define NCDMODULEINDEX_FUNCTIONS_VEC_INITIAL_SIZE 32
45 #define NCDMODULEINDEX_FUNCTIONS_HASH_SIZE 64
46  
47 struct NCDModuleIndex_module {
48 struct NCDInterpModule imodule;
49 struct NCDModuleIndex_module *hash_next;
50 int method_id;
51 };
52  
53 #ifndef NDEBUG
54 struct NCDModuleIndex_base_type {
55 const char *base_type;
56 struct NCDModuleIndex_group *group;
57 BAVLNode base_types_tree_node;
58 };
59 #endif
60  
61 struct NCDModuleIndex_group {
62 LinkedList0Node groups_list_node;
63 struct NCDInterpModuleGroup igroup;
64 struct NCDModuleIndex_module modules[];
65 };
66  
67 struct NCDModuleIndex__Func {
68 struct NCDInterpFunction ifunc;
69 int hash_next;
70 };
71  
72 typedef struct NCDModuleIndex_module *NCDModuleIndex__mhash_link;
73 typedef const char *NCDModuleIndex__mhash_key;
74  
75 typedef struct NCDModuleIndex_s NCDModuleIndex;
76  
77 #include "NCDModuleIndex_mhash.h"
78 #include <structure/CHash_decl.h>
79  
80 #include "NCDModuleIndex_func_vec.h"
81 #include <structure/Vector_decl.h>
82  
83 #include "NCDModuleIndex_fhash.h"
84 #include <structure/CHash_decl.h>
85  
86 struct NCDModuleIndex_s {
87 NCDModuleIndex__MHash modules_hash;
88 #ifndef NDEBUG
89 BAVL base_types_tree;
90 #endif
91 LinkedList0 groups_list;
92 NCDMethodIndex method_index;
93 NCDModuleIndex__FuncVec func_vec;
94 NCDModuleIndex__FuncHash func_hash;
95 DebugObject d_obj;
96 };
97  
98 int NCDModuleIndex_Init (NCDModuleIndex *o, NCDStringIndex *string_index) WARN_UNUSED;
99 void NCDModuleIndex_Free (NCDModuleIndex *o);
100 int NCDModuleIndex_AddGroup (NCDModuleIndex *o, const struct NCDModuleGroup *group, const struct NCDModuleInst_iparams *iparams, NCDStringIndex *string_index) WARN_UNUSED;
101 const struct NCDInterpModule * NCDModuleIndex_FindModule (NCDModuleIndex *o, const char *type);
102 int NCDModuleIndex_GetMethodNameId (NCDModuleIndex *o, const char *method_name);
103 const struct NCDInterpModule * NCDModuleIndex_GetMethodModule (NCDModuleIndex *o, NCD_string_id_t obj_type, int method_name_id);
104 const struct NCDInterpFunction * NCDModuleIndex_FindFunction (NCDModuleIndex *o, NCD_string_id_t func_name_id);
105  
106 #endif