Re: [BLACKBOX] Using a simple DLL

From: [at]} <Wojtek>
Date: Tue, 19 Feb 2008 10:39:40 -0500

----boundary-LibPST-iamunique-415187860_-_-
Content-type: text/plain

Robert:

  just a guess. DLL stuff should be declared [untagged],
what removes the type-safe information from the runtime.
The DLLs are not meant to be type-safe, because there was no
such provision in Windows. I am guessing, that the type
"Real" declared in the DLL still has the type-safe tag,
but the DLL calling convention is using raw addresses,
because DLLs are not meant to be a part of the BlackBox
runtime. (They are parts of the Windows runtime, where
type safety does not exist.)

As a result, when you use the Real type declared in the DLL,
you end up overwriting the type-safety tag instead of the
record field "z".

Perhaps the compiler can be improved to treat the BB-generated
DLLs differently from the DLLs generated by other languages,
but this can possibly break other code.

If you really want to use DLLs, you need to follow the conventions,
which I laid out for your benefit in my PowerPoint presentation.
Use the keyword SYSTEM and use [untagged] records to interface
between the DLLs and the BlackBox system. The presentation is linked
in the 3rd paragraph of my home page. At the very end of the presentation
there are several examples of using the DLLs.

     http://www.pas.rochester.edu/~skulski/

Hope it helps,

Wojtek

On Tue, 19 Feb 2008, Campbell, Robert (SELEX GALILEO, UK) wrote:

> Hi
>
> Can anyone explain the following to me, I am
> rather out of my depth & baffled?
>
>
> The first module creates a small DLL.
>
> The second two test it. It all works fine.
>
> But when I redeclare sum by the commented line it crashes with
> an illegal memory read message.
>
>
> Thanks
>
> Robert.
>
>
>
>
> MODULE DemoAddFunction;
>
> TYPE
> Real = POINTER TO RECORD z : REAL END;
>
> PROCEDURE Addd* (a, b : REAL; sum : Real);
> BEGIN
> sum.z := a + b
> END Addd;
>
> END DemoAddFunction.
>
> <Q> DevLinker.LinkDll DemoAddDll.dll := DemoAddFunction# ~
>
>
>
> MODULE DemoAddInterface ["\BlackBox\DemoAddDll"];
>
> TYPE
> Real* = POINTER TO RECORD z* : REAL END;
>
> PROCEDURE Add* ['Addd'] (a, b : REAL; sum : ANYPTR);
>
> END DemoAddInterface.
>
>
>
>
> MODULE DemoAddTest;
>
> IMPORT DemoAddInterface, StdLog;
>
> TYPE
> Real* = POINTER TO RECORD z* : REAL END;
>
> PROCEDURE Do*;
> VAR
> sum : Real;
> (* sum : DemoAddInterface.Real; *)
> BEGIN
> NEW (sum);
> DemoAddInterface.Add (2.6, 6.1, sum);
>
> StdLog.String ('2.6 + 6.1 :'); StdLog.Real (sum.z); StdLog.Ln
> END Do;
>
> END DemoAddTest.
>
> <Q> DevDebug.Unload
>
> <Q> DemoAddTest.Do>
>
> SELEX Sensors and Airborne Systems Limited
> Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 3EL
> A company registered in England & Wales. Company no. 02426132
> ********************************************************************
> This email and any attachments are confidential to the intended
> recipient and may also be privileged. If you are not the intended
> recipient please delete it from your system and notify the sender.
> You should not copy it or use it for any purpose nor disclose or
> distribute its contents to any other person.
> ********************************************************************
>
>
> ----
> To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy
>
>


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-415187860_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIFJvYmVydDpccGFyDQpccGFyDQogIGp1c3QgYSBn
dWVzcy4gRExMIHN0dWZmIHNob3VsZCBiZSBkZWNsYXJl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QExJU1RTLk9CRVJPTi5DSFxwYXINCn0=
----boundary-LibPST-iamunique-415187860_-_---
Received on Tue Feb 19 2008 - 16:39:40 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:31:01 UTC