Jump to content

Recommended Posts

yes, there is already some low level support for rtti, but no higher level "easy to use" functions yet.

The following should work already:

 

 
procedure PrintPropertiesForType(obj : TObject); 
begin 
  var rtti := RTTIRawAttributes; 
  var aClass := obj.ClassType; 
  PrintLn(aClass.ClassName+':'); 

  while Assigned(aClass) do  
  begin 
    var typeID := TypeOf(aClass); 
    var j : Integer; 
    for j:=Low(rtti) to High(rtti) do  
    begin 
      var attrib := rtti[j]; 
      asm 
        console.dir(attrib); 
      end; 

      if (attrib.T = TypeID) and (attrib.A is RTTIPropertyAttribute) then  
      begin 
        var prop := RTTIPropertyAttribute(attrib.A); 
        Print('- '+prop.Name); 
        Print(', '+IntToStr(prop.Capabilities)); 
        Print(' : '); 
        Print(prop.Typ.Name); 
        Print(' = '); 
        var v := prop.Getter(obj); 
        PrintLn(v); 
        prop.Setter(obj, v+v); 
      end; 
    end; 
    aClass:=aClass.ClassParent; 
  end; 
end; 

procedure TForm1.W3Button1Click(Sender: TObject); 
begin 
  PrintPropertiesForType(self); 
end; 

 

And attributes are supported too:

 
type 
  MyAttrib = class (TCustomAttribute); 

type 
  [MyAttrib] 
  TTest1 = class 
  end; 

type 
  [TCustomAttribute] 
  TTest2 = class 
  end; 

procedure PrintAttributesForType(typeID : TRTTITypeInfo); 
begin 
  var rtti := RTTIRawAttributes; 
  var j : Integer; 
  for j:=Low(rtti) to High(rtti) do 
    if rtti[j].T = typeID then 
      PrintLn(rtti[j].A.ClassName); 
end; 

PrintAttributesForType(TypeOf(TTest1)); 
PrintAttributesForType(TypeOf(TTest2)); 

Link to post
Share on other sites
  • 2 weeks later...

Hello, I was not able to let RTTI be emitted to the HTML.

 

When I define:

type 
   TBase = class 
      published 
         Field : Integer = 1; 
   end; 

 var base := new TBase; 
 PrintPropertiesForType(base); 

 

Then, there is no RTTI available for this class.

In index.html, I have:

 
var $RTTI = []; 

Whatever Project Options I have set.

 

I'm using SMS 2.0.1.741 (and do not have the license yet to upgrade).

 

I'm stuck with implementing a native SMS client for mORMot....

Link to post
Share on other sites

No response since 4 days?

What is it?

 

I'm a bit disappointed by the support here...

I would expect support as least as good for paid products like SMS, in respect to our own Open Source projects.

 

I would like to invest into SMS a lot in the next months, for a new mobile project.

If support is so much unresponsive (whole forum sounds quite peaceful), my associate and I are wondering if investing in SMS is worth the price.

Otherwise, we would switch to alternatives.

 

I would perhaps try in http://stackoverflow.com/questions/tagged/smart-mobile-studio

Link to post
Share on other sites
  • Administrators

Hi AB.

 

Yeah. That was a lousy support!

No argue about that...

 

That sounds like an interesting project, and we will help out as best as we can wherever you're stuck.

 

 

The lack of response is not due to indifference, though. You have raised a rather interesting question!

 

Did you have a look at Lennart's article at http://jonlennartaasenden.wordpress.com/2014/06/20/smart-pascal-rtti-persistence/? And does this article clarify any of your issues?

 

 

I'll have a second look at the discussion we have had on this internally, and you'll get a proper answer (both here and on SO).

Link to post
Share on other sites
  • Administrators

You're still not forgotten, AB ;-)

 

