J'ai un tas de fichiers IDL remplis d'enums. Je voudrais un moyen d'analyser les fichiers IDL, d'extraire les énumérations et de créer des énumérations Java natives basées sur celles-ci (en ignorant également toutes les autres déclarations de l'IDL, comme les consts, les unions ou les structures).Parse IDL enums vers Java Enums
Je ne sais même pas par où commencer. Existe-t-il de bons outils Linux conçus à cet effet? Je suppose que regex serait nécessaire?
Pour expliquer ce que je veux dire, voici un exemple dans 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
Je voudrais exécuter une commande ... comme:
converter common.idl -package com.myproject -outputDir src
et sur cracherait ces fichiers Java source avec 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
}
Est-ce possible?