On 18.3.2015 г. 23:15, Matthew Brush wrote:
Scope contains 20 source files and 22 headers. Using static is not an option, and marking everything global as hidden will be cumbersome, ugly, and easy to miss (inexperienced plugin developers are sure to miss symbols).
Why does it need so many globals? Shouldn't the only globals really be the stuff Geany requires? I'm wondering because one day it would be cool to able to do stuff like having multiple "instances" in-process and to allow a plugin per in-process "instance" or some stuff like this. With the additional userdata pointer, in theory one could make a big huge structure containing all their global (instance) state and have that passed around, and then there's less issue with symbols and multiple instances and such.
Because, if I have foo.c and bar.c, and foo needs to call a function from bar, the obvious way is to use a non-static function. And the normal way to guarantee that bar_function() will not cause any collisions is not to record it in some global pointer function list (you'll need a bar_init() for that anyway), but define it non-exportable. That will automatically enable per-instance usage.
The scope modules are separated by purpose, and they need to call each other no less than the Geany modules. I can declare everything static, create an "all.c", and #include all .c files, but why?
The global variables are: - the global plugin configuration - the current program (name, working dir, env, options...) - the thread count, current thread and frame.
Of these, the first two categories may be reasonably put in structs, like in Geany, but I'm using name prefixes instead.
-- E-gards: Jimmy