Jump to content


  • Content Count

  • Joined

  • Last visited

About abouchez

  • Rank

  • Birthday 10/29/1972

Contact Methods

  • Website URL

Profile Information

  • Gender
  • Location
    Beaulieu sur mer, France

Recent Profile Visitors

107 profile views
  1. abouchez

    How to cast a js variant to TIntArray

    I see at least a small snippet of "asm" within a function: function Variant2TIntArray(value: variant): TIntArray; begin asm @result = @value; end; end;
  2. abouchez

    De-virtualization Enhancement

    Nobody there? As far as I discovered, latest JavaScript engines are able to "de-virtualize" the appy() calls, from its execution trace. See for instance latest webkit enhancements, with FTL introduction, in "Polyvariant Devirtualization" paragraph of this great https://www.webkit.org/blog/3362/introducing-the-webkit-ftl-jit/article.
  3. abouchez

    De-virtualization Enhancement

    Some part of my code needs the highest performance possible. JavaScript's apply() is much slower than direct call, by design. The "devirtualization" feature, AFAIK does the following: - if a method is "pure virtual", without any "override", it will be compiled as if it was not virtual. type TMyClass = public procedure MyMethod; virtual; end; If this TMyClass.MyMethod is never overriden, then the class will be compiled as such: type TMyClass = public procedure MyMethod; end; My problem is that it does not work with "virtual; abstract;" methods. May the "devirtualization" feature be extended to "virtual; abstract;" methods which have only one "override". Following the Liskov principles, I like very much rely on abstractions, and use only one single implementation class: type TMyClassAbstract = public procedure MyMethod; virtual; abstract; end; TMyClassImplementation = public procedure MyMethod; override; end; Even handle for the simplest case, i.e. one abstract class with "virtual; abstract;" method and one inherited class with "override" in the whole project would be enough for me. I would like this type to compile as such: type TMyClassImplementation = public procedure MyMethod; end; The performance difference between apply() and direct call is huge.
  4. abouchez

    TstringList properties and JSON.parse

    Use an "array of string" on the SmartMobileStudio side. But your code won't work directly. There is no built-in JSON serialization of published properties of a class within Smart yet. And AFAIR there is not enough information in the RTTI to process the JSON content into properties. It will work for simple types (string/numbers), but not for classes or records. The main problem is that JSON.Parse() will return a variant, not a TMyClass instance. Also, due to variable name obfuscation, the TMyClass properties and the variant created by JSON.Parse() would probably just not match (at all!). You need etheir: - Forget about TMyClass, and use the variant directly, and its properties directly (e.g. aVariant.ObjId) - but names are case sensitive here! - Use a function which use the JSON, convert it to a variant via JSON.Parse(), then fill the TMyClass published properties. We use something like the 2nd for marshaling JSON data into SMS records or classes with out client unit wrappers for SMS. See http://blog.synopse.info/post/2014/08/11/CrossPlatform-Clients/SmartMobileStudio You can see at https://github.com/synopse/mORMot/blob/master/SQLite3/Samples/29%20-%20SmartMobileStudio%20Client/mORMotClient.pasan unit generated by a mORMot server (from SMS-dedicated templates), which will do all the JSON marshaling I wrote above. See for instance TSQLRecordPeople.SetProperty() and TSQLRecordPeople.GetProperty() or Variant2TTestCustomJSONArraySimpleArray(). BTW our interface-based services are a very simple way of consuming server process written in Delphi from a Smart client: all marshaling is done by the framework. You would benefit of not writing everything on your own, and get a lot of other features (like an additional remote ORM layer, security, and very good performance).
  5. If you find it interesting, you may share some official news in your web site, if you wish! IMHO it may be a good selling point for SmartMobileStudio.
  6. In addition to Delphi and FreePascal clients, our framework is now able to access any mORMot server from HTML5 / AJAX rich client, thanks to Smart Mobile Studio. Take a look at this series of blog articles: Units and platforms; Generating the client code wrappers; Delphi / FreePascal clients; Smart Mobile Studio clients. There is no package to be installed within the Smart Mobile Studio IDE. The client units will be generated directly from the mORMot server. Any edition of Smart is enough: you do not need to pay for the Enterprise edition to consume mORMot services. But of course, the Professionnal edition is recommended, since the Basic edition does not allow to create forms from the IDE, which is the main point for an AJAX application. In contrast to the wrappers available in the Enterprise edition of Smart, for accessing RemObjects or DataSnap servers, our mORMot clients are 100% written in the SmartPascal dialect. There is no need to link an external .js library to your executable, and you will benefit of the obfuscation and smart linking features of the Smart compiler. A set of object pascal units will provide a solid and shared ground for the any kind of clients: Connection to a mORMot server via HTTP, with full REST support; Support of weak or default authentication to secure the transfer - see Authentication; Definition of the TSQLRecord class, using RTTI when available on Delphi orFreePascal, and generated code for Smart Mobile Studio; Remote CRUD operations, via JSON and REST, with a TSQLRestClientURI class, with the same methods as with the mORMot.pas framework unit; Optimized TSQLTableJSON class to handle a JSON result table, as returned bymORMot's REST server ORM - see JSON (not) expanded layouts; Batch process - see BATCH sequences for adding/updating/deleting records - for transactional and high-speed writes; Client-Server services via methods with parameters marshaling; Client-Server services via interfaces with parameters marshaling and instance-life time; Mapping of most supported field types, including e.g. ISO 8601 date/time encoding, BLOBs and TModTime/TCreateTime; Complex record types are also exported and consumed via JSON, on all platforms (for both ORM and SOA methods); Some cross-platform low-level functions and types definitions, to help share as much code as possible between your projects. Hope you find it interesting! Smart Mobile Studio rocks!
  7. abouchez

    File API?

    I suspect you were speaking of W3C.File.pas under RTL\APis\W3C. That is a pretty good start! Thanks!
  8. I confirm that the just release 2.1 revision fixed the issue. I'm now able to work with records and nested records transmitted as JSON from a mORMot server! From my point of view, SMS client generation for mORMot is working as expected. You can now from any Smart application: - Have a secure RESTful ORM access to a remote mORMot server; - Execute interface-based services from a remote mORMot server. The mORMot server is able to generate code wrappers for Smart. No need to add a plug-in in Smart: the units are generated from the mORMot server, using a Mustache template (there are templates for Smart, Win32/Win64 Delphi, and CrossPlatform Delphi clients, including OSX / iOS / Android via FMX/NextGen, and the FreePascalCompiler). Note that I was able to share a lot of code between Smart, Delphi and FPC. As such, the RESTful ORM and SOA classes and methods are the same among all platforms. Then the units are generated from templates. The Smart part is 100% object pascal: there is no external JavaScript library needed (as with RemObjects or DataSnap). I'm finishing the documentation. Some blog articles are to come. Stay tuned!
  9. I was not able to log using the old credentials. But perhaps I made something wrong. It does not matter much. But thanks a lot for fixing this issue, during the Release Candidate day! This is great!
  10. In the Smart RTL, there are some functions which convert manually string to/from enumerations. AFAIK the SMS compiler already generates a javascript string array of all values, so it is pretty easy to use a more generic way. For instance, it is how our mORMot SOA clients handle enumeration serialization. If I define the following type: TRecordEnum = (reOne, reTwo, reLast); The following JavaScript will be generated (and not used, AFAIK): /// TRecordEnum enumeration var TRecordEnum = [ "reOne", "reTwo", "reLast" ]; Then I can convert from a variant (either a string or an integer) into a TRecordEnum as such: function Variant2TRecordEnum(const _variant: variant): TRecordEnum; begin asm return @VariantToEnum(@_variant,@TRecordEnum); end; end; Using the following function: function VariantToEnum(const Value: variant; const TextValues: array of string): integer; var str: string; begin {$ifdef ISSMS} if TVariant.IsNumber(Value) then {$else} if VarIsOrdinal(Value) then // Value is integer {$endif} result := Value else begin str := Value; if str<>'' then for result := 0 to high(TextValues) do if str=TextValues[result] then exit; result := 0; // return first item by default end; end; It could make the current RTL both shorter in size and less error-prone (e.g. if you add some items to the enumeration, you will rely on the compiler). Does it make sense to you? Or perhaps I missing some hidden feature about SMS enumerations, and already built-in "toString/fromString" hidden methods?
  11. Hello, Just to discuss about https://smartmobilestudio.zendesk.com/hc/en-us/requests/84issue. Using latest Smart Mobile Studio 2.1 (beta-3): If I define the following record type: type TTestNestedRecord = record H1: integer; H2: string; H3: record H3a: boolean; H3b: TSQLRawBlob; end; end; when I want to copy the record: var rec1,rec2: TTestNestedRecord; rec2 := rec1; then the browser complain about a missing copy function. In fact, there is no function generated by the compiler to copy the nested rec2.H3 := rec1.H3. This is very annoying to have such a basic language feature not working... I would have to switch from record to classes for our mORMot SOA client, and it is really disappointing.