Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add macros 'PATHTO_FNC ' and 'RECOMPILE' #475

Merged
merged 7 commits into from
Aug 31, 2016

Conversation

shadez95
Copy link
Contributor

@shadez95 shadez95 commented Aug 21, 2016

When merged this pull request will:

  • Add the macros PATHTO_FNC and RECOMPILE
  • Argument for PATHTO_FNC is the name of a function that is located at \MAINPREFIX\PREFIX\SUBPREFIX\COMPONENT\ and the name of the file is fnc_func.sqf where 'func' is the name of you're function. func will be the argument for PATHTO_FNC
  • RECOMPILE does not accept an argument. If RECOMPILE is defined before including script_macros_common.hpp in you're component, then the functions defined with PATHTO_FNC will be recompiled at mission start. (For debug purposes)

These macros emulate the below...

class CfgFunctions {
    class func {
        file = "\MAINPREFIX\PREFIX\SUBPREFIX\COMPONENT\fnc_func.sqf";
        recompile = 0; //if RECOMPILE defined before including script_macros_common.hpp then recompile = 1
    };
};

The macro 'PATHTO_FNC ' can be found already in the components common and settings. Just making it official :)

Ignore the edits to build.py. I guess I removed some spaces or something but no edits to any of the code.

@@ -796,6 +796,17 @@ Macro: GVARMAIN()
#define PREPMAIN(var1) ['PATHTO_SYS(PREFIX,COMPONENT_F,DOUBLES(fnc,var1))', 'TRIPLES(PREFIX,fnc,var1)'] call SLX_XEH_COMPILE_NEW
#endif

#ifdef RECOMPILE
#define RECOMPILE recompile = 1
Copy link
Contributor

@commy2 commy2 Aug 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this work with Mikero's Tools? I think they error out now when trying to redefine a macro in config space.
At least when using make.py (binarizing)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add #undef to keep the macro parsers happy

@commy2
Copy link
Contributor

commy2 commented Aug 21, 2016

Would be cool if we could redefine it for script_macros_mission.hpp, so it doesn't use the addon space paths PATHTOF, but accesses the current mission folder.
(file = QUOTE(DOUBLES(fnc,func).sqf);\)

Also we might want to think about a potentially better name than F_FILEPATH if we make it API.

@jonpas
Copy link
Member

jonpas commented Aug 21, 2016

Ignore the edits to build.py. I guess I removed some spaces or something but no edits to any of the code.

Those edits are actually good, removing redundant whitespace. 👍 😆

@shadez95
Copy link
Contributor Author

How about FUNC_PATH or PATHTO_FUNC?

@commy2
Copy link
Contributor

commy2 commented Aug 22, 2016

PATHTO_FNC I'd say. It's similar enough to PATHTOF to remember and FNC matches the fnc_ tag of the files.

@commy2 commy2 added this to the 3.0.1 milestone Aug 22, 2016
@commy2 commy2 self-assigned this Aug 22, 2016
@shadez95 shadez95 changed the title Add macros 'F_FILEPATH' and 'RECOMPILE' Add macros 'PATHTO_FNC ' and 'RECOMPILE' Aug 22, 2016
@shadez95
Copy link
Contributor Author

Done. Added variant of PATHTO_FNC to script_macros_mission.hpp to be used by mission makers.

@jonpas
Copy link
Member

jonpas commented Aug 23, 2016

If you want to emulate PATHTOF macro then shouldn't it be PATHTOFNC?

@shadez95
Copy link
Contributor Author

Personally I like PATHTO_FNC. It just seems more readable.

#undef RECOMPILE
#define RECOMPILE recompile = 1
#else
#undef RECOMPILE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If RECOMPILE already is undefined, you cannot undefine RECOMPILE. This might or might not error out with Mikeros Tools too.

Copy link
Contributor

@Killswitch00 Killswitch00 Aug 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, undef is only needed in the first case, where RECOMPILE is defined.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still needs action.

@commy2
Copy link
Contributor

commy2 commented Aug 23, 2016

@jonpas making it PATHTOFNC would make it sound too similar to PATHTOF. Keep in mind that the macro does not expand to the file path alone, but also creates the encasing class responsible for defining the function. It only works inside CfgFunctions, while PATHTOF is more of a general utility thing. (for example used here in PATHTO_FNC).

This reminds me. We should simplify QUOTE(PATHTOF( ... )) to QPATHTOF( ... ) inside this macro.

@shadez95
Copy link
Contributor Author

Macro header added for explanation.

@shadez95
Copy link
Contributor Author

This is done unless QUOTE(PATHTOF( ... )) is simplified to QPATHTOF( ... )

@jonpas
Copy link
Member

jonpas commented Aug 24, 2016

Yes it is, QPATHTOF() is the simplified version.

@shadez95
Copy link
Contributor Author

shadez95 commented Aug 24, 2016

Ah ok. Didn't realize it was a macro already. Utilizing QPATHOF() now instead of QUOTE() and PATHOF(). Done...

Do not '#undef RECOMPILE' if 'RECOMPILE' already undefined
@Killswitch00 Killswitch00 merged commit 0a63b53 into CBATeam:master Aug 31, 2016
@commy2 commy2 mentioned this pull request Sep 6, 2016
@marceldev89
Copy link

FYI, the RECOMPILE changes broke Mikero tools for ALiVE and probably others. We had to update all the CfgFunctions.hpp files. 😢

@commy2
Copy link
Contributor

commy2 commented Oct 21, 2016

Mikero's Tools can't handle macro redefinitions anymore. I guess you had a macro named RECOMPILE ?

@marceldev89
Copy link

Yes we have a global macro RECOMPILE set in script_mod.hpp. Changing all the recompile = RECOMPILE; occurrences to RECOMPILE; fixes the errors in the CfgFunctions.hpp files but then it errors out on the #define RECOMPILE 1 in script_mod.hpp with In File P:\x\alive\addons\main\script_mod.hpp: Line 61 #define altered without a #undef. Not sure how to go from there.

@marceldev89
Copy link

#ifdef RECOMPILE
    #undef RECOMPILE
#endif
#define RECOMPILE recompile = 1

In script_mod.hpp seems to "solve" it. Good enough I guess.

@commy2
Copy link
Contributor

commy2 commented Oct 21, 2016

Yeah. This is the only solution. No idea why this change was made. It's really stupid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants