Re: [fpc-pascal] Looking for JavaScript component on FPC
On Wed, 1 Apr 2015, Andrew Brunner wrote: I have Besen installed and I am in the process of evaluating it. It does not handle nested classes. I need a JIT compiler that provide access to heavily nested class information. This PostInfo is a simple database module that I would want Script to have access to. [] Log ('WooHoo'); }; Nested classes are a modern way to organize complex API and code into very easy to read code. Most of the modules I have are extremely nested, the one I chose here is easy and strait forward. And already utterly unreadable for me... IMHO goes to show that this is a very personal matter :-) I see PascalScript is part of the Lazarus project now. I have not been able to get nested classes to work there either. If I am to get my code accessible, I will need someone with knowledge in extending BESEN or PascalScript or both. I would be ideal to offer developers a choice of which scripting language they want to write back-end code. But if I am to provide developers with instant API to do complex code that is relevant to computing needs of today, I will need access to nested objects in either of these JITCs. Anyone familiar with BESEN or PascalScript that could shed some light? Can you explain why nested classes cannot be handled in e.g. besen ? They are no different from normal classes except in their name, a fact that could probably be handled through some stringreplace('.','_') or so. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Looking for JavaScript component on FPC
On 4/2/2015 11:46 AM, Michael Van Canneyt wrote: Namespaces are available as dotted units ? Namespace as dotted units? I use 3.1.1 compiled here so there is no problem. FPC since as far as I recall (svn) has had support for naming units with multiple dots. I've had tons of units with includes and I dot them for quick functionality review in directory listings. Hmmm... The only problem is it seems pretty cheap. I love the advanced look of my complex units. I would have to break out each unit and maintain a bunch of separate units. I could see how this was a delphi-like feature but its not done in a modern fashion. Just wondering how much work it's going to take to have nested class support. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Looking for JavaScript component on FPC
I see PascalScript is part of the Lazarus project now. I have not been able to get nested classes to work there either. If I am to get my code accessible, I will need someone with knowledge in extending BESEN or PascalScript or both. I would be ideal to offer developers a choice of which scripting language they want to write back-end code. But if I am to provide developers with instant API to do complex code that is relevant to computing needs of today, I will need access to nested objects in either of these JITCs. Anyone familiar with BESEN or PascalScript that could shed some light? Can you explain why nested classes cannot be handled in e.g. besen ? They are no different from normal classes except in their name, a fact that could probably be handled through some stringreplace('.','_') or so. I don't think PascalScript should have real problems with using them then. The only problem is that the importer doesn't support them. -- Carlo Kok RemObjects Software ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Looking for JavaScript component on FPC
On Thu, 2 Apr 2015, Carlo Kok wrote: I see PascalScript is part of the Lazarus project now. I have not been able to get nested classes to work there either. If I am to get my code accessible, I will need someone with knowledge in extending BESEN or PascalScript or both. I would be ideal to offer developers a choice of which scripting language they want to write back-end code. But if I am to provide developers with instant API to do complex code that is relevant to computing needs of today, I will need access to nested objects in either of these JITCs. Anyone familiar with BESEN or PascalScript that could shed some light? Can you explain why nested classes cannot be handled in e.g. besen ? They are no different from normal classes except in their name, a fact that could probably be handled through some stringreplace('.','_') or so. I don't think PascalScript should have real problems with using them then. The only problem is that the importer doesn't support them. I suspected as much, but I am not an expert on both engines... Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] load a library twice
Both the Windows LoadLibrary/FreeLibrary and Unix style dlopen/dlclose function internally use a reference counting system to load and unload dll/shared object (dynamic library) files. This means that it is safe to call LoadLibrary twice, and FreeLibrary once whilst keeping the a library loading. It's only when the load/unload counts match when a dynamic library will be unloaded. So to answer you question, yes it's okay. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Looking for JavaScript component on FPC
On 4/2/2015 2:24 AM, Michael Van Canneyt wrote: And already utterly unreadable for me... IMHO goes to show that this is a very personal matter :-) Units that include hierarchy via class types are a supplement for namespaces in languages such as c#. Since Namespaces are not *yet* available in FPC we have to use classes. The dotted notation in libraries that use the organized unit makes for easy code readability as well as having global variables available within the namespace. So things like naming conventions become standard. I have attached a 3.4kb example unit that is the back-end db module. CMS.XML namespace holds all my XML related types,vars,consts,etc. Units that use this module declare things like var PP:dbmCMS.CMS.TPagePoint; I realize the similarities in having a unit results in the same code as above however, the real benefit comes when the database modules become more complex. The single most important feature I absolutely love is having *.TItem and *.TItems where * is a hierarchy of nested classes (purposely namespace). My most complex database module dbmSocial. There I have Files.TItem/TItems and Folder.TItem/TItems. I hope the attached unit brings some clarity to my motivation and need for having organized units with namespaces (currently as nested classes). unit dbmCMS; {$mode objfpc}{$H+} { unit dbmCMS.pas CMS Storage Database Module DBMS facilities to handle Content Management System Copyright Aurawin LLC 2014 Written by: Andrew Thomas Brunner This code is protected under the Aurawin Release License http://www.aurawin.com/aprl.html } interface uses Classes, SysUtils, hDatabase, uXML, uStringArray, uQWordArray, uByteArray, XMLRead, DOM, uStreams, uDBModule, uDatabase, dbmContentTypes, hHTTP, uVarString; type CMS = class type XML=class type Stanzas=class const PagePoint = 'pp'; end; Fields=class const FileID = 'fild'; FolderID = 'fold'; URI= 'uri'; Space = 'spc'; Data = 'data'; end; end; PPagePoint=^TPagePoint; TPagePoint=record FileID : QWord; FolderID : QWord; URI : TVarString; Space: TVarString; Data : TVarString; end; class function toXML(var Item:TPagePoint; Output:TMemoryStream; Header:boolean):boolean; class function fromXML(xDoc:TXMLDocument; var Item:TPagePoint):boolean; overload; class procedure Empty(Var Item:TPagePoint); overload; class procedure Init(Var Item:TPagePoint); overload; class procedure Done(Var Item:TPagePoint); overload; end; implementation uses uStorage,uTimer,uImage,DB, sqldb,uBase64; class function CMS.fromXML(xDoc:TXMLDocument; var Item:TPagePoint):boolean; var xItem:TDOMNode; begin Result:=False; Empty(Item); xItem:=uXML.XML.getNode(xDoc,XML.Stanzas.PagePoint); if (xItemnil) then begin with uXML.XML do begin Item.FileID:=toQword(xItem,XML.Fields.FileID); Item.FolderID:=toQword(xItem,XML.Fields.FolderID); Item.Space:=toString(xItem,XML.Fields.Space); Item.URI:=toString(xItem,XML.Fields.URI); Item.Data:=toString(xItem,XML.Fields.Data); Result:=True; end; end; end; class function CMS.toXML(var Item:TPagePoint; Output:TMemoryStream; Header:boolean):boolean; begin Result:=False; if Header then uXML.XML.Stamp(Main.Header.Encoding,Output); Output.Position:=Output.Size; uStreams.Write('',1,Output); uStreams.Write(XML.Stanzas.PagePoint,Output); uStreams.Write('',1,Output); with uXML.XML do begin uStreams.Write(Print(XML.Fields.FileID,Item.FileID),Output); uStreams.Write(Print(XML.Fields.FolderID,Item.FolderID),Output); uStreams.Write(Print(XML.Fields.Space,Item.Space,CDATA_OFF),Output); uStreams.Write(Print(XML.Fields.URI,Item.URI,CDATA_ON),Output); uStreams.Write(Print(XML.Fields.Data,Item.Data,CDATA_OFF),Output); end; uStreams.Write('/',2,Output); uStreams.Write(XML.Stanzas.PagePoint,Output); uStreams.Write('',1,Output); Result:=True; end; class procedure CMS.Empty(Var Item:TPagePoint); begin Item.FileID:=0; Item.FolderID:=0; SetLength(Item.Space,0); SetLength(Item.URI,0); SetLength(Item.Data,0); end; class procedure CMS.Init(Var Item:TPagePoint); begin Item.FileID:=0; Item.FolderID:=0; SetLength(Item.Space,0); SetLength(Item.URI,0); SetLength(Item.Data,0); end; class procedure CMS.Done(Var Item:TPagePoint); begin Finalize(Item.Space); Finalize(Item.URI); Finalize(Item.Data); Finalize(Item); end; end. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] load a library twice
Hi All, Is the following correct: var h1, h2: TLibHandle; lib1, lib2: string; begin lib1 := 'library.so'; lib2 := 'library.so'; h1 := LoadLibrary(lib1); h2 := LoadLibrary(lib2); end. The reason I need this is that I would like to keep the possibility to provide different group of functions in the same or two different libraries. For example, lib1 provides function A, lib2 provide function B, or, lib3 provide both function A and B. If I open the same library via 2 different handles, are they actually pointing to the same memory address internally, so that if I UnloadLibrary, it will cause something like access violation in the second call? Thanks! Xiangrong ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Looking for JavaScript component on FPC
On Thu, 2 Apr 2015, Andrew Brunner wrote: On 4/2/2015 2:24 AM, Michael Van Canneyt wrote: And already utterly unreadable for me... IMHO goes to show that this is a very personal matter :-) Units that include hierarchy via class types are a supplement for namespaces in languages such as c#. Since Namespaces are not *yet* available in FPC we have to use classes. Namespaces are available as dotted units ? Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Looking for JavaScript component on FPC
Am 02.04.2015 18:46 schrieb Michael Van Canneyt mich...@freepascal.org: On Thu, 2 Apr 2015, Andrew Brunner wrote: On 4/2/2015 2:24 AM, Michael Van Canneyt wrote: And already utterly unreadable for me... IMHO goes to show that this is a very personal matter :-) Units that include hierarchy via class types are a supplement for namespaces in languages such as c#. Since Namespaces are not *yet* available in FPC we have to use classes. Namespaces are available as dotted units ? But 3.0.0 is not yet released and some people rely on release versions... Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal