wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



View Poll Results: Do you think jasshelper should have C preprocessor?
Yes 2 33.33%
No 3 50.00%
Wtf is C preprocessor? 1 16.67%
Voters: 6. You may not vote on this poll

Reply
 
Thread Tools Search this Thread
Old 12-24-2011, 02:18 PM   #1
cohadar
master of fugue
 
cohadar's Avatar
 
Join Date: Jun 2007
Posts: 2,453

Submissions (5)

cohadar is just really nice (250)cohadar is just really nice (250)cohadar is just really nice (250)cohadar is just really nice (250)cohadar is just really nice (250)

Default C preprocessor in jasshelper

Do you think jasshelper should have C preprocessor?

EDIT:
I uploaded experimental version with C prepreprocessor, try it and vote.

Quote:
#include
#define
#if
#elif
#ifdef
#ifndef
#else
#endif
#undef
#foreach
#endforeach
#bigdef
#endbigdef
#error
#warning
#comment
__________________
Omg database crash deleted my signature, as a side effect this immensely improved wc3c.

Last edited by cohadar : 12-25-2011 at 10:33 AM.
cohadar is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 12-26-2011, 11:28 AM   #2
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

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.
__________________
Cool != Useful

Last edited by Troll-Brain : 12-28-2011 at 07:18 PM.
Troll-Brain is offline   Reply With Quote
Old 12-30-2011, 01:53 PM   #3
cohadar
master of fugue
 
cohadar's Avatar
 
Join Date: Jun 2007
Posts: 2,453

Submissions (5)

cohadar is just really nice (250)cohadar is just really nice (250)cohadar is just really nice (250)cohadar is just really nice (250)cohadar is just really nice (250)

Default

#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.
__________________
Omg database crash deleted my signature, as a side effect this immensely improved wc3c.
cohadar is offline   Reply With Quote
Old 01-04-2012, 06:30 AM   #4
cohadar
master of fugue
 
cohadar's Avatar
 
Join Date: Jun 2007
Posts: 2,453

Submissions (5)

cohadar is just really nice (250)cohadar is just really nice (250)cohadar is just really nice (250)cohadar is just really nice (250)cohadar is just really nice (250)

Default

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)
__________________
Omg database crash deleted my signature, as a side effect this immensely improved wc3c.
cohadar is offline   Reply With Quote
Old 01-04-2012, 12:32 PM   #5
0zyx0
Perfectionist noob
 
0zyx0's Avatar
 
Join Date: Mar 2009
Posts: 255

0zyx0 will become famous soon enough (38)0zyx0 will become famous soon enough (38)

Default

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.
__________________
My new signature - Now easier to understand than ever!
0zyx0 is offline   Reply With Quote
Old 01-04-2012, 03:17 PM   #6
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

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.
__________________
Cool != Useful

Last edited by Troll-Brain : 01-04-2012 at 03:25 PM.
Troll-Brain is offline   Reply With Quote
Old 01-06-2012, 06:39 AM   #7
cohadar
master of fugue
 
cohadar's Avatar
 
Join Date: Jun 2007
Posts: 2,453

Submissions (5)

cohadar is just really nice (250)cohadar is just really nice (250)cohadar is just really nice (250)cohadar is just really nice (250)cohadar is just really nice (250)

Default

Quote:
Originally Posted by 0zyx0
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.

Most parts of macro preprocessor have already been implemented by vexorian,
the problem is they do not all look like preprocessor constructs.
  • //! include
  • //! external
  • //! textmacro
  • optional
  • static if
  • module

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:
Originally Posted by Troll-Brain
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.
It takes some time for people to learn how to use C preprocessing properly.
Here is a tip for your particular problem:
Make a macro for GroupRemoveUnit before you make a macro for RemoveUnit.

Quote:
Originally Posted by Troll-Brain
I can't even use the tool in command line before jasshelper to remove comments, since it will also remove all external commands (//!...)
You got that the wrong way.
Removing comments has been disabled so preprocessor would not destroy old external commands and textmacros. Compatibility ftw.

