SRL Archive - Suggestions

(Form) Extensions


nielsie95

2010-02-27 04:29:57

A simple way of making plugins for Simba would be nice, maybe using Pascal Script?

Wizzup?

2010-02-27 11:39:27

Basically:
Code an API for programmers which gives them access to the Simba form plus some hooks like OnStartScript. This way theming can be implemented, as well as (for example) writing your own ACA in PascalScript, and then use it as a form in Simba.

mastaraymond

2010-02-27 17:20:54

Lazarus doesn't support Forms in any thread other than the Mainthread… Also does not support Forms in DLL's.

Wizzup?

2010-02-27 17:59:19

Extension Types:
  • Forms. (ACA or DTM Editor for example)
  • Themes. Small scripts that change some form settings
  • Ones that use hooks to perform certain actions on events. For example, preprocess a script before it is passed to the interpreter.
  • Macros

Extensions can be:
PascalScript scripts
Compiled FPC code. (in .so/.dll)

Wizzup?

2010-03-15 10:02:05

I've been thinking on how we can implement this…

One idea came to mind…

The first solution that comes to mind is to create a pascalscript instance for each extension, and run it on a seperate (PSEX) thread. Then have PSEX create the form on the main thread. This PSEX thread would run all the time whilst Simba is open, as PascalScript is blocking. You'd need a thread for every extension.

Good: Probably easy to implement… Hopefully stable.
Bad: Lots of extra threads.


Other idea may be similar: we could invoke the interpreter once an extension is called. (Like when the extension form has to open)
So we'd need to create hooks on which an extension is invoked. This is probably less CPU hungry, and shouldn't cost one thread per extension. To implement it properly it would be nice if we could suspend pascalscript. (If we really need to we could even suspend the entire thread)
I'm not sure if PascalScript is suspendable and to be used on event-basis… (Like, call it once to create the form, then suspend until the form needs attention)
Raymond or Nielsie hopefully does.

We could probably force extensions to implement certain functions like ShowExtensionForm(), and then call it with ExecuteFunction (PS Function). We'd only have to add a Hooks system and ask extensions to create certain functions.

nielsie95

2010-03-15 15:50:42

I think the separate threads are the best solution, as some extensions might want to run in the background (auto-updater?), but event driven would still be nice (OnSwitchTab, OnBeforeRun, etc).

Wizzup?

2010-03-15 16:34:47

I'll implement Event-based first. We'll see if we need threaded later.

Wizzup?

2010-03-15 19:32:43

Well, it seems to be very doable. I have a working proof of concept in the repos, on the extensions branch. It *should* work on Windows as well.

http://git.villavu.com/gitweb.cgi?p=simba.git;a=shortlog;h=refs/heads/extensions

(Use git pull origin master && git checkout -t origin/extensions)

Wizzup?

2010-03-16 07:50:49

We could easily create Filewall hooks, so the Filewall could be an extension. :)

mastaraymond

2010-03-19 20:27:19

The point is, if you want the extensions to be form-related they MUST run in the mainthread… Maybe we should have an option whether the extention wants to be run in a seperate thread or the mainthread..

Wizzup?

2010-03-20 08:18:00

From: mastaraymond
The point is, if you want the extensions to be form-related they MUST run in the mainthread… Maybe we should have an option whether the extention wants to be run in a seperate thread or the mainthread..


I don't see really when you would need a extension that cannot run on the main thread? However, this is going to be added eventually… First I want to finish the current psevent and add pluginevent. Then we can worry about running some stuff on another thread. :)