Author Topic: SBT  (Read 35435 times)

0 Members and 3 Guests are viewing this topic.

Charles Pegge

  • Guest
Re: SBT
« Reply #30 on: September 29, 2014, 02:19:07 PM »

Those are questions for Peter Verhas. It is a very complex system and extremely demanding for a third party to track.

JRS

  • Guest
Re: SBT
« Reply #31 on: September 29, 2014, 02:42:19 PM »
Thanks Charles for having a look. I'll keep chipping away at it until Peter has time to answer these questions.

Your right, as simple as SB looks from a user standpoint, understanding the magic under the covers is still a challenge. (I've been at it since 2006)

JRS

  • Guest
Re: SBT
« Reply #32 on: September 29, 2014, 11:25:31 PM »
What has me wondering is the hooker aspect of SB. (maybe this topic will get Mike's interest.  :-* ) Was this created to couple data objects in their different forms? Is this only for the extension module side of the SB API? I'm going to try to clone some of the working ICALL code into the SB_Sub() call and manually parse the arguments in stdarg syntax. I'm hoping Peter has some SB function I haven't discovered yet to make all this less painful.

Charles Pegge

  • Guest
Re: SBT
« Reply #33 on: September 30, 2014, 03:04:59 AM »
There are only  10 pHooker references in execute.c, compared with 45 in basext.c. So they are mainly used for the benefit of extension modules.

They  are a form of OOP methods table.

ExecuteObjects are used extensively throughout the source code though.


JRS

  • Guest
Re: SBT
« Reply #34 on: September 30, 2014, 09:40:27 AM »
Using both the ext. and embedding API in unison is SB running on all cylinders. On a positive note, it gives you a much better picture of SB as a whole. As you have already discovered writing DLLC.

 

JRS

  • Guest
SBT
« Reply #35 on: April 25, 2015, 08:55:54 AM »
Charles,

I'm trying to call a SB function, passing arguments and return a result as an embedded extension module call. Can you give me a hand on the All BASIC forum? You are a member there. I'm trying to rally Peter Verhas and AIR to help as well.

John

JRS

  • Guest
Re: SBT
« Reply #36 on: April 26, 2015, 06:29:31 PM »
Hi Charles,

I'm not having much luck solving the scriba_CallArgEx mystery. Can you post how you did it in DLLC? I really could use a hand with this if you have time.

John

Charles Pegge

  • Guest
Re: SBT
« Reply #37 on: April 27, 2015, 12:37:27 AM »
Hi John,

Is this a pProgram problem?

JRS

  • Guest
Re: SBT
« Reply #38 on: April 27, 2015, 06:55:27 AM »
Hi John,

Is this a pProgram problem?

No, that is working fine. It's dynamically building the ArgData array from the passed wrapper function arguments. It's ICALL as a ext. module function. (see details on All BASIC)

The goal with this project is to show how the Script BASIC API works using itself.  8) I have already discovered a couple bugs which I have informed Peter Verhas of.
« Last Edit: April 27, 2015, 11:25:24 AM by John »

Charles Pegge

  • Guest
Re: SBT
« Reply #39 on: April 28, 2015, 04:23:44 AM »
Hi John,

Since we solved that little problem of how to pass string arguments to an SB function, I have not seen any further difficulties with CallArgEx. For integers and floats, Argument blocks can be built from scratch. But when implementing callbacks to an SB function, I think there is a serious potential hazard: to avoid concurrency in the same pProgram.
« Last Edit: April 28, 2015, 04:59:43 AM by Charles Pegge »

JRS

  • Guest
Re: SBT
« Reply #40 on: April 28, 2015, 07:54:39 AM »
Charles,

I'm not doing anything special with callbacks or anything else. All I need help with is taking the passed arguments in my wrapper function and build the argument array. Please take a look at the All BASIC thread I have going as it should make things perfectly clear.

Thanks!

John

Charles Pegge

  • Guest
Re: SBT
« Reply #41 on: April 28, 2015, 10:59:19 AM »
Are you using Hook functions? Last time I attempted to use them, I found null pointers in the chain. ie: structures not initialised.

However, using the scriba_ functions, with a valid pProgram:

Code: OxygenBasic
  1.   sbfun=scriba_LookupFunctionByName(pProgram,"main::callbacka")
  2.   if sbfun=0 then print "Unable to locate callbackA" : goto ending
  3.   string s={"One","Two","Three","Four"}
  4.   args=scriba_NewSbArgs(pProgram,"s s s s",s[0],s[1],s[2],s[3])
  5.   count=4
  6.   iError=scriba_CallArgEx(pProgram, sbfun, @ReturnData, count, args)
  7.   scriba_DestroySbArgs(pProgram,args,4)
  8.  

Passing integers {100,200,300,400}, is simpler: Here it is done with an array of longs, instead of using a set of SB data blocks: (2 signifies integer type)


Code: OxygenBasic
  1.   sbfun=scriba_LookupFunctionByName(pProgram,"main::callbacka")
  2.   if sbfun=0 then print "Unable to locate callbackA" : goto ending
  3.   long a={2,4,100,0, 2,4,200,0, 2,4,300,0, 2,4,400,0} : args=@a
  4.   count=4
  5.   iError=scriba_CallArgEx(pProgram, sbfun, @ReturnData, count, args)
  6.  

By the way, I've tested this with your 64bit libScriba.dll (GCC 2013) :)
« Last Edit: April 28, 2015, 11:14:07 AM by Charles Pegge »

JRS

  • Guest
Re: SBT
« Reply #42 on: April 28, 2015, 12:14:50 PM »
Sweet! (and 64 bit Windows to boot)

Well, at least we know it works. The trick is to grab the argdata being passed in the wrapper function and share the argument array after the first two with scriba_CallArgEx. The next thing is returning the results of the dynamic SB script function being called. I'm assuming at this point it is nothing more than passing back a pointer to ReturnData.


Charles Pegge

  • Guest
Re: SBT
« Reply #43 on: April 28, 2015, 12:37:43 PM »
Yes, quite easy. You must check the format of the returned data, and use accordingly.

NB! scriba_DestroySbArgs should not be used on the returned data pointer. It will crash.

Code: OxygenBasic
  1.   'READ RETURNED VALUE
  2.  '-------------------
  3.  '
  4.  select ReturnData.typ
  5.     case SBT_UNDEF  : pr+= "Undefined "
  6.     case SBT_DOUBLE : pr+="double "  ReturnData.dbl
  7.     case SBT_LONG   : pr+="long "    ReturnData.lng
  8.     case SBT_STRING : pr+="zstring " ReturnData.str
  9.     case SBT_ZCHAR  : pr+="zchar "   ReturnData.lng
  10.   end select
  11.  

JRS

  • Guest
Re: SBT
« Reply #44 on: April 28, 2015, 12:39:58 PM »
Thanks Charles!

Any chance you could use my C example on All BASIC and make a working function from that?

« Last Edit: April 28, 2015, 12:46:59 PM by John »