| 12-24-2011, 01:18 PM | #1 | |
Do you think jasshelper should have C preprocessor? EDIT: I uploaded experimental version with C prepreprocessor, try it and vote. Quote:
|
| 12-26-2011, 10:28 AM | #2 |
I've voted yes, because actual text macros are not only really limited, it's also fugly to use. Not to mention that hooks are most of time useless in the current state. And finally i've always found the use of static ifs not enough clear with the actual syntax (i mean the syntax difference between static ifs and classic ifs is not enough) But public resources shoudn't use bigdef for a native function define. Btw, is it possible to define a native function instead of using it like vJass textmacros ? EDIT : Ok, just tested and you can. A pretty new toy to play with it, i would say : Why bigdef and just not def, or define btw ? EDIT 2 : Oh wait, i was trying to define RemoveUnit for my Personnal Unit Indexer, but sadly it defines also GroupRemoveUnit, and i suppose anything which have RemoveUnit in its name :/ I'm also wondering if it defines strings "" (can't test it right now). EDIT 3 : bigdefs are considered even in comments block (/* */), plus i tends to add line breaks and make a new line with the last character (usually a ")" ) and then make the jass script invalid. So if you plan to let them in the current state, you should just remove them instead. Ofc you are welcome to improve them, if you're willing to it. |
| 12-30-2011, 12:53 PM | #3 |
#bigdef is for multi-line macros. #define is for one-line macros. It seems all your problems can be simply solved by reading the manual. |
| 01-04-2012, 05:30 AM | #4 |
Humm, maybe it is just the new year thing but it seems there are not enough people to even make a decent poll. (or not enough people willing to learn something new) Anyways I will probably put a turn on/off option (default off) for C preprocessor in jasshelper menu bar since it does not seems it is gonna be uber-mega-popular. (which is a shame considering how easy it is to use) |
| 01-04-2012, 11:32 AM | #5 |
I would find #define to be useful, but not the others. Perhaps also #foreach, to replace short loops with something more efficient. But the other features seem (to me) either useless, or uglier alternatives to what exists. |
| 01-04-2012, 02:17 PM | #6 |
For some reasons i didn't saw the documentation, neither #define, my bad. Anyway, unless a space " " is a valid first character for a #define i fail to see how to define RemoveUnit, without breaking other functions such as GroupRemoveUnit. Or maybe defines will work as intented without the need of a space, i can't test it now. Same for this : Code:
/*
#define ...
#endfine
*/I can't even use the tool in command line before jasshelper to remove comments, since it will also remove all external commands (//!...) Also, i have not tried yet but i'm stll wondering if strings "..." are affected by the defines. And also not tested, but i suppose you handle requirements (library A requires B, scopes, ...) before doing any defines, else that wouldn't work that much. Anyway thx for this and jasshelper, i had almost no interest in wc3 modding but you gave me some. |
| 01-06-2012, 05:39 AM | #7 | ||||||
Quote:
Most parts of macro preprocessor have already been implemented by vexorian, the problem is they do not all look like preprocessor constructs.
The last three clearly do not look like preprocessing statements but rather like jass extensions. This kind of programming stile is misleading. As for comments on the estetics of this stuff vs C preprocessor directives, I think that should have to wait for someone to make proper color coding for #statements. Quote:
Here is a tip for your particular problem: Make a macro for GroupRemoveUnit before you make a macro for RemoveUnit. Quote:
Removing comments has been disabled so preprocessor would not destroy old external commands and textmacros. Compatibility ftw. Quote:
There is an option to turn it off but I see no reason for it. Quote:
That way you can do things like this: JASS:ifdef PUI library mylib uses PUI elif Autoindex library mylib uses Autoindex else error "mylib needs at least one indexing system" endif but than again it does not error if you have both libraries at the same time or if you don't have either. Quote:
|
| 01-06-2012, 10:55 AM | #8 | |||||
Quote:
JASS://=========================================================================== // // Encore une carte Warcraft III // // Warcraft III map script // Generated by the Warcraft III World Editor // Date: Fri Jan 06 12:38:19 2012 // Map Author: Inconnu // //=========================================================================== //*************************************************************************** //* //* Global Variables //* //*************************************************************************** globals // Generated trigger gg_trg_Initialisation_m__l__e = null endglobals function InitGlobals takes nothing returns nothing endfunction //*************************************************************************** //* //* Triggers //* //*************************************************************************** //=========================================================================== // Trigger: Initialisation mêlée // // Initialisation mêlée par défaut pour tous les joueurs //=========================================================================== //TESH.scrollpos=2 //TESH.alwaysfold=0 scope A initializer init function RemoveUnitEx takes unit u returns nothing call RemoveUnit(u) call DoNothing() endfunction function GroupRemoveUnitBJ takes group g, unit u returns nothing call GroupRemoveUnit(g,u) call DoNothing() endfunction define GroupRemoveUnit(g,u) GroupRemoveUnitBJ(g,u) define RemoveUnit(u) RemoveUnitEx(u) private function init takes nothing returns nothing local integer i = 0 call RemoveUnit(null) call GroupRemoveUnit(null,null) endfunction endscope//=========================================================================== function InitCustomTriggers takes nothing returns nothing call InitTrig_Initialisation_m__l__e( ) endfunction //=========================================================================== function RunInitializationTriggers takes nothing returns nothing call ConditionalTriggerExecute( gg_trg_Initialisation_m__l__e ) endfunction //*************************************************************************** //* //* Players //* //*************************************************************************** function InitCustomPlayerSlots takes nothing returns nothing // Player 0 call SetPlayerStartLocation( Player(0), 0 ) call SetPlayerColor( Player(0), ConvertPlayerColor(0) ) call SetPlayerRacePreference( Player(0), RACE_PREF_HUMAN ) call SetPlayerRaceSelectable( Player(0), true ) call SetPlayerController( Player(0), MAP_CONTROL_USER ) endfunction function InitCustomTeams takes nothing returns nothing // Force: TRIGSTR_002 call SetPlayerTeam( Player(0), 0 ) endfunction //*************************************************************************** //* //* Main Initialization //* //*************************************************************************** //=========================================================================== function main takes nothing returns nothing call SetCameraBounds( -1280.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), -1536.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM), 1280.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), 1024.0 - GetCameraMargin(CAMERA_MARGIN_TOP), -1280.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), 1024.0 - GetCameraMargin(CAMERA_MARGIN_TOP), 1280.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), -1536.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM) ) call SetDayNightModels( "Environment\\DNC\\DNCLordaeron\\DNCLordaeronTerrain\\DNCLordaeronTerrain.mdl", "Environment\\DNC\\DNCLordaeron\\DNCLordaeronUnit\\DNCLordaeronUnit.mdl" ) call NewSoundEnvironment( "Default" ) call SetAmbientDaySound( "LordaeronSummerDay" ) call SetAmbientNightSound( "LordaeronSummerNight" ) call SetMapMusic( "Music", true, 0 ) call InitBlizzard( ) call InitGlobals( ) call InitCustomTriggers( ) call RunInitializationTriggers( ) endfunction //*************************************************************************** //* //* Map Configuration //* //*************************************************************************** function config takes nothing returns nothing call SetMapName( "Encore une carte Warcraft III" ) call SetMapDescription( "Sans description" ) call SetPlayers( 1 ) call SetTeams( 1 ) call SetGamePlacement( MAP_PLACEMENT_USE_MAP_SETTINGS ) call DefineStartLocation( 0, 832.0, 128.0 ) // Player setup call InitCustomPlayerSlots( ) call SetPlayerSlotAvailable( Player(0), MAP_CONTROL_USER ) call InitGenericPlayerSlots( ) endfunction compiles to : JASS:globals // Generated trigger gg_trg_Initialisation_m__l__e= null //JASSHelper struct globals: endglobals //=========================================================================== // // Encore une carte Warcraft III // // Warcraft III map script // Generated by the Warcraft III World Editor // Date: Fri Jan 06 12:38:19 2012 // Map Author: Inconnu // //=========================================================================== //*************************************************************************** //* //* Global Variables //* //*************************************************************************** function InitGlobals takes nothing returns nothing endfunction //*************************************************************************** //* //* Triggers //* //*************************************************************************** //=========================================================================== // Trigger: Initialisation mêlée // // Initialisation mêlée par défaut pour tous les joueurs //=========================================================================== //TESH.scrollpos=2 //TESH.alwaysfold=0 // scope A begins function RemoveUnitEx takes unit u returns nothing call RemoveUnit(u) call DoNothing() endfunction function GroupRemoveUnitBJ takes group g,unit u returns nothing call GroupRemoveUnit(g, u) call DoNothing() endfunction function A__init takes nothing returns nothing local integer i= 0 call RemoveUnitEx(null) call GronullpRemoveUnitBJ(null , null) endfunction // scope A ends function InitCustomTriggers takes nothing returns nothing //Function not found: call InitTrig_Initialisation_m__l__e() endfunction //=========================================================================== function RunInitializationTriggers takes nothing returns nothing call ConditionalTriggerExecute(gg_trg_Initialisation_m__l__e) endfunction //*************************************************************************** //* //* Players //* //*************************************************************************** function InitCustomPlayerSlots takes nothing returns nothing // Player 0 call SetPlayerStartLocation(Player(0), 0) call SetPlayerColor(Player(0), ConvertPlayerColor(0)) call SetPlayerRacePreference(Player(0), RACE_PREF_HUMAN) call SetPlayerRaceSelectable(Player(0), true) call SetPlayerController(Player(0), MAP_CONTROL_USER) endfunction function InitCustomTeams takes nothing returns nothing // Force: TRIGSTR_002 call SetPlayerTeam(Player(0), 0) endfunction //*************************************************************************** //* //* Main Initialization //* //*************************************************************************** //=========================================================================== function main takes nothing returns nothing call SetCameraBounds(- 1280.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), - 1536.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM), 1280.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), 1024.0 - GetCameraMargin(CAMERA_MARGIN_TOP), - 1280.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), 1024.0 - GetCameraMargin(CAMERA_MARGIN_TOP), 1280.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), - 1536.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM)) call SetDayNightModels("Environment\\DNC\\DNCLordaeron\\DNCLordaeronTerrain\\DNCLordaeronTerrain.mdl", "Environment\\DNC\\DNCLordaeron\\DNCLordaeronUnit\\DNCLordaeronUnit.mdl") call NewSoundEnvironment("Default") call SetAmbientDaySound("LordaeronSummerDay") call SetAmbientNightSound("LordaeronSummerNight") call SetMapMusic("Music", true, 0) call InitBlizzard() call A__init() call InitGlobals() call InitCustomTriggers() call RunInitializationTriggers() endfunction //*************************************************************************** //* //* Map Configuration //* //*************************************************************************** function config takes nothing returns nothing call SetMapName("Encore une carte Warcraft III") call SetMapDescription("Sans description") call SetPlayers(1) call SetTeams(1) call SetGamePlacement(MAP_PLACEMENT_USE_MAP_SETTINGS) call DefineStartLocation(0, 832.0, 128.0) // Player setup call InitCustomPlayerSlots() call SetPlayerSlotAvailable(Player(0), MAP_CONTROL_USER) call InitGenericPlayerSlots() endfunction //Struct method generated initializers/callers: I've also tried to use GroupRemoveUnit instead of that awesome BJ created by myself : same result. Or i'm missing something ? Quote:
What i mean is that it doesn't make sense that preprocessors are evaluated if they are commented, they should be disabled. Quote:
Leave a tag option in the file jasshelper.conf wouldn't hurt. Quote:
Well, the real problem is that the wc3 editor doesn't handle really well relative trigger order So requirements are a must, and also despite some people says, really most of the time scripting inside the editor is the only way to go (preplaced units, object editor stuff, ...) It breaks the concepts of vJass requirements, which is not a plus here. Now, if it is just too much and/or will make the compile time much longer, i think you should just leave this stuff. Quote:
You have no idea of what you did. |
| 01-06-2012, 01:38 PM | #9 |
Preprocessor directives exist before everything else, even comments. Therefore putting them inside multiline comments /* */ will not work To disable a preprocesor directive use single line comment before directive //# JASS:call GronullpRemoveUnitBJ(null , null) // u -> null "u" is obviously a very bad name :) Try something like UNIT |
| 01-06-2012, 03:25 PM | #10 | |
I still don't get how the jass code is generated in my example, for me it's a bug. But well, i've changed the macro param name and it works. Too bad we can't define a function to itself and make a wrapper of it instead, sure it will be inlined but meh ... This preprocessor is far more powerfull than what we already have in jasshelper, but i wouldn't say : Quote:
Actually it is not, and quite tricky. Also considering that most of the stuff you allow shouldn't be used in a public ressource, i repeat myself, this preprocessor should be removed, even if i've voted yes in the first place. |
| 01-06-2012, 03:39 PM | #11 |
Well it is easy to use to me, but I guess that is because I know C programming, so I don't really count. That is it I guess. C preprocessor will be removed because:
It would have been a great thing if it was inserted at the beginning of jasshelper development, but now it is a bit late for it. Next jasshelper version will have no C preprocessor. |
