Archive for the ‘Windows’ Category

Join us at Data Rage 2

RemObjects will present Data Abstract in a vendor showcase session at the Embarcadero DataRage 2 online conference, that will take place May 25-27, 2010.

Currently our session “n-Tier in a Box: Data Abstract in Action” is scheduled on Thursday, May 27th from 06:00 to 06:45 PDT.

In this session you will see how easy it is to create a Data Abstract server in Delphi, access that from a Delphi Client and we additionally show you how to create a Relativity-hosted DA server, access this via REST from a browser and at the same time from a native Mac application written with DA/OS X.

I like to invite you to the online conference and I’m excited to see (well, rather read or hear ;-) ) you at Data Rage 2.

by Sebastian, May 15th, 2010

Delphi Prism in MonoDevelop at a glance

Our beta users (marc already did mention you can apply for the Prism beta here, didn’t he?) are already playing around with this for some time now, and we are going to ship it with the upcoming release: the Delphi Prism MonoDevelop integration. Marc already mentioned this some time ago and a lot has happened since then. This article should give you a ‘what is it and how could I start?’ introduction into Delphi Prism in MonoDevelop.

MonoDevelop LogoMonoDevelop is a free and open source .NET IDE. and has its roots in the also free and open-source SharpDevelop .NET IDE. With SharpDevelop still being a Windows-only IDE using Windows Forms, MonoDevelop (or in short MD, as we call it internally) was ported to Gtk# and massively extended in regards to cross-platform compatibility. It is now able to work smoothly on Linux, Mac OS X and, of course, Windows. You can use your solutions from Visual Studio with MD and vice versa, so you are able to have a single source solution for different platforms.

With the Delphi Prism MonoDevelop integration we target mainly the Mac and then Windows. For Windows we have the Visual Studio integration and we ship the Visual Studio Shell which is, in fact and to be honest, a far more comfortable and powerful IDE. That said: Of course we want to make sure that MonoDevelop on Windows (MD/Win) also works like a charm, but MD/Mac is of a higher priority because you don’t have an alternative IDE there.

The MD/Mac flavor of our MonoDevelop integration comes in form of a complete Mac application. It looks like it’s the original MonoDevelop, but additionally contains our Delphi Prism plug-in. That means you will have to install the MonoDevelop prerequisite by yourself (which is Mono >= 2.4). You can grab it here.

After startup, the Delphi Prism will tell you that it is not licensed and ask you to register your license (if you don’t have a Delphi Prism license yet you can get your copy and a 30-day trial key from the Delphi Prism download page).

