Category: Firemonkey

Developer Issue Report Tool (DIRT) Client screenshots

People who've attended the Delphi XE DataSnap webinar, or read the Delphi XE in Action white paper on "DataSnap XE in the Real World" may have seen the development bits of my Developer Issue Report Tool (DIRT) Server and Client, but here are some screenshots of the most recent build. After you login to the DIRT DataSnap Client (called DirtCleaner by the way), you will get an overview of all issues that belong to you (either because you were the Reporter or the Assigned-To user).
Read More

Delphi XE DataSnap Development courseware and webinar

Within the next 24 hours, I will send out the third edition of the Delphi XE DataSnap Development Courseware manual to all current registered buyers from http://www.eBob42.com/courseware, at 190 pages - now also available as paperback from Lulu.com without updates to the paperback, I'm afraid. The paperback edition of the Delphi XE DataSnap Development courseware manual contains 190 pages, with sections about: DataSnap History and Example Data, DataSnap Server Targets (and Wizards), DataSnap Security, DataSnap Server Components, DataSnap Server Deployment, DataSnap Clients, DataSnap and Databases, DBX: DataSnap Filters, DataSnap REST and Callbacks, DataSnap and .NET Clients, and an appendix about the extended Developer Issue Report Tool (DIRT) Server and Client.
Read More

Working with C++ dll’s from ObjectPascal

It's a well known fact that there are many excelent libraries written in C++, and we, as Object Pascal programmers can take advantage of them. Many times, I have found in forums or mailing lists, questions such as "How can I translate XYZ library to ObjectPascal?", or "How can I use a C++ from Object Pascal?". Well, it's not necessary to translate a library from C++, we can use it just by creating a C wrapper around it.Why I need to wrap the C++ library to C?Because of name mangling, if you look inside the library (using TDump included in Delphi, or by using "nm" on linux), you'll get something like this:000DB314 794 0319 _ZN12DcmAgeStringC1ERKS_000DB274 795 031A _ZN12DcmAgeStringC2ERK6DcmTagm000DB2F0 796 031B _ZN12DcmAgeStringC2ERKS_000DB398 797 031C _ZN12DcmAgeStringD0Ev000DB368 798 031D _ZN12DcmAgeStringD1Ev000DB338 799 031E _ZN12DcmAgeStringD2Ev000DB3C8 800 031F _ZN12DcmAgeStringaSERKS_In the snippet from above, you can see names like _ZN12DcmAgeStringaSERKS. Those names may reffer to functions, methods, constants or variables we can call from Object Pascal by using GetProcAddress. The name in the example, is the "mangled" version of DcmAgeStringa. If the C++ doesn't expose classes, but functions, you can call the functions just by passing the mangled name to GetProcAddress, but what about working with classes?.There's no way to directly use a C++ class from Object Pascal, before using it is mandatory to create a "C" wrapper around it.Let's start by defining a simple C++ class with only one method:#include using namespace std;class Test{ public: Test(); void getHello(char * &AString); };Test::Test(){}void Test::getHello(char * &AString){ const char * str = "Hello World from C++"; strcpy(AString, str);}The class above, can be used with something like this:int main(){ Test * t = new Test(); char * str; t->getHello(str); cout << str;}It just gets change the value of the string "str" and print its contents.As I mentioned earlier, there's no way to create an instance of a C++ class from Object Pascal, but there's a workaround, to create a "C" wrapper around it, and export it from the library.Creating our first "C" wrapper around a C++ classThe idea is to create plain C functions in charge of creating an instance of the Test class, then return a pointer to that instance, then create another function that receive the pointer as param, and use its getHello function.Here's the code:#include #include using namespace std;class Test{ public: Test(); void getHello(char * &AString); };Test::Test(){}void Test::getHello(char * &AString){ const char * str = "Hello World from C++"; strcpy(AString, str);}extern "C"{ void createTestInstance(void * &instance) { instance = new Test(); } void doHello(void * instance, char * &AString) { Test * lInstance = (Test *) instance; lInstance->getHello(AString); } void deleteTestInstance(void * instance) { delete (Test *)instance; instance = NULL; }}If you look at the snippet above, you can see I added code inside an extern "C" block, there will reside the exported functions. I added three functions to create an instance of our class, to use the method getHello, and one to delete the instance.To create a dll from this code, just do this (I'm using Linux here, but you can use MinGW from Windows using the same command):g++ -fPIC -shared test.cpp -o test.soThat command compiles our code and creates a shared object file, in Windows you must replace "-o test.so" with "-o test.dll".Now you can check the contents of the library by using nm or tdump. The result should be something like this:...0000000000000c08 T _fini00000000000008b0 T _init0000000000000990 t call_gmon_start0000000000201068 b completed.74240000000000000ac5 T createTestInstance0000000000000b4e T deleteTestInstance0000000000000b21 T doHello0000000000201070 b dtor_idx.74260000000000000a30 t frame_dummy U strcpy@@GLIBC_2.2.5 U strlen@@GLIBC_2.2.5...You can see, that createTestInstance, deleteTestInstance and doHello now aren't mangled as in the plain C++ library. Now the fun part!The last step of this journey, is to create an Object Pascal program that loads and use the shared library. The program should do this:1) Load the library and store a reference to its handler.2) Execute the method createTestInstance and store a reference to the pointer it returns.3) Execute the method doHello by passing the pointer stored in point 2 as parameter.4) Delete the instance by executing deleteTestInstance and passing the same pointer.Here's the code:program Test;{$mode objfpc}{$H+}uses dynlibs;type TCreateInstance = procedure (var AInstance: Pointer); cdecl; TdoHello = procedure (AInstance: Pointer; var AString: PAnsiChar); cdecl; TDeleteInstance = procedure (AInstance: Pointer); cdecl;var lCreateInstance: TCreateInstance; ldoHello: TdoHello; lDeleteInstance: TDeleteInstance; lHandle: TLibHandle; lInstance: Pointer; lStr: PAnsiChar;begin lHandle := LoadLibrary('./test.so'); if lHandle NILHandle then begin writeln('Library loaded successfully!.'); lInstance := nil; // First, create the instance Pointer(lCreateInstance) := GetProcAddress(lHandle, 'createTestInstance'); if @lCreateInstance nil then lCreateInstance(lInstance); // Second, use the instance Pointer(ldoHello) := GetProcAddress(lHandle, 'doHello'); if @ldoHello nil then begin GetMem(lStr, 255); ldoHello(lInstance, lStr); writeln(lStr); FreeMem(lStr); end; // Third, delete the instance and unload the library Pointer(lDeleteInstance) := GetProcAddress(lHandle, 'deleteTestInstance'); if @lDeleteInstance nil then begin lDeleteInstance(lInstance); UnloadLibrary(lHandle); end; writeln('Done.'); end else writeln('Cannot load library.');end. That's all. Now you can use all your loved C++ libraries from Object Pascal!.
Read More

