|
|
@ -2,16 +2,19 @@ |
|
|
|
|
|
|
|
@{ |
|
|
|
|
|
|
|
// allows you to retrieve the type if it is pre-existing or created during compilation |
|
|
|
checkIdorDecl(x) { |
|
|
|
(x.identifier == null) ? x.declarators.identifier : x.identifier; |
|
|
|
} |
|
|
|
|
|
|
|
// allows you to retrieve the type if it is pre-existing or created during compilation |
|
|
|
checkIdorText(x) { |
|
|
|
(x.identifier == null) ? x.text : x.identifier; |
|
|
|
} |
|
|
|
|
|
|
|
program.objects = null; |
|
|
|
|
|
|
|
// Initialisation of the object |
|
|
|
beginObject(objectName, typeName) { |
|
|
|
program.objects = {}; |
|
|
|
program.objects.elements = {}; |
|
|
@ -31,11 +34,12 @@ |
|
|
|
append(l, treeCopy(obj)); |
|
|
|
type_obj = `declaration typedef union object *oop;; |
|
|
|
type_obj.declarators[0].declarators.identifier = objectName; |
|
|
|
type_obj.semicolon.comment = getComment(" "); |
|
|
|
type_obj.semicolon.comment = getComment("\n\n"); |
|
|
|
append(l, treeCopy(type_obj)); |
|
|
|
l; |
|
|
|
} |
|
|
|
|
|
|
|
// Function to add dynamically an object |
|
|
|
addObject() { |
|
|
|
structName = treeCopy(getEnum(program.last.name.identifier)); |
|
|
|
l = length(program.enums.last.enumList); |
|
|
@ -55,21 +59,26 @@ |
|
|
|
nil; |
|
|
|
} |
|
|
|
|
|
|
|
// Function triggered each time we met a struct |
|
|
|
everyExternalDeclaration(s) { |
|
|
|
if (program.objects) { |
|
|
|
addObject() |
|
|
|
} |
|
|
|
s; |
|
|
|
} |
|
|
|
|
|
|
|
// Functions to get the macro |
|
|
|
getObjectMacro() { |
|
|
|
macro = `ed #define get(PTR, TYPE, FIELD) (_checkType(PTR, TYPE, __FILE__, __LINE__)->TYPE.FIELD) |
|
|
|
; |
|
|
|
macro; |
|
|
|
} |
|
|
|
|
|
|
|
// Functions to get the macro |
|
|
|
setObjectMacro() { |
|
|
|
macro = `ed #define set(PTR, TYPE, FIELD, VALUE) (_checkType(PTR, TYPE, __FILE__, __LINE__)->TYPE.FIELD = VALUE) |
|
|
|
; |
|
|
|
macro.text = macro.text + "\n"; |
|
|
|
macro; |
|
|
|
} |
|
|
|
|
|
|
@ -102,9 +111,11 @@ |
|
|
|
treeCopy(func); |
|
|
|
} |
|
|
|
|
|
|
|
// Function to set up element useful to the programmer |
|
|
|
endObject() { |
|
|
|
l = {}; |
|
|
|
objectUnion = `declaration union object { int type; };; |
|
|
|
objectUnion = treeCopy(objectUnion); |
|
|
|
objectUnion.specifiers[0].declarationL[0].specifiers[0].text = program.objects.enum.declarators[0].identifier; |
|
|
|
objectUnion.semicolon.comment = getComment("\n"); |
|
|
|
obj = select(notToken, program.objects.enum.specifiers[1].enumList); |
|
|
|