Extension Modules > COM

Couple Api ideas for embedding

(1/14) > >>

dzzie:
Hi all,

Just found the project and I am really impressed with it. Before I start I will mention my goal. I would like to create a basic script control similar to MS Script control but with debugging / single step/ variable inspection support. So I am coming from the task of an embedded user.

ScriptBasic looks like it is a good fit for this and I have been experimenting with it for about a week now. So far I have added the following (simple) API


--- Code: ---//text config to binary
scriba_CompileConfig

//add a preprocessor dll explicitly by dll path, no config needed
scriba_LoadInternalPreprocessorByPath

//register a compiled in preprocessor with no need for external dll
scriba_LoadInternalPreprocessorByFunction

--- End code ---

I have also had success compiling extensions directly into the interpreter and accessing them via the declare mechanism (even when working from an exe test project) This seemed easier to me than writing a new command so far.

I see that the interpreter has support to call script functions and getting/setting global variables. I was looking for an easy way to have a host app register a new function to be available to scripts maybe something like


--- Code: ---scriba_registerNative(pProgram, "myFunc", &myFunc_handler)

--- End code ---

Thats when I took a side street and figured out to use a compiled in extension for this task.


--- Code: ---declare sub trial alias "trial" lib "test.exe"

--- End code ---

Bit of a hack but it works so I can move on to experiment with next task of wiring access to the now compiled in debugger preprocessor to a VB6 GUI. Once this is fleshed out, I can add in a scintilla based syntax highlight control I have and add proper debug controls around that.

Ultimate goal for me is to make an embeddable script control ocx with a script editor IDE + debug support and some kind of support for VB6 COM objects.

For COM support, I was thinking of something like:


--- Code: ---scriba_registerNameSpaceResolver(pProgram, "myObj", &my_resolver)

--- End code ---

so if the script engine sees myObj::myfunc(1,2)

it will call my_resolver() with the args "myfunc", 1, 2 or something like that, but after looking through the syntax and lexer code I think it would be tricky to slip this in. An easier solution is probably to use the extension trick to


--- Code: ---declare sub callObj alias "callObj" lib "test.exe"
a = callObj("myObj.myFunc", 1 , 2)

--- End code ---

Then the VB6 CallByName function will be put to good use, but you will be limited to accessing the primary functions/properties of the object I think. (ie myObj.itsObj.someProp probably wont work at least not  without some parsing and intermediate steps). Not the prettiest, but manageable.

John also mentioned Charles Pegge's (OxygenBasic author) DLLC COM extension which I will study as well.

Again really impressed with the project, I have wanted this type of script control for a loooong time. I can see all the pieces fitting together here.

My work in progress can be found here:  https://github.com/dzzie/ScriptBasic_Control

As always, any/all ideas or comments welcome :)

-Dave



Support:
Welcome Dave!

Interesting stuff. Can you post your Visual Studio project file when you get everything working? It would be nice to have an alternative way to compile Script BASIC for Windows other than Peter's setup.pl method. I current have VS 2013 install on Win 7 64.


dzzie:
the solution and project files are included in the git repository (also a .zip download link) https://github.com/dzzie/ScriptBasic_Control/archive/master.zip

My physical file layout is slightly different and does not include all files in the distro, but you can see the project settings used.
You could also remove the files I have set in there and re-add (just drag and drop a multiselection of files or a folder into the VS treeview and it will add all files in that dir to the project)

There are ways to add multiple projects to one solution file so you can "Build All" and it will compile each exe, dll , preprocessor, extension etc all at once.
Setting all that up might take a while though it can be allot of fussing. I think basically you make copies of a vcproj file you are using, set up each one individually to build the target you want, then from the top level solution file, you can "Add project". so each binary gets its own project file, all linked into
the top level solution file. Its kind of a pita.

Sometimes I just use a VS project just for code navigation and editing, then use the custom build scripts authors provide for the actual compilation. Actually there is probably a way to set a custom build step to use the perl script and not the standard VS compilation process. So you probably can just add all the files to one
solution file for editing/viewing/navigation, then hit build and it will call the perl script. Not sure if it will display compilation errors as nicely as normally though.
 

Support:
For a release build, Peter's method would be preferred as everything (.h, syntax tables, error codes, documentation, ...) is built from scratch from the C files.

Armando (AIR) created a custom SB master make file for gcc under Windows that works pretty well.

dzzie:
thought I would share another bit of progress. I think a generic COM extension is about 90% done now and working in tests.
(currently i have it compiling into the main exe for debugging, no dll available yet but should be able to be built as one)

https://github.com/dzzie/ScriptBasic_Control/blob/master/engine/extensions/COM.cpp


--- Code: ---declare sub CreateObject alias "CreateObject" lib "test.exe"
declare sub CallByName alias "CallByName" lib "test.exe"

const VbGet = 2
const VbLet = 4
const VbMethod = 1
const VbSet = 8

obj = CreateObject("SAPI.SpVoice")

if obj = 0 then
print "CreateObject failed!\n"
else
CallByName(obj, "rate", VbLet, 2)
CallByName(obj, "volume", VbLet, 60)
CallByName(obj, "speak", VbMethod, "This is my test")
end if

print "\n\nPress ENTER..."
line input a

'in vbscript this would be:
'----------------------------------------
'Set voice = CreateObject("SAPI.SpVoice")
'voice.Rate = 8
'voice.Volume = 60
'voice.Speak "Hello, world!"

--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version