Open BrettMayson opened 4 years ago
#define QUOTE(var1) #var1
#define B(x) {x}
#define C ({1})
class CfgPatches {
class q {
t = QUOTE(B(C); call f);
};
};
output:
class CfgPatches
{
class q
{
t = "{({1})}; call f";
};
};
#define QUOTE(var1) #var1
#define ARR_2(ARG1,ARG2) ARG1, ARG2
#define DOUBLES(var1,var2) var1##_##var2
#define TRIPLES(var1,var2,var3) var1##_##var2##_##var3
#define ADDON test
#define DFUNC(var1) TRIPLES(ADDON,fnc,var1)
#define GVAR(var1) DOUBLES(ADDON,var1)
#define QGVAR(var1) QUOTE(GVAR(var1))
#define QQGVAR(var1) QUOTE(QGVAR(var1))
#define GET_NUMBER(config,default) (if (isNumber (config)) then {getNumber (config)} else {default})
#define GET_NUMBER_GREATER_ZERO(config,default) (if (0 < getNumber (config)) then {getNumber (config)} else {default})
#define DEFAULT_FUELCARGO \
GET_NUMBER(\
configFile >> 'CfgVehicles' >> typeOf _this >> QQGVAR(fuelCargo),\
GET_NUMBER_GREATER_ZERO(configFile >> 'CfgVehicles' >> typeOf _this >> 'transportFuel',-1)\
)
class CfgPatches {
class q {
expression = QUOTE(if (_value != DEFAULT_FUELCARGO) then {[ARR_2(_this,_value)] call DFUNC(makeSource)});
};
};
output:
class CfgPatches
{
class q
{
expression = "if (_value != (if (isNumber (configFile >> 'CfgVehicles' >> typeOf _this >> ""test_fuelCargo"")) then {getNumber (configFile >> 'CfgVehicles' >> typeOf _this >> ""test_fuelCargo"")} else {(if (0 < getNumber (configFile >> 'CfgVehicles' >> typeOf _this >> 'transportFuel')) then {getNumber (configFile >> 'CfgVehicles' >> typeOf _this >> 'transportFuel')} else {-1})})) then {[_this,_value] call test_fnc_makeSource}";
};
};
Don't know if you still need it but here you go:
#define PREFIX rid
#define COMPONENT core
#define QUOTE(var1) #var1
#define DOUBLES(var1,var2) var1##_##var2
#define TRIPLES(var1,var2,var3) var1##_##var2##_##var3
#define ADDON DOUBLES(PREFIX,COMPONENT)
#define FUNC(var1) TRIPLES(ADDON,fnc,var1)
#define FUNC_INNER(var1,var2) TRIPLES(DOUBLES(PREFIX,var1),fnc,var2)
#define EFUNC(var1,var2) FUNC_INNER(var1,var2)
#define ARG_1(A,B) ((A) select (B))
#define ARR_2(ARG1,ARG2) ARG1, ARG2
#define ARR_3(ARG1,ARG2,ARG3) ARG1, ARG2, ARG3
class simple_thing
{
class EventHandlers
{
init = QUOTE([ARR_2(ARG_1(_this,0),{ARG_1(_this,0) setVariable[ARR_3('rid_core_isConnected',true,true)]})] call EFUNC(network,createNetworkNode);[_this select 0] call FUNC(createVibrationDetector));
};
};
Output:
class simple_thing
{
class EventHandlers
{
init="[((_this) select (0)), {((_this) select (0)) setVariable['rid_core_isConnected', true, true]}] call rid_network_fnc_createNetworkNode;[_this select 0] call rid_core_fnc_createVibrationDetector";
};
};
I am looking for some files to test the new preprocessor that is being made for HEMTT. I would like members of the Arma community to submit snippets of config files that would be good for me to test against. If you are providing a complex example, please include the correct output as well.