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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion addons/main/script_macros_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ Macro: MAP()
/* -------------------------------------------
Macro: FILTER()
Description:
Filters an array based on given code, then assigns the resulting array
Filters an array based on given code, then assigns the resulting array
to the original
Parameters:
ARRAY - Array to be filtered
Expand Down Expand Up @@ -796,6 +796,47 @@ 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
#undef 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

#else
#define RECOMPILE recompile = 0
#endif

/* -------------------------------------------
Macro: PATHTO_FNC()

Description:
Defines a function inside CfgFunctions.

Full file path in addons:
'\MAINPREFIX\PREFIX\SUBPREFIX\COMPONENT\fnc_<FNC>.sqf'
Define 'RECOMPILE' to enable recompiling.

Parameters:
FUNCTION NAME - Name of the function, unquoted <STRING>

Examples:
(begin example)
// file name: fnc_addPerFrameHandler.sqf
class CfgFunctions {
class CBA {
class Misc {
PATHTO_FNC(addPerFrameHandler);
};
};
};
// -> CBA_fnc_addPerFrameHandler
(end)

Author:
dixon13, commy2
------------------------------------------- */
#define PATHTO_FNC(func) class func {\
file = QPATHTOF(DOUBLES(fnc,func).sqf);\
RECOMPILE;\
}

#define FUNC(var1) TRIPLES(ADDON,fnc,var1)
#define FUNCMAIN(var1) TRIPLES(PREFIX,fnc,var1)
#define FUNC_INNER(var1,var2) TRIPLES(DOUBLES(PREFIX,var1),fnc,var2)
Expand Down
9 changes: 7 additions & 2 deletions addons/main/script_macros_mission.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
#define PATHTOF2_SYS(var1,var2,var3) ##var1\##var2\##var3
#endif


/************************** REMOVAL OF MACROS ***********************/

#undef MAINPREFIX
Expand All @@ -74,4 +73,10 @@
#undef XEH_PRE_SINIT
#undef XEH_POST_INIT
#undef XEH_POST_CINIT
#undef XEH_POST_SINIT
#undef XEH_POST_SINIT

#undef PATHTO_FNC
#define PATHTO_FNC(func) class func {\
file = QUOTE(DOUBLES(fnc,func).sqf);\
RECOMPILE;\
}
6 changes: 3 additions & 3 deletions tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ def main():
failed = 0
skipped = 0
removed = 0

for file in os.listdir(addonspath):
if os.path.isfile(file):
if check_for_obsolete_pbos(addonspath, file):
removed += 1
print(" Removing obsolete file => " + file)
os.remove(file)
print("")
print("")

for p in os.listdir(addonspath):
path = os.path.join(addonspath, p)
if not os.path.isdir(path):
Expand Down