When selecting “Start a new Solution” you have several options: The first one is a Console application, but you also have the choice to work with ASP.NET projects, create iPhone or iPod touch applications (be sure to have the iPhone SDK and at least the Trial of MonoTouch (http://monotouch.net/) installed for this) and you can build Moonlight applications (the Mono alternative to Silverlight).

For this article we’re going for an iPhone application. Not because we want you to go and buy you into the iPhone Developer Program and additionally buy MonoTouch from Novell, but just because it’s a neat thing to show ;)

In this dialog you see the options I set for the Hello world iPhone application. Be sure to meet the requirements (MD prereqs, iPhone SDK and MonoTouch) if you want to follow this article in code yourself. The next thing you’ll see is the MD editor with the project opened and ready to start.

We’re not going too deep into the MVC approach of the iPhone development, which is also the key to general Cocoa development, but you need to know that the UI is separated from your code. Unlike in Delphi or Windows forms where controls dropped on the form are automatically properties of your form class, you need to define which controls and events (called Actions) are visible to your code using defined classes.

The first thing we’re creating is the GUI. No demo without a ‘Hello World’, so we simply want to display the text entered in a text box on a label when the user presses a button. In the ‘Solution’ part of the MonoDevelop IDE to your left we expand the project and double-click on the ‘MainWindow.xib’ file. This should launch a program called ‘Interface Builder’ which belongs to the iPhone SDK. The .xib file is somewhat compareable to .dfm files you know from Delphi or like .Designer.pas files which define the layout of a Windows Forms form. The following part of designing the GUI and connecting the outlets and signals is in fact the most difficult if you never worked with interface builder. Because of that I also created a short video of this walk-through so that you have the chance to actually see what I’m going to describe now.

S1.png

On the ‘Library’ window you select the ‘Objects’ part on top and use the search box on the bottom to search for a ‘Toolbar’. Take it and drop it on the window and let it dock on the top. Then do the same for a ‘Text Field’ and a ‘Label’. You can drag them to the width that pleases you. Now that all controls are in place it’s time to make them accessible. In the ‘Library’ Windows please select ‘Classes’ on top and type ‘App’ in the search box. Then you can select the ‘AppDelegate’ class which is the interface between our application code and the GUI. Still in the library window select ‘Outlets’ in the lower half. We’re going to define accessors to the text field and the label now by clicking on the ‘+’ below the listed outlets and enter text and repeat that for label. Now we’re going to make our click event accessible by selecting ‘Actions’ instead of outlets and add the action ‘onClick:’ (mind the colon!) to the AppDelegate class.

The next task is to connect our outlets and the action to the controls. To do this, you simply select the toolbar button (labeled ‘Item’) in the window. In the property window you select the connections (white arrow on blue circle). There is an area called ‘Sent actions’ with an entry for ‘Selector’. Use the mouse and click in the circle to the right and drag this on the yellow ‘App Delegate’ box in the ‘MainWindow.xib’ window. On dropping you are able to select the action you want to link with the sent ‘selector’ action of the item. For both the text field and the label drag the ‘New referencing outlet’ circle on the App delegate and link them to the text and label outlets we defined before. Now you can press Apple+S to save the MainWindow.xib file.

MonoDevelop generates the code behind for us automatically. Please open the ‘MainWindow.xib.designer.pas’ file (expand the ‘MainWindow.xib’ node in your solution to find it) to have a loot at the generated code. Locate the

method onClick(sender: MonoTouch.UIKit.UIBarButtonItem); partial; empty;

line and copy it (withouth the empty;). Pase that in the ‘private’ section of the ‘AppDelegate’ class in the Program.pas file and double check that the empty; part did not get pasted too. This is the method that get’s called when the event (sorry, Signal ;-) ) fires from the GUI. In the implementation part complete the partial method and fill in it’s body:

method AppDelegate.onClick(sender: UIBarButtonItem);
begin
  label.Text := textbox.Text;
end;

In fact that’s all. Compile the project using the building blocks icon in the toolbar of MD (or by pressing Apple-B). Your code will be compiled into an assembly and the assemblies then will automatically be compiled in to native code for the iPhone by the MonoTouch compiler. When clicking on ‘Run’ or ‘Debug’ the iPhone simulator application should pop up and run our Hello world application:

S2.png

As you can see building an application for the iPhone using Delphi Prism is not only working, but you can make use of the full Cocoa API the iPhone SDK is offering you. Of course this only works if you have the iPhone SDK and MonoTouch, but to develop for the simulator as we just did, the free version of both is enough. You would only need to pay for the Apple developer program membership and for the MonoTouch licence if you’re going to deploy your programs on a physical device. In other words: Unless you want to start selling your application and earn money in return, you can work for free.

Here you can watch a little video that shows how the application was build:



Download this Video: as mp4 or in open ogg format.

This was a first feature preview of Delphi Prism in MonoDevelop and we hope you like it and stay tuned for more.

Sebastian

by Sebastian, March 29th, 2010

Everything is Relative

Today i want to talk a bit about “Relativity”, a new feature we’re shipping with Data Abstract this month (and which is actually available as “tech preview”in the current Winter 2009 releases).

