XojoScript: access to entire classes


I’m making some test and evaluating Xojo for my project.
I need to implement some scripting features, and made some tests.

I understood that I can expose code written in Xojo via “context” (and xojoscript see, for example, methods as global methods).
Is there any way (any trick) to expose to xojoscript an entire object defined in xojo (not instance, but class)?

For example, in xojo I create the class Calculator:

class Calculator function add(argNum1 as integer, argNum2 as integer) as integer return argNum1 + argNum2 end function end class

I want to instantiate and use that class in xojoscript:

dim calc as Calculator
print calc.add(3,4)

Thank you for your help!

No you have two options:

Xojo class gets dummy methods added to it that accept strings/integers. You instantiate whatever you need in those dummy classes.


Your XojoScript gets a full fledged instance of that class and you just store the values somewhere in real Xojo code.

Ultimately XojoScript is not designed to facilitate OOP as much as give you a simple way to alter behavior at run-time.

There is another option… you can define a Class in xojoscript, where it’s methods call back into the context. Basically you mirror the class completely in xojoscript and then you can “instantiate” one on the fly.

Yes, I was thinking to that solution, but does not solve my problem. In fact, I wanted to avoid to method per method, some special classes I’m creating for the script.
If I could map entire classes, in a future, if I will add a new method, if I have automatically that new method in script also. Instead, I’m obliged to map everything by hand.

Thank you for your suggestion.