Why Microsoft and Nokia have a chance

Many iPhone and Android fans don't believe that Nokia and Microsoft have much chance to succeed. While everybody agrees that they wouldn't have a chance without good partners, few seem to agree that they can do much together. The most frequent explanation is that their level of innovation is too low, and their R&D doesn't really work. Most people, however, don't care about the phone producer's
Read More

Learn about Multi-Tier Application Development with DataSnap XE

Embarcadero has just published my new DataSnap white paper where you learn about Multi-Tier Application Development with DataSnap in RAD Studio XE, based on a small but real-world DataSnap application that covers just about everything you can imagine: from secure connections to simple server methods, server methods returning read-only datasets, datasetproviders returning master-detail datasets, with autoincrement primary keys (and how to handle those), using authentication and role based authorisation to secure not only the server methods but also the exposed datasetproviders, deployment and more.
Read More

Flotsam and Jetsam #23

Do you have TestComplete skills?  Do you know someone who has TestComplete skills? If so, we want to hire you. (Well, we don't necessarily want to hire you if you merely know someone with TestComplete skills, but you get the idea.  ) StackOverflow Question of the Week:  What are the pros and cons of using interfaces in Delphi? Lot’s of good discussion and some nice answers. THTMLWriter Update: I have finished and checked changes to fully support the <table> tag and its subordinate tags, including ensuring that they aren’t used out of order.  I have but three tags left (<dd>, <dl>, <dt>), and then I think I will be “done” in that I’ll declare it to be a “1.0” release.  At that point I’ll “freeze” the interface and won’t make any more changes to it.  Any subsequent additions will require a new interface at that point.  Your feedback gratefully accepted.  In addition, the IHTMLWriter interface now descends from ILoadSave to remove the duplication. I hereby officially declare Hodges’ Law: “The first person in an argument to compare the software development process to building automobiles loses that argument.” Danny Thorpe pointed me to this interesting article talking about using existing Wi-Fi connections to expand the coverage of a given network.  I’ve often wondered about this – that is, why don’t cell networks make it easy for people to expand their networks?  I’d be willing to bet that if you go to the mall, the Sprint Store (or the Verizon store, or the AT&T Store or the T-Mobile store) all have some sort of repeater or other type of device that ensure that their store has a five-bar signal.  (Who would buy a phone at the store where there is a weak phone signal?)   Why not put those all over the place?  Why not install them in office buildings, malls, airports, etc., where people are? Why not sell them (give them) to people to install in their homes?  Or why not make the phone able to call over any given WiFi network, allowing the phone to work even where there is no cell tower at all?  It seems to me that this is an unexplored and unexploited feature for cell network providers, and something that could drastically increase the already high value of a cell phone. Heck, I’d be willing to share some of my bandwidth with my neighbors to increase and improve the coverage in my neighborhood. Another great argument about why unit-testing is so cool and powerful from Uncle Bob.
Read More

Flotsam and Jetsam #20

My Dad got me this clock for Christmas and I now have it hanging on my wall at the office here at the World-wide Headquarters of Gateway Ticketing.  It is definitely an eye catcher and a conversation starter.  I was able to figure out some of the numbers (12, 6, 7, 8, and 11), but the rest I had to get from a blog post that explains them all.  I happy and honored to say that the Delphi Feed for my blog is now part of DelphiFeeds. Hopefully this will mean that these amazing pearls of wisdom will benefit a broader audience than just you fine people. We here at Gateway are in the process of migrating to Mercurial for our source control (I’ve probably mentioned that before….) and we are considering using bitbucket.org to host our repository.  Thus, I’ve created a small Delphi project there called DelphiClean. It’s not much right now, but it is serving the purpose of letting me see how things work on BitBucket.  I will update it in the future, particularly with the ability to provide a custom list of extensions to be “cleaned”. Now that Delphi has cool language features like Generics and Anonymous Methods, there is a lot of very cool code being written. Combine that with the ease of sharing code on places like GoogleCode, BitBucket, SourceForge, etc., and it ‘s a pretty cool time to be a developer.  The indefatigable Alex Ciobanu is a guy who is producing some amazing code.  Alex create the DeHL project, and now he’s created out of that a project called Collections.  Well worth a look.  The fun part is that Alex creates a full suite of unit tests for his code, so you can use it with confidence, and if you find a bug, you can write a failing unit test for him, and he can fix it, incorporate the now passing test, and we’ll all know if that bug appears again.  (There’s my daily pitch for unit testing….) In any event, Alex’s code is quite remarkable, and he’s a valuable member of the Delphi RTL team.  Here’s hoping some of this great code finds its way into the RTL. Danny Magin posts about the Developer Solutions Conference.  I wish I could go – alas, duty calls – but you can. (I’m particularly interested in the Android development stuff.  Alas)  Plus, it’s in Vegas, baby!
Read More

The future of C#, the bloat explosion, and what happened instead

Looking back on this video with Anders Hejlsberg, about the future of C#, from march 2009, or this blog post about the upcoming bloat explosion, seems quite awkward with the current explosion of iOS and especially Android. There are numerous awkward parts in the video: The focus on objects, the "huge amounts" of memory and the statement that multithreading is the exception. As readers of this
Read More

Android sells better than Windows to consumers

If you combine a few news articles, things get interesting: http://www.guardian.co.uk/technology/2010/nov/29/apple-ipad-cannibalising-pc-sales "Gartner forecasts that worldwide PC shipments for 2011 will reach 409m units" = 1.1 million per day. It is fair to expect less than 40% of these sales to be for consumers. This is an 18% growth, meaning that in 2010, we can expect PC sales to reach 138
Read More

R.I.P Microsoft Windows?

Microsoft is usually very good at presenting new products years ahead of the actual launch - but there continues to be a very remarkable absence of a single strategy for support of Windows applications or Windows as a well integrated desktop. Android provides many improvements that Windows does not offer as part of the standard platform: * Easy app discovery and installation (Android Market) *
Read More