Lua get class name of object at runtime - lua

im wondering if there is way to get class name of object at runtime.
i mean something like this:
here is my very simple script
person=TPerson:new()
And i want in my app (in delphi) get "TPerson"
I tried it with lua debug info but what i know to get is called function "new" but i need to get class "TPerson"
lua_getstack(l,0,PL_Debug);
lua_getfield(l,LUA_GLOBALSINDEX,'f');
lua_getinfo(l,'n',PL_Debug);
nameOfCurrnetFunction:=PL_Debug.name; // here is stored "new"
so is possible to get class name?
thanks

Officially you do not have classes in Lua so the type of your objects would always be table. Of course you are free to implement some function that returns you a custom type-name as a string. Lua-wise it will remain a table tough

Related

Using the analyzer package, is it possible to create an instance of a DartType representing a would-be generated code?

While using the analyzer package, I was wondering if it was possible to create an instance of its DartType object.
The issue I'm facing is, the analyzer output doesn't give me a valid DartType for a given class because that class has yet to exist (it is not yet generated by a code-generator).
I can work around not using DartType directly and instead make some copycat class. But that adds a lot of complexity. So I'd like to be able to create a DartType representing the would-be generated class.
I've looked into the TypeSytem/TypeProvider objects which seem to object type-related utilities but didn't find anything I wanted.
Is that possible?

Instantiating a class by String name in Dart

I am trying to call a method of a class that I only know by name as a String. Now therefore I would need a ClassMirror of that class that allowes me to instantiate an instance. However, creating ClassMirrors seems to be only possible by entering a type using reflectClass(Type) or by passing an already existing instance of that class into reflect(dynamic). So these aren`t helping if I only have a String.
In Java you can do this pretty easily, by calling Class.forName(String). Then you would get a Constructor instance, make it accessibly and call it.
Does anyone know if this is even possible in dart? What seems weird is that once you have a ClassMirror you can access fields and methods by passing symbols, which can be created by Strings.
You can put a specific list of strings to map to a specific list of closures to create a new object with specific parameters.
But you can't get a reflection without using dart:mirrors, which is being deprecated, and also had a negative impact on tree shaking to get the payload size down.
In general, you're invited to look at the package:reflectable to achieve most of what you'd want out of dart:mirrors, using source-to-source builders.

Fatal error: Call to protected method TCPDF::_dounderlinew() from context

I'm trying to used a method called _dounderlinew(). I'm studying the other method that was list down on the documentation of TCPDF, and it was says that this method's access is PROTECTED. This is the reason why I can't make it work just like the others. Hmm Can anyone explain me why I'm getting errors like this and how can I used this method? THANKS.
Codes I USeds
$pdf->_dounderlinew(x, y, '');
_dounderlinew() is protected because it is used in the TCPDF class to output the actual PDF code, based on your input, so it is of no use to you. As the PHP manual says:
Members declared protected can be accessed only within the class
itself and by inherited and parent classes.
By using it I assume you wish to underline text (maybe inside a cell), for that you can use the SetFont function and set the style parameter to 'U':
SetFont($family, $style='U', $size=null, $fontfile='', $subset='default', $out=true)
And the other parameters as you wish of course.

Map TRttiProperty to a class definition equivalent

I'm wondering if its possible to reference a class definition directly for purpose of using it in conjunction to RTTI (map a property to TRttiProperty, etc).
E.g.
I would like to use TMyClass.MyProperty as a TRttiProperty, without having to resolve it via a name/ string, this will keep my code and compiler integrity intact, as string variables may be misspelled, etc.
Thanks
Assuming which you want do something like this
P:=TRttiProperty(TMyClass.MyProperty);
or write a function like so
function GetPropertyInfo(P: reference to property):TRttiProperty;
This is not possible, to do this possible you will require which delphi has support to property references. So the only current way to access (reference) an class property is using his name via an string.

How to tell what module has called the program

When using [Dynamics] [AX] is there a system function that can be used
to determine which module the user was in when the program was called?
I want to execute different X++ lookup code for employee,
for the ProjJournalTable form, but this would
be a different employee-list depending on which module is calling
the form. Hope that's clear! - Maeve
There is no concept of "module" in the execution context of a form or report. Therefore there is no system function to return that.
How to get around context dependant behaviour, where the behaviour depends on the caller?
The usual method in say a lookup form is to inspect element.args() for one of:
element.args().dataset() and/or element.args().record()
element.args().parmEnumType() and element.args().parmEnum()
element.args().parm()
element.args().caller()
element.args().parmObject()
Take a look on the form LedgerAccountLookup for example, you can find many more by searching for "args" in form methods named "init".

Resources