“Relativity” is, simply put, a standalone server application that can be used to host Data Abstract schemas and serve data. In essence, it provides the complete Data Abstract middle tier, in a precompiled box and ready run. This offers several benefits, not the least of which are:

  1. No need to build your own. Relativity provides all the power and abstraction of a true Data Abstract middle tier server, without you actually having to create, build, and deploy your own executable. This allows you to concentrate on the client development. It also is really handy for prototyping, if you just want to have database server to talk to, without much work, even if you plan to eventually implementing your own custom server.
  2. Build on Data Abstract for .NET. .NET is platform with the most advanced version of DA – it supports our powerful DA SQL execution engine, and other features not available on all platforms. “Relativity” is being made available to all users of Data Abstract, so whether you’re a developer using .NET, Delphi, or Xcode, you can now write clients against Relativity that take full advantage of these features.

But let’s go and take a more detailed technical look at Relativity.

Relativity is a server application, so it does not provide any user interface. You can deploy a Relativity server in several ways, including:

  • Running it as a regular user application, on Windows.
  • Installing it as a Windows service.
  • Running it as a Unix daemon with the mono-service2 tool, on Mac and Linux.
  • Running it as a menubar item, on Mac.

Regardless of how you deploy and run it, Relativity will start making it’s Data Abstract services available on (by default) port 7099. But of course before it can start serving actual data, it will need to be configured with what data to serve. That is done thru the Relativity Server Admin tool, which is currently available for Windows (but versions for both Mac and iPhone are in the works).

When you first start it, the Admin tool will look something like this:

Screen shot 2010-02-03 at 2.24.03 PM.png

On the left hand side, you will see a tree view with all known instances of “Relativity” servers. This includes any servers (local or remote) that you connected to in the past, as well as any servers discovered on the local network using ROZeroConf.

Select any of the servers (here, “VEMMY” is the one instance running in my Windows VM), to connect and get more options.

Screen shot 2010-02-03 at 2.30.01 PM.png

The first two nodes allow you to configure how this “Relativity” server is accessed. This includes options such as what ports to listen on, what RemObjects SDK channels and messages to use, etc. Here you have the full choice of all the options provided by RO, you can choose the familiar HTTP, TCP, Super HTTP or other channels, BinMessage, SOAP Message, and so on.

Where it gets more interesting is the third node – Domains. This is where you configure the meat of the services Relativity is providing.

Each Domain corresponds to what typically would be a separate Data Abstract middle tier server. Domains are completely abstracted from one another and Relativity allows you to host as many separate domains as needed. With that, a single Relativity server can replace multiple DA servers, be it for related to completely independent applications or projects.

As you can see, i have three domains set up in my server, one for “BC7″, our new bug tracking system (using a PostgreSQL database running on our Xserve build server), one for “RemObjectsCom”, the database that drives our website (Microsoft SQL Server, running on the Windows server that hosts our website), and finally “OneSpace”, the database for a personal iPad project i am working on.

As we drill into a specific domain, you start seeing more things that will be familiar to you as a Data Abstract developer. Each domain can contain one or more Schemas – which correspond directly to .daSchema files or TDASchema components as you know them. You can manage schemas right there in the Admin tool, or directly launch Schema Modeler to edit the schema in question:

Screen shot 2010-02-03 at 2.39.38 PM.png

The domain also maintains a list of Connections to back-end databases available to it’s schemas. Once again, this directly corresponds to the .daConnections file or TDAConnectionManager component. Since Relativity is based on DA/.NET, these connections are based on the available DA/.NET drivers – regardless of whether your regular development platform is .NET, Delphi or Cocoa.

Another interesting part is the Login node. Relativity provides several options for handling authentication from client applications for data access (something you would normally need to manually implement, in a standalone DA server): in addition to relying on a static list of allowed username/password combinations, you can also choose to use a data table or command defined in one of the domain’s schemas to verify users (as i do in the example shown below) or query an external LDAP server for login.

The LDAP option is very handy if you are running a variety of services – some using Relativity, and some not – that you want to share user data among. We recently switched to LDAP for all our employee resources, and it has made administration so much easier.

The LDAP support in Relativity is based on a new 100% managed LDAP client implementation we’ve added to Internet Pack for this upcoming release. Carlo will blog more about this, soon.

