dotnetconnect andreas tönne, georg heeg ek. overview about overview.net demo architecture...

36
DotNetConn ect Andreas Tönne, Georg Heeg eK

Upload: lawrence-higgins

Post on 02-Jan-2016

229 views

Category:

Documents


1 download

TRANSCRIPT

DotNetConnect

Andreas Tönne, Georg Heeg eK

OverviewOverview

About

Overview .NET

Demo

Architecture

Limitations

Benchmarks

Conclusions

About Georg Heeg eKAbout Georg Heeg eK

100% Smalltalk since 1987

Offices in Dortmund

Köthen (Anhalt)

Zürich (CH)

Consulting, Product development

VisualWorks Support EMEA for Cincom

Windows CE platform

Overview of .NET (technical view)Overview of .NET (technical view)

Common language runtime (aka VM) for a family of typed languages

C#

C++

VB

many more

even some Smalltalk dialects

Overview of .NET (technical view)Overview of .NET (technical view)

Huge, ever growing libraries that eventually will cover all of Windows and more

Web services

ASP. Net

Longhorn, Visual Studio ...

Successor to COM/COM+/ActiveX

Overview of .NET (management view)Overview of .NET (management view)

The future platform for application development

Will replace everything else in 10 years

Seriously reduced costs in development and maintainace

Platform for web services

Demo ScenarioDemo Scenario

Existing Smalltalk applicationDemo: engineering domain/measuring tool

Need to interface to .NET-componentsNew hardware with new drivers

Replacement for COM-components

Someone listened to Microsoft marketing

How do we keep our investment in Smalltalk alive?

Live DemoLive Demo

1. Smalltalk and C#-Applications

2. Installation DotNetConnect

3. Running the wizard

4. OutputCompile, link and file in

5. The missing link

6. Application test

Live Demo Step #1Live Demo Step #1

Smalltalk application shows graphical transcript of points received in real-time

C# application publishes event carrying a Pointpublic delegate void PointEventHandler(object sender, PointEventArgs e);

public event PointEventHandler Coordinate;

Event created by moving the mouse

Live Demo Step #2Live Demo Step #2

Install DotNetConnectPoint to VM-bin directory for finding DLLs

Directories for generated code side-by-side with the image

Two flavors: runtime and wizard

Live Demo Step #3Live Demo Step #3

Running the wizard

A) Settings:Load the desired assembly

Adjust target package ‚from assembly‘

B) Check Types:Inspect not-importable types

Luckily we have none

(optional) will be run anyways

Live Demo Step #3Live Demo Step #3

C) Review kept/deleted codeoptional

D) Generate Code

Wizard finished

Live Demo Step #4Live Demo Step #4

Output (Sources-DLL):EventDemoProxy.mak

EventDemoProxy_class.h/cpp (managed)

EventDemoProxy_dll.h/cpp (unmanaged)

EventDemoProxy_eventClass.h

nmake EventDemoProxy.mak

copy EventDemoProxy.dll to VM directory

Live Demo Step #4Live Demo Step #4

Output (Sources-VW):EventDemoProxy_namespace.st

EventDemoProxy_ext_interface.stExternalInterface for EventDemoProxy.dll

EventDemoProxy_ext_stub.stWrapper for external interface with marshalling

EventDemoProxy_domain_stub.stObject-mapper for the wrapper for the external interface to the DLL

File In the sources...

Live Demo Step #5Live Demo Step #5

Hook the Smalltalk application to the EventDemo application

| dotNetInstance |

dotNetInstance := DotNET.Heeg.EventDemo New.

[DotNET.Heeg.EventDemo Main: dotNetInstance] forkAt: 51.

dotNetInstance upon: #EventDemoCoordinate send: #newSample:with: to: self

newSample: sender with: coordinate| dotNetPoint |

dotNetPoint := coordinate GetPoint.

currentSample := dotNetPoint X @ dotNetPoint Y

Live Demo Step #6Live Demo Step #6

Architecture - ChoicesArchitecture - Choices

Expensive:Web services

Intrusive:Corba

COM

Direct:Custom marshalling

Communication via TCP or C-calls

Proxy in .NET-world

There is no call-in interface in .NET!

Architecture - DotNetConnectArchitecture - DotNetConnect

EventDemo ExternalInterface

VW Managed .NET

EventDemo

EventDemo Stub

EventDemo

EventDemo Proxy DLL

Unmanaged .NET

Architecture - DotNetConnectArchitecture - DotNetConnect

Direct communication

Marshalling for all primitive data types, values and objects

Proxy is C-DLL with one end in the managed .NET-world

No reflection at runtime -> fast

Bridging the world delegated to the Microsoft C++-Compiler

Architecture – Call sequenceArchitecture – Call sequence

EventDemo ExternalInterface

VW Managed .NET

EventDemo

EventDemo Stub

EventDemo

EventDemo Proxy DLL

