The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,854 other subscribers

Archive for the ‘Delphi’ Category

Stefan Glienke on Delphi generics: Implementing List Enumerator OfType in Delphi – Stack Overflow

Posted by jpluimers on 2012/06/26

Stefan Glienke posted a nice StackOverflow answer on some things to watch for when using Delphi Generics to implement an IEnumerator of type for a generic usage that works better than the stock one.

–jeroen

via:generics – Implementing List Enumerator OfType in Delphi – Stack Overflow.

Posted in Delphi, Development, Software Development | 3 Comments »

Repeating characters into strings in C# and Delphi (via: .net – Best way to repeat a character in C# – Stack Overflow)

Posted by jpluimers on 2012/06/26

Switching back and forth between mainly Delphi and C#, sometimes it is hard to remember which idiom works best in each environment.

Recently, I had to dupe a lot of tab characters for some Tab-Delimited interface to an archaic system.

I remembered the Delphi idiom: use the DupeString function as about Delphi explains (yes, I know: it dupes more than just characters).

In C#, these work best for me:

Small code sample of the first way (thanks CMS):

static string Tabs(int n)
{
    return new String('\t', n);
}

–jeroen

via: .net – Best way to repeat a character in C# – Stack Overflow.

Oh BTW: I have reduced my StackOverflow presence. It looks like the success of StackOverflow made them instantiate many moderators. A lot of those moderators work under the mantra “we follow the rules strictly, and favour punishment over encouragement” (some  even talk about “changing heritage“). That’s a real pity, as I see a lot of StackOverflow users get scared by the very active downvoting, question/answer closing and even deletion of material that is in essence valuable, if it were edited up a bit. Deleting content is always bad, as it increases the link rot that StackOverflow are trying to prevent in questions/answers as per their FAQ. Links are the foundation of the web.

Alas, devoting real attention to the quality of StackOverflow requires putting real energy in it, which for some of the moderators seems to be too much to ask.

Posted in .NET, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Delphi, Development, Pingback, Software Development, Stackoverflow | 5 Comments »

