Classes and objects in Shared Libaries or DLL's?

This is a discussion on Classes and objects in Shared Libaries or DLL's? within the Pascal forums in Programming Languages category; 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 ...

Go Back   Application Development Forum > Programming Languages > Pascal

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 03-24-2008, 05:49 AM
Bitty
Guest
 
Default Classes and objects in Shared Libaries or DLL's?

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.
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 12:02 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.