Author Topic: O2 IUP  (Read 6551 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
Re: O2 IUP
« Reply #15 on: December 08, 2012, 04:02:59 AM »
Hi John,

Sorry for the delay, I have just had a cold, a real streamer.

There are a large number of permutations for declaring functions, including C style header declarations.

"!" replaces declare funcion or declare sub
You can also declare without specifying function or sub

To specify a variable number of parameters, use ellipsis

Use null for null parameters

They usually take the form of an integer specifying the number of params, followed by the ellipsis

Code: [Select]
function f (sys n,...) as sys
=============================
sys *p : @p=@n
indexbase 0
for i=1 to n
print p[i]
next
end function

f(3,10,20,30)


Using pure ellipsis is a little more tricky, and unusual. The offset will change when a function is exported, and/or 64bit.

Code: [Select]
function f (...) as sys
=======================
sys p
lea eax,[ebp]
mov p,eax
p+=2*sizeof sys
do
  if *p=0
    exit do
  end if
  print *p
  p+=sizeof sys
enddo
end function

f(3,10,20,30,null)


I could fully implement this form by making a parameter array available

Charles

Charles Pegge

  • Guest
Re: O2 IUP
« Reply #16 on: December 08, 2012, 08:14:06 AM »
You can use the original IUP headers (well almost!)

Code: OxygenBasic
  1. extern lib "iup.dll" cdecl
  2. include "iup.h"
  3. end extern  
  4.  
  5. IupOpen(null,null)  
  6. IupShow(IupDialog(IupLabel("Hello World!")))  
  7. IupMainLoop()  
  8. IupClose()  
  9.  

Modification to iup.dll
Code: C
  1. '===================================
  2. 'ADAPTATION FOR OXYGENBASIC Dec 2012
  3. '===================================
  4. 'typedef struct Ihandle_ Ihandle;
  5. 'typedef int (*Icallback)(Ihandle*);
  6. typedef void IHandle
  7. typedef sys  ICallback
  8. '===================================
  9.  

X

JRS

  • Guest
Re: O2 IUP
« Reply #17 on: December 08, 2012, 08:20:16 AM »
WOW!!!

And with a runny nose too.  ;D

Thanks Charles!

Here is a IUP function that has a variable argument list.

IupSetAtt

Can you show how this function would be defined or should I look at what you just uploaded in a zip?

Here is how this looks in your modified iup.h.

Code: C
  1. Ihandle*  IupSetAtt(const char* handle_name, Ihandle* ih, const char* name, ...);
  2.  
« Last Edit: December 08, 2012, 08:28:29 AM by JRS »

JRS

  • Guest
Re: O2 IUP
« Reply #18 on: December 08, 2012, 09:16:01 AM »
I was curious how you were handling the references to the other IUP header files from iup.h and I guess your not.



If I don't give BaCon (gcc) the -I/usr/include/iup compiler swithch, <iupkey.h> isn't found.

I finally understand what .o2h means. (or could mean)   :o
« Last Edit: December 08, 2012, 09:28:10 AM by JRS »

Charles Pegge

  • Guest
Re: O2 IUP
« Reply #19 on: December 08, 2012, 09:50:50 AM »
John,

You can work with the full set of iup headers, but the main extras to include are iupdef.h and iupkey.inc. These do not need to be altered. Then your example should be up and running.


JRS

  • Guest
Re: O2 IUP
« Reply #20 on: December 08, 2012, 10:54:49 AM »
Still issues.



Code: OxygenBasic
  1. extern lib "iup.dll" cdecl
  2. include "\iup\include\iup.o2h"
  3. include "\iup\include\iupdef.h"
  4. include "\iup\include\iupkey.h"
  5. end extern  
  6.  
  7. IupOpen(null,null)  
  8. IupShow(IupDialog(IupLabel("Hello World!")))  
  9. IupMainLoop()  
  10. IupClose()  
  11.  

Update

If I copy the iupdef.h and iupkey.h into the same directory as my helloiup.o2bas and modified iup.o2h, it compiles and runs. It would be nice to be able to point to an include directory outside the O2 environment.

Code: OxygenBasic
  1. extern lib "iup.dll" cdecl
  2. include "iup.o2h"
  3. end extern  
  4.  
  5. IupOpen(null,null)  
  6. IupShow(IupDialog(IupLabel("Hello World!")))  
  7. IupMainLoop()  
  8. IupClose()  
  9.  
« Last Edit: December 08, 2012, 11:03:26 AM by JRS »

Charles Pegge

  • Guest
Re: O2 IUP
« Reply #21 on: December 08, 2012, 11:27:19 AM »
Yes that's it.

If you want keek the headers in a separate folder you can use:

includepath "iup/"

this specifies a directory path relative to your main source code.

I agree it would be nice to assume a standard file path for major header files, like C does eg:  <stdio.h>

JRS

  • Guest
Re: O2 IUP
« Reply #22 on: December 08, 2012, 03:35:20 PM »
This will work fine. Thanks!

Code: OxygenBasic
  1. includepath "C:\iup\include\"
  2. extern lib "iup.dll" cdecl
  3. include "iup.o2h"
  4. end extern  
  5.  
  6. IupOpen(null,null)  
  7. IupShow(IupDialog(IupLabel("Hello World!")))  
  8. IupMainLoop()  
  9. IupClose()  
  10.  

JRS

  • Guest
Re: O2 IUP
« Reply #23 on: December 09, 2012, 07:50:09 AM »
@Peter - I hope you are having fun with IUP and just about finished with your remake of Google Earth in IUP.  ;D

Peter

  • Guest
Re: O2 IUP
« Reply #24 on: December 09, 2012, 09:15:25 AM »
Sure,  thanks  :D