1 Feb 2006 08:21
Re: Revision #6 to the job system
Bruce Dodson <bruce_dodson <at> hotmail.com>
2006-02-01 07:21:55 GMT
2006-02-01 07:21:55 GMT
Hi April, Congratulations, you're the lucky winner of ... a code review! But I am not reviewing the JobQueue itself. Instead I will focus on how the SciTE Tools Menu and the Extensions interface with the new job system. (Mainly because I worked on the Tools Menu and on the Extensions, so I have a personal interest in those parts. But also because multithreaded code is hard to review, and I am lazy.) 1) As Neil pointed out, the correct model for setting up the function is like Open, not like SendEditor. SendEditor and SendOutput are closures so that they can share the same code. (A closure is just a function with some associated data: in this case, the extra data is a string that says where to send the message.) lua_pushliteral(luaState, "Open"); lua_pushcfunction(luaState, cf_scite_open); lua_rawset(luaState, -3); lua_pushliteral(luaState, "Execute"); lua_pushcfunction(luaState, cf_scite_execute); lua_rawset(luaState, -3); The Lua API is stack-based, so it takes a bit of getting used to. First you push the arguments, then you call the function. The function call may reference other stack items by index; that's what the -3 is. So here, if this were a normal C-style API, it would look something like this(Continue reading)
>1) As Neil pointed out, the correct model for setting up the
>function is like Open, not like SendEditor.
>
>
I've altered this in my source. Thank you Neil and Bruce.
>2) If it is necessary to add new methods to the
>ExtensionAPI, I would try to keep them at a high level so
>that other extensions (e.g. Director) can also use them
>without having to copy boilerplate code from LuaExtension.
>To that end, you might consider removing DecodeCommandMode
>from ExtensionAPI, and changing AddJob to do that work.
>AddJob could have this signature:
>
> virtual bool AddJob(const char *jobCommand, const char
>*jobDirectory, const char *jobMode, const char
>*jobInput=0)=0;
>
>The implementation of AddJob would decode the mode string to
>get the subsystem, save-before option, and flags. Pass a
>non-NULL for jobInput (even an empty string) and that means
>jobHasInput gets added to the flags after the mode string is
>decoded. (Also, since the raw flags are not passed in to
RSS Feed