Screen shot 2010-02-03 at 3.05.53 PM.png

The Login Provider architecture is extensible, so you can implement your own providers, for example if you need to do user authentication with a different method.

Client Access

Once you have Relativity set up to serve your data, your client application(s) can access it like any other Data Abstract server.

The only slight difference is that, since a Relativity server can host more than one domain, you need to tell the server which domain to access, by simply passing an additional Domain parameter as your login string, as in

User=foo;Password=bar;Domain=DomainName

You will also want to select which Schema to query. in regular DA applications, each schema usually has its own DataService, so keeping in line with that, Relativity allows you to append a schema name to the ServiceName property of your Remote Service. Instead of using DataService, simply use DataService.DomainName. (Alternatively, you can also pass a Schema to LoginEx).

In Closing…

So, this has been a brief introduction to Relativity – i hope you found it useful.

We think of Relativity as a strategic piece of Data Abstract, and it will play an increasing part in what we do for DA. We have lots of things planned for the future that will make Relativity even more powerful, such as our upcoming JavaScript Business Rules Scripting based on Carlo’s RemObjects Script for .NET.

You can try out the tech preview of Relativity now, and the official release will be part of what we ship at the end of this month. I’m looking forward to your thoughts and feedback!

marc

by marc hoffman, February 3rd, 2010

.NET 4.0 BigInteger support

The February release of Delphi Prism will include support for the new .NET 4.0 “BigInteger” type for all integer constants. BigInteger is a new class that let’s it’s users define an arbitrarily large integer. Using this new type for integer constants is simple in Delphi Prism:

  var r := 6985743574365784365432758943759843265983427594356349776534765743928657843567843625437564392067452985674398563429;
  var y := 8574398256943285643296524390;
  Console.WriteLine(y);
  Console.WriteLine(r);
  y := r - y;
  Console.WriteLine(y);

Output:

8574398256943285643296524390
6985743574365784365432758943759843265983427594356349776534765743928657843567843625437564392067452985674398563429
6985743574365784365432758943759843265983427594356349776534765743928657843567843625428989993810509700031102039039

Any constant that does not fit the largest type supported ((U)Int64) will become a BigInteger, or fail compiling if the new type isn’t referenced. BigInteger acts and works like a regular integer type, although it has some extra operations, like GreatestCommonDivisor, Remainder, Pow(er) and conversions to and from regular integer types.

by Carlo Kok, January 25th, 2010

Obfuscar

A few releases ago we switched to Obfuscar for obfuscation of our libraries, after some critical issues with the commercial obfuscator that we used. I’ve been providing the original authors with new issues and patches for things I fixed in the process of using this project (ranging from bugs to features), however it looks like the original project is dead.

So now at code.remobjects.com/p/obfuscar you can find the latest version with my changes and binaries of that version. Among the new features are:

* Unreadable unicode characters for obfuscated identifiers
* Signing assemblies

Enjoy,

by Carlo Kok, November 4th, 2009

Porting a Delphi/Win32 Code Parser to Delphi Prism

For an internal QA/Docs project, we’re working on a tool that, given a .NET library, Delphi .pas file or Objective-C .h file emits an XML file with all public types and members of those types. This tool will be used as part of the process to make sure we have all publicly accessible members documented in our wiki. There are few parsers available that understand all Delphi code (our own Prism parser does not support all Delphi/Win32 constructs, so it wasn’t an option for this little project), however there is one out there, that has always worked very well: mwdelpar, which Jacob Thurman took over as part of his work on Castalia: Castalia Delphi Parser. This is a free parser for Delphi licensed under the MPL.

Since I needed this to work in Delphi Prism, I spend an hour porting the code to Prism, and in this blog post I’ll cover some of the things I had to change to get it working.

Unit names and uses

For the 4 units involved, I had to change the unit header, as I wanted them all in the same namespace. The original looked like

unit CastaliaPasLex