Unmanaged .NET

Code-ExamplesCode-Examples

EventDemo method invocationDotNET.Heeg.EventDemo Main: eventDemoInstance

Main: instance

EventDemoStub current Static_EventDemo_Main: instance objectId

EventDemoStub marshalling etc.Static_EventDemo_Main: instance

| errorCode instancePointer |

instancePointer := instance gcCopyToHeapUnicode.

errorCode := self externalInterface Static_EventDemo_Main: instancePointer.

self checkError: errorCode.

Architecture – Call sequenceArchitecture – Call sequence

EventDemo ExternalInterface

VW Managed .NET

EventDemo

EventDemo Stub

EventDemo

EventDemo Proxy DLL

Unmanaged .NET

Code-ExamplesCode-Examples

Call-out in EventDemoExternalInterfaceStatic_EventDemo_Main: instance

<C: int _threaded Static_EventDemo_Main(wchar_t* instance)>

^self externalAccessFailedWith: _errorCode

Call-in in EventDemoProxy.dll// Static System.Void Main (Heeg.EventDemo instance)

__declspec(dllexport) int Static_EventDemo_Main(wchar_t* instance)

{

reset_error();

return theProxy.Static_EventDemo_Main(instance);

}

Architecture – Call sequenceArchitecture – Call sequence

EventDemo ExternalInterface

VW Managed .NET

EventDemo

EventDemo Stub

EventDemo

EventDemo Proxy DLL

Unmanaged .NET

Code-ExamplesCode-Examples

Step into the managed .NET Worldint EventDemoProxy::Static_EventDemo_Main(wchar_t* instance)

{

int error_code = 0;

try

{

Object* raw1 = this->DeReferenceObject(instance);

Heeg::EventDemo* arg1 = __try_cast<Heeg::EventDemo*>(raw1);

Heeg::EventDemo::Main(arg1);

}

catch(Exception* ex)

{

....

Architecture – Call sequenceArchitecture – Call sequence

EventDemo ExternalInterface

VW Managed .NET

EventDemo

EventDemo Stub

EventDemo

EventDemo Proxy DLL

Unmanaged .NET

Code-ExamplesCode-Examples

The C# application[STAThread]

static public void Main(EventDemo instance)

{

Application.Run(instance);

}

Everything but this C# application is generated by the wizard!

C++ and VW 7 code

LimitationsLimitations

.NET-CLR is a superset of C# or C++

Not all legal types are importable because the DLL cannot be compiled

Some illegal types are detected

Some illegal types lead to compile errors

Members with overloaded signatures need manual case statement in Smalltalk

DetectedDetected

Value types without GetHashCode()

all sorts of unmanaged pointers

Multi-dimensional arrays and arrays of arrays

Visibility constraints of class types

Reserved words as parameter names

Events must have void return type and two parameters

Undetected, UnsupportedUndetected, Unsupported

Multi-dimensional arrays or arrays of arrays used as member fields

Multi-dimensional indexerAmbiguity of [x,y] and [x][y] unresolved

Delegates with Array parameters

Member that are inherited from multiple interfaces

Inherited from interface and overloaded

Ambiguity of short and wchar_t

Manual CorrectionsManual Corrections

Overloaded .NET MemberE.g.. Class System.Collections.Queue constructor

1. Queue (System.Collections.ICollection col)

2. Queue (System.Int32 capacity)

Needs manually written case statement in Smalltalk-method

BenchmarksBenchmarks

Measured on 1140MHz, 256MB AthlonMethod invocation: 0,7 µS

Scalar parameter: not measurable

n reference parameters: 6+16n µS

n type Object parameters: 17+22n µS

Return valuesScalar: 19 µS

Reference: 61 µS

Type Object: 87 µS

Instance creation: 130 µS

Further optimizations pending

ConclusionsConclusions

Automated generation of .NET-interface

Wizard-driven with manual control

‚No brainer‘ in almost all cases

No C++ knowledge necessaryunless hit by type limitations

Fast

Future DevelopmentFuture Development

Next major step: DotNetConnect becomes NConnect

100% integrated in Visual Studio

Project-Wizard generated Solution

.NET-GUI inside VisualWorks

Georg Heeg eKBaroper Str. 337D-44227 DortmundTel: +49-231-97599-0Fax: +49-231-97599-20

Email: [email protected]://www.heeg.de

Georg Heeg AGRiedtlistr. 8

CH-8006 ZürichTel: +41-1-356 3311Fax: +41-1-356 3312

Georg Heeg eKMühlenstr. 19

D-06366 KöthenTel: +49-3496-214 328Fax: +49-3496-214 712

2004 Cincom Systems, Inc. All Rights Reserved

Developed in the U.S.A.CINCOM, , and The World’s Most Experienced Software Company are trademarks or registered trademarks

of Cincom Systems, Inc

All other trademarks belong to their respective companies.