forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Resolving LOC(Routine) to Subroutine Call (Porting woes #1)

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
JugoslavDujic



Joined: 10 Nov 2005
Posts: 7

PostPosted: Mon Nov 14, 2005 8:30 am    Post subject: Resolving LOC(Routine) to Subroutine Call (Porting woes #1) Reply with quote

I'm porting my Xeffort GUI library (www.xeffort.com) from Visual Fortran to FTN95 (among other compilers). The code uses a lot of "smart" non-standard tricks (since VF has pretty much full capabilites of C language) and I'm trying to find out how to find equivalent constructs in FTN95.

So, porting woe #1 is: the library contains a map of Windows messages (WM_WHATEVER) and user-registered handler routines (callbacks) for them. For each message, an address (LOC) of the handler routine is stored. When the routine is to be called by the library, it dereferences the pointer to the routine and calls it. In the original version, it used Cray pointers to routines (VF-specific). Later, I changed it to use VALUE/EXTERNAL mismatch, like:

[pre]
interface
MODULE XFTHandlerM

INTERFACE
LOGICAL FUNCTION WM_CLOSE_Handler(fnHandler,xWnd)
USE XFTTYPES
INTEGER, INTENT(IN):: fnHandler
!DEC$ATTRIBUTES VALUE:: fnHandler
TYPE(X_WINDOW):: xWnd
END FUNCTION
END INTERFACE
...
END MODULE XFTHandlerM

implementation (external procedure "driver")
!=================================================
LOGICAL FUNCTION WM_CLOSE_Handler(fnHandler, xWnd) RESULT(bHandled)
USE XFTTYPES
LOGICAL, EXTERNAL:: fnHandler
TYPE(X_WINDOW):: xWnd

bHandled = fnHandler(xWnd)
END FUNCTION
!=================================================

call
USE XFTHandlerM
...
CASE(WM_CLOSE)
bHandled = WM_CLOSE_Handler(lpfnHandler, xWnd)

[/pre]
Notice the mismatch between "interface" and "implementation". Alas, FTN95 does not appear to allow VALUE attribute for "native" Fortran code Sad .

So, what can I do? About the only think that comes to my mind is to use STDCALL declaration for the interface part, and F_STDCALL declaration for implementation part, but I'm not sure if linker will get it right. And I'd like to check out here before I start rewriting that part (cca. 100 interfaces and implementations)
_________________
%2D%2D%0D%0AJugoslav
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Tue Nov 15, 2005 1:13 am    Post subject: Resolving LOC(Routine) to Subroutine Call (Porting woes #1) Reply with quote

Jugoslav

You may get an idea for what you need by looking at the supplied include file win322api.ins.
You should certainly do some experiments on a small sample program before trying to change all of your calls.

I suspect that you may be the first to attempt to port to FTN95 from this environment.
There are usually ways that these problems can be solved but, to be honest, they are probably not within the level of support that we can provide via a free forum.
Back to top
View user's profile Send private message AIM Address
Anonymous
Guest





PostPosted: Fri Nov 18, 2005 7:49 pm    Post subject: Resolving LOC(Routine) to Subroutine Call (Porting woes #1) Reply with quote

Jaroslav,

I don't know if you are familiar with Clearwin+.

I would suggest to contact Salford Fortran developers
to incorporate some jewels and nicities of your Xeffort project into Clearwin
(for xample XGraph) so that your eXtreeme (and not so X) efforts will not be lost
and will be actually used by users of Salford Fortran.

Another idea would be to port Clearwin to other Fortran environments
as a external library. They all will find and and enjoy Windows programming
using Fortran.

Just a thought Smile

S
Back to top
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group