I changed it to:

  {$IFDEF PRISM}
  Castalia.Pascal.Parser
  {$ELSE}
  CastaliaPasLex
{$ENDIF}

;

The second thing needed was to add a {$IFDEF PRISM} {$ENDIF} around the uses clauses.

After that I set the Allow Globals, Delphi Compatibility and the Allow Create keyword option and added {$IFDEF PRISM} {$ENDIF}around the destructors found in the file.

Making types public

Another difference in Prism is that the types are internal (assembly) by default and cannot be used outside the assembly. What I did is add {$IFDEF PRISM}public {$ENDIF} before the enums and classes I needed to expose.

Converting pointer to record to classes

The parser code had types like:

PDefineRec = ^TDefineRec;
TDefineRec = record
  Defined: Boolean;
  StartCount: Integer;
  Next: PDefineRec;
end;

This linked list could be converted to a generic LinkedList supported by .NET, but in this case it was much easier to just turn it into a class:

{$IFDEF PRISM}
  PDefineRec = TDefineRec;
{$ELSE}
  PDefineRec = ^TDefineRec;
{$ENDIF}
TDefineRec = {$IFNDEF PRISM}
  record
  {$ELSE}
  class public
  {$ENDIF}
  Defined: Boolean;
  StartCount: Integer;
  Next: PDefineRec;
end;

Most of the code that used this worked right away after that, except for the places it used a ^ to dereference the Next pointer.

Function pointers

The Prism compiler is a bit more strict when it comes to function pointers, especially when assigning a function to a variable of a function pointer type. A simple fix was to replace:

fIdentFuncTable[I] := Func15;

with

fIdentFuncTable[I] := {$IFDEF PRISM}@{$ENDIF} Func15;

Enum Members

