Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (M_D), 1,430 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Hide internal functions or modules #452140
06/03/15 14:52
06/03/15 14:52
Joined: Jun 2014
Posts: 5
Germany
N
nekokuruma Offline OP
Newbie
nekokuruma  Offline OP
Newbie
N

Joined: Jun 2014
Posts: 5
Germany
A Question for you as a user of a Lite-C library or framework.

Suppose the used library has got the modules Engine, Car and Helicopter in normal Header and Source file implementation.
Now Car and Helicopter uses Engine and calls Engine functions which should be defined in the header file because they are used by Car, Helicopter and maybe other vehicles (provided by the library) in future.
But the client which will use the Car module and Helicopter module should NOT use the Engine module.

Code:
Engine.h

struct {
    int rpm;
} Engine;

Engine_setRpm (Engine* this, int rpm);


--------------
Car.h

struct {
   . . .
   Engine* engine;
   int tireTemp;
} Car;

Car_accelerate(Car* this, int value);


--------------
Helicopter.h

struct {
   . . .
   Engine* engine;
   int altitude;
} Helicopter;

Helicopter_gotoAltitude(Helicopter* this, int value);




Now my question is what would you like to see in a library:

A) Function name which indicates that this function should never be used outside the library itself

Library_Engine_LibInternal_setRpm (Engine* this, int rpm);


B) leave the function name unchanged and add a comment

/*
Private
Do not use this function if you are a client of the framework and if you do not implement new features for the framework.
*/
Library_Engine_setRpm (Engine* this, int rpm);


C) Separate free to use by client modules and internal modules

vehicles/internal/engine.h
vehicles/helicopter.h
vehicles/car.h

Which maybe get a little messy over time when the library grows I suppose?



What are your methods to write/structure your code so that it is best protected by accidently using internal implementations which are not intended to use by client.
I am looking forward to hear how you implement your Lite-C Work or what you’d like to see in a Lite-C library considering the mentioned problem.

Last edited by nekokuruma; 06/03/15 14:53.
Re: Hide internal functions or modules [Re: nekokuruma] #452142
06/03/15 16:27
06/03/15 16:27
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline
User
Wjbender  Offline
User
W

Joined: Mar 2012
Posts: 927
cyberspace
if you need to code something ,and , you want to prevent your code from being visible and prevent needless cluttering , I suggest that you write a dll (plugin) , if you have a pro licence or a plugin licence ,in such cases you may redistribute the build dll and simply keep your source code private ,if you don't have any of these licences you may redistribute your dll but you must provide the source code along with it.

hence the only part of viewable code wil be function declarations and definitions in a .c/.h file to be included in a user's project ,along with the dll wich the engine will automatically load up .



Compulsive compiler
Re: Hide internal functions or modules [Re: Wjbender] #452143
06/03/15 17:08
06/03/15 17:08
Joined: Jun 2014
Posts: 5
Germany
N
nekokuruma Offline OP
Newbie
nekokuruma  Offline OP
Newbie
N

Joined: Jun 2014
Posts: 5
Germany
Hey thanks for the reply. I never programmed a dll before and just skimmed the wiki article.
Now I must decide which way I go the plain Lite-C way or the dll way.

As I read you have to do a little rewriting like (_VAR(_FLOAT(a)+_FLOAT(b)));
I do believe I will stay plain Lite-C wink (At least for the moment).

Re: Hide internal functions or modules [Re: nekokuruma] #452145
06/03/15 17:30
06/03/15 17:30
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline
User
Wjbender  Offline
User
W

Joined: Mar 2012
Posts: 927
cyberspace
yes , like imperial and metric conversion ,you have to convert (type cast) from engine types to c++ types and vice versa to successfully use values and types in c++ .

stick it out a little longer with lite-c if your new to c++ , once you have enough knowledge you could always try out doing a dll later .

good luck and welcome


Compulsive compiler

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1