Debian Codegraph @

texk/web2c/mfluadir/otfcc/lib/table/otl/otl.c

raw
1 #include "private.h"
2
3 #define DELETE_TYPE(type, fn) \
4 case type: \
5 ((void (*)(otl_Subtable *))fn)(*subtableRef); \
6 break;
7
8 static INLINE void disposeSubtableDependent(MODIFY otl_SubtablePtr *subtableRef,
9 const otl_Lookup *lookup) {
10 switch (lookup->type) {
11 DELETE_TYPE(otl_type_gsub_single, iSubtable_gsub_single.free);
12 DELETE_TYPE(otl_type_gsub_multiple, iSubtable_gsub_multi.free);
13 DELETE_TYPE(otl_type_gsub_alternate, iSubtable_gsub_multi.free);
14 DELETE_TYPE(otl_type_gsub_ligature, iSubtable_gsub_ligature.free);
15 DELETE_TYPE(otl_type_gsub_chaining, iSubtable_chaining.free);
16 DELETE_TYPE(otl_type_gsub_reverse, iSubtable_gsub_reverse.free);
17 DELETE_TYPE(otl_type_gpos_single, iSubtable_gpos_single.free);
18 DELETE_TYPE(otl_type_gpos_pair, iSubtable_gpos_pair.free);
19 DELETE_TYPE(otl_type_gpos_cursive, iSubtable_gpos_cursive.free);
20 DELETE_TYPE(otl_type_gpos_chaining, iSubtable_chaining.free);
21 DELETE_TYPE(otl_type_gpos_markToBase, iSubtable_gpos_markToSingle.free);
22 DELETE_TYPE(otl_type_gpos_markToMark, iSubtable_gpos_markToSingle.free);
23 DELETE_TYPE(otl_type_gpos_markToLigature, iSubtable_gpos_markToLigature.free);
24 default:;
25 }
26 }
27 static caryll_ElementInterface(otl_SubtablePtr) otl_iSubtablePtr = {
28 .init = NULL, .copy = NULL, .dispose = NULL,
29 };
30 caryll_VectorImplFreeDependent(otl_SubtableList, otl_SubtablePtr, otl_Lookup,
31 disposeSubtableDependent);
32 caryll_VectorImplFunctions(otl_SubtableList, otl_SubtablePtr, otl_iSubtablePtr);
33 caryll_VectorInterfaceTypeName(otl_SubtableList) otl_iSubtableList = {
34 caryll_VectorImplAssignments(otl_SubtableList, otl_SubtablePtr, otl_iSubtablePtr),
35 .disposeDependent = otl_SubtableList_disposeDependent,
36 };
37
38 void otfcc_delete_lookup(otl_Lookup *lookup) {
39 if (!lookup) return;
40 otl_iSubtableList.disposeDependent(&lookup->subtables, lookup);
41 sdsfree(lookup->name);
42 FREE(lookup);
43 }
44
45 // LOOKUP
46 static INLINE void initLookupPtr(otl_LookupPtr *entry) {
47 NEW(*entry);
48 (*entry)->name = NULL;
49 otl_iSubtableList.init(&(*entry)->subtables);
50 }
51 static INLINE void disposeLookupPtr(otl_LookupPtr *entry) {
52 otfcc_delete_lookup(*entry);
53 }
54 caryll_standardType(otl_LookupPtr, otl_iLookupPtr, initLookupPtr, disposeLookupPtr);
55 caryll_standardVectorImpl(otl_LookupList, otl_LookupPtr, otl_iLookupPtr, otl_iLookupList);
56 caryll_standardType(otl_LookupRef, otl_iLookupRef);
57 caryll_standardVectorImpl(otl_LookupRefList, otl_LookupRef, otl_iLookupRef, otl_iLookupRefList);
58
59 // FEATURE
60 static INLINE void initFeaturePtr(otl_FeaturePtr *feature) {
61 NEW(*feature);
62 otl_iLookupRefList.init(&(*feature)->lookups);
63 }
64 static INLINE void disposeFeaturePtr(otl_FeaturePtr *feature) {
65 if (!*feature) return;
66 if ((*feature)->name) sdsfree((*feature)->name);
67 otl_iLookupRefList.dispose(&(*feature)->lookups);
68 FREE(*feature);
69 }
70 caryll_standardType(otl_FeaturePtr, otl_iFeaturePtr, initFeaturePtr, disposeFeaturePtr);
71 caryll_standardVectorImpl(otl_FeatureList, otl_FeaturePtr, otl_iFeaturePtr, otl_iFeatureList);
72 caryll_standardType(otl_FeatureRef, otl_iFeatureRef);
73 caryll_standardVectorImpl(otl_FeatureRefList, otl_FeatureRef, otl_iFeatureRef, otl_iFeatureRefList);
74
75 // LANGUAGE
76 static INLINE void initLanguagePtr(otl_LanguageSystemPtr *language) {
77 NEW(*language);
78 otl_iFeatureRefList.init(&(*language)->features);
79 }
80 static INLINE void disposeLanguagePtr(otl_LanguageSystemPtr *language) {
81 if (!*language) return;
82 if ((*language)->name) sdsfree((*language)->name);
83 otl_iFeatureRefList.dispose(&(*language)->features);
84 FREE(*language);
85 }
86 caryll_ElementInterfaceOf(otl_LanguageSystemPtr) otl_iLanguageSystem = {
87 .init = initLanguagePtr, .dispose = disposeLanguagePtr,
88 };
89 caryll_standardVectorImpl(otl_LangSystemList, otl_LanguageSystemPtr, otl_iLanguageSystem,
90 otl_iLangSystemList);
91
92 // COMMON PART
93 static INLINE void initOTL(table_OTL *table) {
94 otl_iLookupList.init(&table->lookups);
95 otl_iFeatureList.init(&table->features);
96 otl_iLangSystemList.init(&table->languages);
97 }
98 static INLINE void disposeOTL(table_OTL *table) {
99 otl_iLookupList.dispose(&table->lookups);
100 otl_iFeatureList.dispose(&table->features);
101 otl_iLangSystemList.dispose(&table->languages);
102 }
103
104 caryll_standardRefType(table_OTL, table_iOTL, initOTL, disposeOTL);