Quote:
Originally Posted by Troll-Brain
Also, i have not tried yet but i'm stll wondering if strings "..." are affected by the defines.
Yes they are.
There is an option to turn it off but I see no reason for it.

Quote:
Originally Posted by Troll-Brain
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.
No, C preprocessing happens before EVERYTHING else.
That way you can do things like this:
Collapse JASS:
ifdef PUI
library mylib uses PUI
elif Autoindex
library mylib uses Autoindex
else
  error "mylib needs at least one indexing system"
endif
Of course optional keyword does the same in one line,
but than again it does not error if you have both libraries at the same time
or if you don't have either.

Quote:
Originally Posted by Troll-Brain
Anyway thx for this and jasshelper, i had almost no interest in wc3 modding but you gave me some.
:evil_laughter:
__________________
Omg database crash deleted my signature, as a side effect this immensely improved wc3c.
cohadar is offline   Reply With Quote
Old 01-06-2012, 11:55 AM   #8
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

Quote:
Originally Posted by cohadar
It takes some time for people to learn how to use C preprocessing properly.
Here is a tip for your particular problem:
Make a macro for GroupRemoveUnit before you make a macro for RemoveUnit.

Expand JASS:

compiles to :

Expand JASS:

I've also tried to use GroupRemoveUnit instead of that awesome BJ created by myself : same result.
Or i'm missing something ?

Quote:
You got that the wrong way.
Removing comments has been disabled so preprocessor would not destroy old external commands and textmacros. Compatibility ftw.

What i mean is that it doesn't make sense that preprocessors are evaluated if they are commented, they should be disabled.

Quote:
Yes they are.
There is an option to turn it off but I see no reason for it.

Leave a tag option in the file jasshelper.conf wouldn't hurt.

Quote:
No, C preprocessing happens before EVERYTHING else.
That way you can do things like this:
Collapse JASS:
ifdef PUI
library mylib uses PUI
elif Autoindex
library mylib uses Autoindex
else
  error "mylib needs at least one indexing system"
endif
Of course optional keyword does the same in one line,
but than again it does not error if you have both libraries at the same time
or if you don't have either.

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:
:evil_laughter:

You have no idea of what you did.
__________________
Cool != Useful

Last edited by Troll-Brain : 01-06-2012 at 12:12 PM.
Troll-Brain is offline   Reply With Quote
Old 01-06-2012, 02:38 PM   #9
cohadar
master of fugue
 
cohadar's Avatar
 
Join Date: Jun 2007
Posts: 2,453

Submissions (5)

cohadar is just really nice (250)cohadar is just really nice (250)cohadar is just really nice (250)cohadar is just really nice (250)cohadar is just really nice (250)

Default

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 //#

Collapse JASS:
 call GronullpRemoveUnitBJ(null , null) // u -> null
Give longer argument names for macro params and make sure they don't appear as part of other macro names.
"u" is obviously a very bad name :)
Try something like UNIT
__________________
Omg database crash deleted my signature, as a side effect this immensely improved wc3c.

Last edited by cohadar : 01-06-2012 at 03:01 PM.
cohadar is offline   Reply With Quote
Old 01-06-2012, 04:25 PM   #10
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

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:
which is a shame considering how easy it is to use

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.
__________________
Cool != Useful

Last edited by Troll-Brain : 01-06-2012 at 04:26 PM.
Troll-Brain is offline   Reply With Quote
Old 01-06-2012, 04:39 PM   #11
cohadar
master of fugue
 
cohadar's Avatar
 
Join Date: Jun 2007
Posts: 2,453

Submissions (5)

cohadar is just really nice (250)cohadar is just really nice (250)cohadar is just really nice (250)cohadar is just really nice (250)cohadar is just really nice (250)

Default

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 is too complicated to use for average mapper
  • most of it's functionality is already implemented in different ways
  • It slows down compilation even if you don't use it

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.
__________________
Omg database crash deleted my signature, as a side effect this immensely improved wc3c.
cohadar is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 02:39 PM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services