Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Ansi -iso > Classes and obj...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 206 of 211
Post > Topic >>

Classes and objects in Shared Libraries or DLL's?

by Bitty <bitty@[EMAIL PROTECTED] > Mar 23, 2008 at 09:28 PM

Hello,

I'm a newbee here, but not new on the programming edge with Pascal.
I'm writing a library to manage a personal office product for both Win32 
and Linux with FreePascal. Therefore, I have to write many objects wich 
I will bind in separated libraries.
To reduce the code and data overhead, I would like to include each code 
block only once in the complete library. That means that the total 
amount of code can be reduced to the smallest possible size.
The problem which raises now, is that I cannot export constructors, 
destructors, or functions from within objects or classes to a library 
file. Does anyone here have a solution to fix this problem?

To show the problem I have included some example coding at the end of 
this message.

Thanks in Advance!

Bitty.

[--- example code ---]

LIBRARY testobj;

TYPE  TColorType = OBJECT
         Red      : BYTE;
         Green    : BYTE;
         Blue     : BYTE;

         CONSTRUCTOR Init(R,G,B:BYTE); EXPORT;
         BEGIN
           IF ((R <> 0) OR (G <> 0) OR (B <> 0)) THEN SetColor(R,G,B);
           ELSE BEGIN
             Red   := 0;
             Green := 0;
             Blue  := 0;
           END;
         END; { TColorType.Init }

         DESTRUCTOR Done; VIRTUAL; EXPORT;
         BEGIN
         END; { TColorType.Done }

         PROCEDURE SetColor(R,G,B: BYTE); EXPORT;
         BEGIN
           IF (R <> 0) THEN Red   := R ELSE Red   := 0;
           IF (G <> 0) THEN Green := G ELSE Green := 0;
           IF (B <> 0) THEN Blue  := B ELSE Blue  := 0;
         END; { TColorType.SetColor }

         PROCEDURE SetRed(R:BYTE); EXPORT;
         BEGIN
           Red := R;
         END; { TColorType.SetRed }

         PROCEDURE SetGreen(G:BYTE); EXPORT;
         BEGIN
           Green := G;
         END; { TColorType.SetGreen }

         PROCEDURE SetBlue(B:BYTE); EXPORT;
         BEGIN
           Blue := B;
         END; { TColorType.SetBlue }

         FUNCTION  GetRed:BYTE; EXPORT;
         BEGIN
           GetRed := Red;
         END; { TColorType.GetRed }

         FUNCTION  GetGreen:BYTE; EXPORT;
         BEGIN
           GetGreen := Green;
         END; { TColorType.GetGreen }

         FUNCTION  GetBlue:BYTE; EXPORT;
         BEGIN
           GetBlue := Blue;
         END; { TColorType.GetBlue }

         PROCEDURE Output; EXPORT;
         BEGIN
           WriteLn('R:',Red,' G:',Green, ' B:',Blue);
         END; { TColorType.Output }

       END; { OBJECT: TColorType }

EXPORTS
   TColorType.GetBlue, TColorType.Done, TColorType.GetGreen, 
TColorType.GetRed,
   TColorType.Init, TColorType.Output, TColorType.SetColor, 
TColorType.SetBlue,
   TColorType.SetGreen, TColorType.SetRed;

END.




 1 Posts in Topic:
Classes and objects in Shared Libraries or DLL's?
Bitty <bitty@[EMAIL PR  2008-03-23 21:28:05 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed May 14 5:56:38 CDT 2008.