I've got a bunch of IDL files filled with enums. I would like a way to parse the IDL files, extract out the enums and create native Java enums based on these (also ignoring any other declarations in the IDL, like consts, unions, or structs).
I'm not even sure where to start with this. Are there any good Linux tools designed for this purpose? I'm assuming regex would be needed?
To explain what I mean, here is an example in common.idl:
#ifndef __common_idl__
#define __common_idl__
module common_idl {
const short MAX_UNITS = 99;
const short MAX_SIZE = 15;
enum Bearing_Type {
North_Bearing,
South_Bearing,
No_Bearing
};
enum Bounds_Type {
Empty,
Full,
Above,
Between,
Below
};
enum Identity_Type {
Pending,
Unknown,
Assumed_Friend,
Friend
};
enum Status_Type {
No_Status,
To_Status,
To_Established,
From_Established
};
enum Emergency_Type {
Reported,
Confirmed,
None
};
struct Console_Marker {
boolean Marked;
};
typedef unsigned short Index_Type;
typedef long TQ_Type;
typedef unsigned short Count_Type;
typedef unsigned long Number_Of_Type;
typedef unsigned short Special_Index_Type;
typedef string<2> Code_Type;
};
#endif
I would like to run a command... such as:
converter common.idl -package com.myproject -outputDir src
and out would spit these source java files with enums:
src/com/myproject/Bearing_Type.java
package com.myproject;
public enum Bearing_Type {
North_Bearing,
South_Bearing,
No_Bearing
}
src/com/myproject/Bounds_Type.java
package com.myproject;
public enum Bounds_Type {
Empty,
Full,
Above,
Between,
Below
}
src/com/myproject/Emergency_Type.java
package com.myproject;
public enum Emergency_Type {
Reported,
Confirmed,
None
}
src/com/myproject/Identity_Type.java
package com.myproject;
public enum Identity_Type {
Pending,
Unknown,
Assumed_Friend,
Friend
}
src/com/myproject/Status_Type.java
package com.myproject;
public enum Status_Type {
No_Status,
To_Status,
To_Established,
From_Established
}
Is this feasible?