Line data Source code
1 : /* Copyright 2017 noseglasses <shinynoseglasses@gmail.com>
2 : *
3 : * This program is free software: you can redistribute it and/or modify
4 : * it under the terms of the GNU Lesser General Public License as published by
5 : * the Free Software Foundation, either version 3 of the License, or
6 : * (at your option) any later version.
7 : *
8 : * This program is distributed in the hope that it will be useful,
9 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 : * GNU Lesser General Public License for more details.
12 : *
13 : * You should have received a copy of the GNU Lesser General Public License
14 : * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 : */
16 :
17 : #include "detail/ppg_token_vtable_detail.h"
18 : #include "detail/ppg_token_detail.h"
19 : #include "detail/ppg_note_detail.h"
20 : #include "detail/ppg_chord_detail.h"
21 : #include "detail/ppg_cluster_detail.h"
22 :
23 868 : uintptr_t ppg_token_vtable_id_from_ptr(void *vtable_ptr)
24 : {
25 868 : if(vtable_ptr == &ppg_token_vtable) {
26 18 : return 1;
27 : }
28 850 : if(vtable_ptr == &ppg_note_vtable) {
29 826 : return 2;
30 : }
31 24 : if(vtable_ptr == &ppg_chord_vtable) {
32 12 : return 3;
33 : }
34 12 : if(vtable_ptr == &ppg_cluster_vtable) {
35 12 : return 4;
36 : }
37 :
38 0 : return 0;
39 : }
40 :
41 434 : void *ppg_token_vtable_ptr_from_id(uintptr_t id)
42 : {
43 434 : switch(id) {
44 : case 1:
45 9 : return &ppg_token_vtable;
46 : break;
47 : case 2:
48 413 : return &ppg_note_vtable;
49 : break;
50 : case 3:
51 6 : return &ppg_chord_vtable;
52 : break;
53 : case 4:
54 6 : return &ppg_cluster_vtable;
55 : break;
56 : }
57 :
58 0 : return NULL;
59 : }
|