The next part was slightly harder to do: Delphi Prism requires enums to be prefixed by the type that they’re defined in. This could be solved with a simple (interactive) search/replace in the file, since all keywords started with pt, I did a search/replace on ‘ pt’ and ‘[pt’ with ‘ {$IFDEF PRISM}TptTokenKind{$ENDIF}.pt’ or ‘[{$IFDEF PRISM}TptTokenKind{$ENDIF}.pt‘.

The Rest

After that, there were a only few small tweaks left to do, like changing calls to GetEnumValue to value.ToString, replace a few PChars with strings and a few RTL string functions to their .NET counter parts. All in all, it only took about an hour to convert the entire parser – and with the ifdefs I used it still compiles in Delphi/Win32, too.

by Carlo Kok, September 23rd, 2009

iPhone & Desktop Pairing with RemObjects SDK

One common scenario when developing iPhone apps is that you have a desktop application of some sorts that you want your iPhone to pair with – be it to sync data, remote control one with the other, or establish any other kind of communication.

In this scenario, the desktop app would be the “server”, in RemObjects SDK terminology, and the iPhone would be the client.

For the next release of RemObjects SDK for OS X, coming next month, we’ve created a nice sample that illustrates how to easily achieve this, and i figured i would post a small screencast of the sample in action, below.

What you see is a desktop app written in Delphi (although .NET will do just fine, as well), which for sample purposes has a pretty minimal UI, but in real life would be your full-fledged desktop UI app. When the iPhone client is a launched, it automatically detects any instance of your desktop app running on the local network and shows them in a list.

(The UI for this would be up to the application designer, obviously; for simplicity we simply show them all in a UITableView. In real life, if only one server was found you’d probably want to forgo the list altogether and just ask the user if he wants to connect).

Once the user picks a server, communication is initiated, by the iPhone calling a service method and passing it a unique GUID it generated. Since this is the first time these two are talking to each other, the server rejects the phone, but displays a random 4-digit code in it’s UI (this code is not known to the phone, at this stage). The phone asks the user to enter the code and, once done, sends it to the server to confirm the pairing. Once successful, the server stores the client’s GUID for future reference – and any future calls (even after the phone app has been restarted) will work right away.

Of course instead of showing an UIAlertView, your application would instead commence doing it’s real work.

Here’s the app in action:

by marc hoffman, September 18th, 2009

Delphi Prism, M.D.

Over the past couple months, a lot of progress has been made with getting Delphi Prism integrated into MonoDevelop. As mentioned before (and in our ROadmap), one of the “big” focuses in the current product cycle leading up to the August release next month has been a major refactoring of our internal IDE code, both in preparation for Visual Studio 2010 (Beta 1 of which which we’ll be supporting in August) and MonoDevelop.

So without further ado, below you will find the first ever screenshot of Delphi Prism being fully integrated into Mono Develop on the Mac:

Notice how we have a working Class Browser, Syntax Highlighting and Code Completion, as well as integrated building using MSBuild/XBuild.

Of course MonoDevelop is taking shape on Windows as well and of course (always has) runs on Linux, and Delphi Prism will integrate with it on all three platforms. Windows, i suppose, is the least exciting of these three options (after all, we already have Visual Studio, there), but having a native IDE running on either Mac or Linux should be a great boon for everyone using Delphi Prism to develop for these platforms.

So what’s the time line here, you’re asking? Good question! I cannot quite confirm a specific ship date, for two reasons. For one, while basic integration is working, there’s still a lot of Ts to dot and Is to cross. Lockdown for the August releases is imminent, so MonoDevelop definitely will not make it into that (also due to reason #2) – but then, hey, one new IDE per release should be enough, right?

Secondly, there’s still the remaining issue of MonoDevelop being licensed under GPL. The MD team, our team and a few contributors from the Delphi Prism community have done a great job moving this forward, but we still have some ~20 or so modules left that need to be rewritten before MonoDevelop is non-GPL and we can ship integration for it. Your help would be appreciated with this, so if you have some spare time, please check out our remobjects.public.oxgene.md-project newsgroup to see how you can help (or drop me a direct mail).

As far as our coding efforts go, i would think we should be ready to ship a preview of MonoDevelop support sometime between the August and November releases. i would also hope that come November, MD will be GPL-clean, and we can officially ship this in the November release of Delphi Prism*.

Also, what about Sharp Develop? To be honest, we’re undecided. While SharpDevelop (a Windows-only IDE for .NET and Mono) is closely related to MonoDevelop, it is different enough that supporting it would mean extra work. With MonoDevelop starting to look good on Windows now, we’re not sure if there’s much sense going thru the effort to integrate with SharpDevelop as well. What’s your thought on that? Can you see any benefits to SD support (that MD does not cover)?

*So if you’re buying RAD Studio 2010, not Delphi Prism standalone, make sure to get Software Assurance to be eligible for new features in November!
by marc hoffman, July 13th, 2009

CS2PAS 0.2

Just uploaded CS2PAS 0.2, this release should be able to do a conversion of the most common C# constructs. Download

Changes:

* 36: Bad conversion of array typed variable
* 37: Error during processing: Index was out of range.
* 40: Char constants declared like ‘\x1A’ cannot be converted
* 39: this. keyword is not converted to self.
* 30: && and || operators should automatically add parenthesis
* 29: simple “if (x) return” gets way to verbose
* 42: Class marked as internal is left using the internal keyword
* 31: DO for while, with and the others should do a space first
* 25: constructors get emitted with class name, in decl
* 24: “protected” gets translates as “assembly or protected”
* 26: inherited calls dont lose the dot
* 28: switch statement gets converted badly

by Carlo Kok, June 8th, 2009

Open source project website

For a while we’ve been looking for a good way of working with the open source projects we’re working on but never could find a good community website that was simple enough to install and maintain, but had all the features we needed.

So now we setup a simple website at http://code.remobjects.com for 3 projects:

  • ShineOn the delphi/Win32 compatibility library for Delphi Prism
  • Pascal Script the free script engine for Delphi
  • C# to Oxygene a new (unofficial) project I’ve been working on for a while to convert C# code to Oxygene.

Comments on the website appreciated, it’s not definitive yet but I like it so far.

by Carlo Kok, April 2nd, 2009