Dplug icon indicating copy to clipboard operation
Dplug copied to clipboard

Wren classes are known without the Wren import

Open p0nce opened this issue 3 years ago • 4 comments

It doesn't make sense to me, but it seems you can forget to import a class from "widgets", and it still work. (!!?)

p0nce avatar Mar 07 '22 13:03 p0nce

I've noticed that Wren knows about any class exported in a @ScriptExport section, and you do not need to "import" from your wren script.

Conversely, I have some classes that I explicitly import in Wren without needing a @ScriptExport, but that actually doesn't work, so I'm forced to use a @ScriptExport anyways! This has led to the following code in my project:

@ScriptExport
{
...
	UISeparator ForceScriptToImportSeparators; // For some reason importing directly in the script isn't enough
}

PolyVector avatar Jun 08 '22 18:06 PolyVector

@ScriptExport is indeed always needed (unless you use context.wrenSupport.registerUIElementClass!UISeparator to do it for each class manually, this is equivalent).

It makes the class UISeparator declared, with its properties, in the "widget" pseudo-module, it then allows to use it from script. Without that, this class doesn't exist for the point of view of the Wren VM.

p0nce avatar Jun 09 '22 13:06 p0nce

Something else annoying with Wren?

p0nce avatar Jun 09 '22 13:06 p0nce

@ScriptExport is indeed always needed (unless you use context.wrenSupport.registerUIElementClass!UISeparator to do it for each class manually, this is equivalent).

Ah! That makes sense! I should have taken more time to understand how this works, thank you.

PolyVector avatar Jun 09 '22 18:06 PolyVector

Well this isn't really disrupting.

p0nce avatar Aug 13 '23 09:08 p0nce