But it seems like we need to dig pretty deep to figure this one out... :-(

 

We were mislead by the fact that our own tests worked OK. We have tested the last three versions (+ our internal svn trunk), since we thought this might be related to some side-effect in a hotfix. But then it turned out that the RTTI failed in some situations after all. Re-testing all four versions, and impossible to see any pattern.

 

 

We're starting to get the overview now, though.

Seems like:

- Attributes are OK, but published fields/properties/methods fail.

- Some RTL-classes work OK, but custom classes fail.

 

 

BTW. Make sure that "RTTI" is enabled in "Project options" (I.e. that "No RTTI information" is unchecked). This has fooled me a couple of times... :-P

 

 

The bottom line is that Smart should have a proper support for RTTI, and if it fails then it is a bug that will get fixed for next release.

 

We will go thoroughly trough the RTTI-stuff and ensure that everything works the way it should. We will also publish a proper documentation of the RTTI-support.

 

 

Link to post
Share on other sites

Thanks for the feedback.

 

I was more worried than upset in fact...

We are investing all our time (and did quit our jobs to have dedicated full time) on this new project using SMS, and my associate and I would definitively won't break our project due to show stoppers like this.

 

As a result, won't use rtti but generated wrappers (just like RO) for creating mORMot clients using Smart. Using mustache for templates - so that it may be shared with other platforms, e.g. C# or Java. :-)

Link to post
Share on other sites

BTW, is there any multi-developer licences?

 

My associate just bought one licence, and I will need to renew my own (which just ended beginning on this month)?

 

Or perhaps, if we manage to integrate mORMot to SMS IDE (just like RO/DataSnap), we may have some bonus from your side? A PRO license is enough for us, since we will rely on our own SOA, which is mORMot (much faster and efficient than the other two, and I'm not sure it is 100% suggestive). What we would like is to have mORMot integrated into the "Professional" version of SMS, since it is an Open Source project. In all cases, we would probably support direct SMS units generation from the mORMot server itself. But integration into the IDE would be even better, at least to add the newly generated units to the project. Is there some scripting features to extent the SMS IDE, just like the OpenTools?

 

Did you consider a free license for true GPL projects? Could be a good idea - perhaps with a banner or splash screen by default, which may be removed for a particular project, if you are sure the project is GPL.

Link to post
Share on other sites
  • Administrators

Worried about the lack of response or lack of RTTI?

 

Either way: We take this project seriously and we really care about the users. We might be late from time to time, but that doesn't mean that we doesn't care nor that we doesn't work on the reported issue.

 

We're very eager to hear more about your project :-)

If you can reveal some details or write about your experiences - we would love that!

 

We do have a 5-pack, 10-pack and 50-pack solution for the Enterprise edition. Right now we don't have any such bulk scheme for the Professional edition. The whole idea behind these editions was to offer a "low priced and affordable" alternative to the Enterprise. We will have a second look at this...

 

Our partners will get a free license as long as they maintain and contribute with valuable "stuff". Steema, TMS, BitTime, BergSoft, to mention a few. I believe mORMot would fall into this category too :-)

 

We have discussed mORMot before, but we never got around to complete the integration. We should definitely catch up on that! We are working on the "plugin feature" (OTA) from time to time, but I'm not sure about the current state. I believe it's still pretty "experimental". (The project templates have good scripting support). The easiest thing to do would probably be to just hard-code the wizard/tool directly into Smart IDE. We'll need to take closer look at the requirements for such an integration.

 

A free license for true GPL projects? Hm... Interesting idea. We will discuss this closer internally. We are positive to such initiatives. Thus the free compiler and the free educational license.

Link to post
Share on other sites

We have added sample "29 - SmartMobileStudio Client".

 

We introduced SMS one step further - not working yet, but at least compiling and able to share most of the client code between SMS and Delphi/FPC.

 

See http://synopse.info/fossil/info/e0d219684249664bd2feea75e3ad8a2c4850d35c

and http://synopse.info/fossil/tree?name=SQLite3/Samples/29+-+SmartMobileStudio+Client

Link to post
Share on other sites

The cross-platform units for the clients are available at http://synopse.info/fossil/tree?name=CrossPlatform

 

Please ensure you first copied the latest version of those files from CrossPlatform folder into this folder:

 

- SynCrossPlatformCrypto.pas

- SynCrossPlatformRest.pas

- SynCrossPlatformSpecific.pas

 

Those units are needed as external content, to compile the demo application.

Link to post
Share on other sites
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...