Delphi: [##] numbers in DFM files determine order of subcomponents (via: Strange [number]s in Delphi DFM files – origin and necessity? – Stack Overflow)

Posted by jpluimers on 2012/06/21

Another interesting SO thread that explains [##] numbers in DFM files.

They are used to determine the order of subcomponents when using form/frame inheritance.

–jeroen

via: Strange [number]s in Delphi DFM files – origin and necessity? – Stack Overflow.

Posted in Delphi, Development, Software Development | Leave a Comment »

Strong name for Interop.Scripting – .NET Framework

Posted by jpluimers on 2012/06/20

So I won’t forget:

I was trying to generate from the interop.scripting.dll which I guess was the automatically generated dll without strong naming. A wrapperof a wrapper apperently doesnt work.
The following did work:

tlbimp.exe C:\WINDOWS\system32\scrrun.dll /keyfile:..\nameHere.snk /out:Interop.Scripting.StrongNamed.dll

The suite of .NET projects I’m refactoring relies in part on scripting in the Microsoft Script Runtime because the original was build by people bringing their COM love from the VB6 world into the .NET world.

I don’t see COM as the first class citizen it was in the VB6 era. On the other hand, COM and ActiveX play an important role in the .NET world. Sometimes I regret that, as dealing with COM is hard.

Some consider COM a first class citizen in .NET as it was in VB6, especially after the dynamic keyword was added in C# 4.0. The variant type available since Delphi 2 since 1996 does more or less the same as dynamic keyword in C#. I know how Anders Heijlsberg disliked the Delphi Variant support of COM. But COM is what the market wanted in 1996, and that seems true until today.

But I digress.

At least parts of the .NET code needs to become strongly named, so I’m hesitating:

  1. kick out the COM stuff – and verify through unit tests that the encompassing code still works – or
  2. generate a strongly named COM Interop Wrapper as described above.

Not sure yet.

Opinions anyone?

Anyway, I’m expecting a few problems here and there, so I’ll be using the CLR Interop Tools like the P/Invoke Interop Assistant and Type Library Importer in Managed Code where needed.

–jeroen

via: Strong name for Interop.Scripting – .NET Framework.

Posted in .NET, C#, Delphi, Development, Software Development, VB.NET | 1 Comment »

Delphi: interesting SO question + answer on using AllocateHWND to route TThread messages to a message handler in a TObject descendant (via: delphi – Custom Messages in Non-Windowed Classes – need a default handler? – Stack Overflow)

Posted by jpluimers on 2012/06/19

The delphi – Custom Messages in Non-Windowed Classes – need a default handler? – Stack Overflow thread on SO is very interesting.

It explains how to use AllocateHWND to route messages for a TThread into a message handler of an object instance.

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

There are reasons why Delphi is not C++ (via: Entropy Overload: One-liner RAII in Delphi)

Posted by jpluimers on 2012/06/06

There was a nice short discussion on Entropy Overload where Ivan Levanshew seemed to want to be Delphi way more C++ and Barry Kelly explains why Delphi isn’t C++.

Both Delphi and C++ are great languages, but both have weaknesses too. It is good that their individual strengths complement each other, and their weaknesses don’t crossover too much.

Ivan Levashew said…

It’s XE2 now, and there is still no proper RAII despite Delphi runtime already having all the required functionality for years. Variants copying and destruction is an example.

It’s a pity. Read the rest of this entry »

Posted in C++, Delphi, Delphi XE2, Development, Software Development | 1 Comment »

Some links on the Delphi compiler and the LLVM Compiler Infrastructure Project

Posted by jpluimers on 2012/06/05

A long while ago I read about Embarcadero Discussion Forums: Barry Kelly on LLVM … I think it was 2010, the thread is gone now (probably because the Embarcadero forum index does not go back more than one year), but the title still shows up at Google search: Barry+Kelly+on+LLVM

Barry Kelly is one of the Delphi compiler engineers, so it got me thinking and made me archive some links (I wish I had archived the content as well as the Wayback Machine didn’t archive some defunct links.)

Today Paweł Głowacki presents the Mac and Mobile Development for Windows Developers event and indicated future Delphi compiler platform targets like ARM will indeed make use of the The LLVM Compiler Infrastructure Project..

(if you still want to come: you are welcome, there are a few spots left; The event is June 5, 2012 at 9:30 AM – 1:30 PM
at the High Tech Campus Eindhoven Conference Center, The Strip).

Delphi leveraging LLVM for ARM is important in more than a few ways: Read the rest of this entry »

Posted in Delphi, Development, FireMonkey, OS X FMX, Software Development | 10 Comments »

Pointers to value and to reference types (was: delphi – Why does TValue.Make require a pointer to an object reference? – Stack Overflow)

Posted by jpluimers on 2012/05/30

Delphi seemingly makes the distinction between reference and value types disappear, especially because it hides the ^derefererncing operator for most usages:

  • there is no ^ dereferencing operator when following “class” type object instances, “interface” references and “object” type object instances, strings, open arrays and dynamic arrays: the dereferencing is implicit
  • usually you do not need the ^ dereferencing operator when

Rudy Velthuis wrote a great article on pointers in general. Though it was in the Delphi 2009 timeframe, almost everything is very valid. A few things are missing, some additions are below.

I’m not going into deep detail here right now, just a few notes to get people interested going.

Hopefully I will some time in the future to either go into more detail, or point to articles that do.

  1. “object” style object instances.
    Those have been deprecated since Delphi 1 (which introduced “class” style objects), but there are still libraries that use them, and (almost unbeleivable): they are supported in Delphi x64
  2. anonymous method references
  3. Events (method references) aka the “procedure … of object”/”function … of object”
    are implemented using the underlying TMethod type from the System unit
    always use the “Assigned” method to check if both the Data and Method field are non-nil

Even with those additions to Rudy’s list, I’m not 100% sure everything is complete now (:

–jeroen

via: delphi – Why does TValue.Make require a pointer to an object reference? – Stack Overflow.

Posted in Delphi, Development, Software Development | 4 Comments »

What you need on your Mac to develop for OS X or iOS using Delphi XE2

Posted by jpluimers on 2012/05/29

Just a few notes on things I told Delphi cross development students over the last nine months or so.

For Mac OS X apps:

  • The Platform Assistant Server that ships with Delphi XE2

For iOS apps:

Steps:

  1. Become a registered Apple Developer
  2. Download and install xCode 4 when you run on OS X 10.7 Lion or higher, or
    Download and install xCode 3 when you run on OS X 10.6 Leopard
  3. Download and install FreePascal 2.4.4
xCode includes the iOS SDK
Delphi uses the Delphi compatibility mode of FreePascal.

–jeroen

via: Developer Tools Overview – Apple Developer.

Posted in Delphi, Delphi XE2, Development, Software Development, xCode/Mac/iPad/iPhone/iOS/cocoa | 1 Comment »

Dodgy Coder: Coding tricks of game developers

Posted by jpluimers on 2012/04/26

Some very interesting tips from game development that apply juts as well to general software development.

On code health:

Now I always try to dig right down to the root cause of a bug, even if a simple, and seemingly safe, patch is available. I want my code to be healthy. If you go to the doctor and tell him “it hurts when I do this,” then you expect him to find out why it hurts, and to fix that.

Though tools like SourceMonitor can help you track your code health, the best tool is between your ears.

–jeroen

via: Dodgy Coder: Coding tricks of game developers.

Posted in .NET, Batch-Files, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Delphi, Delphi x64, Delphi XE2, Development, JavaScript/ECMAScript, PHP, PowerShell, Scripting, Software Development | 1 Comment »