1. define_c_func .e file... Question

I also have a confusing one... having to put those stupid define_c_func,
and not knowing what to put in and expect. So, I planned on having an .e
file, with object definitions to take care of it. basically, like this:

(global?) object BeginPaint
BeginPaint = define_c_func(user32, "BeginPaint", {C_INT, C_POINTER},
C_INT)

^
and in the program, it would probably look like:     |

user32 = open_dll("user32.dll")                              |
BeginPaint = BeginPaint - - - - - - - - - - - - - - - - - -

Would this be correct? (doesn't to me. would I have to label it
something else in the .e file?)

new topic     » topic index » view message » categorize

2. Re: define_c_func .e file... Question

>(global?) object BeginPaint
>BeginPaint = define_c_func(user32, "BeginPaint", {C_INT, C_POINTER},
>C_INT)
>
>^
>and in the program, it would probably look like:     |
>
>user32 = open_dll("user32.dll")                              |
>BeginPaint = BeginPaint - - - - - - - - - - - - - - - - - -
>
>Would this be correct? (doesn't to me. would I have to label it
>something else in the .e file?)

I'm not exaclt sure what you want. You may want to try this to avoid the
whole DLL trick in your completely:

--(.e file)
user32 = open_dll("user32.dll")
BeginPaint_pointer = define_c_func(user32, "BeginPaint", {C_INT, C_POINTER},
C_INT)

global function BeginPaint (integer a, integer b)
    return c_func (BeginPaint_pointer, {a,b})
end function

--(.ex file)

? BeginPaint (a,b)

-- Where 'a' and 'b' are the the arguments to call the dll function.

To be honest, it suprised me dll functions are only available as pointers
and we have to do this manually.

The cleanest approuch would be:
(this is not the way Euphoria handles it, but I strongly suggest this:)

include_dll user32.dll

-- If you want to load dll's dynamically, then adjust both this syntax as
the syntax to open normal euphoria include files.

declare c_func BeginPaint ( C_INT, C_POINTER ) as C_INT

-- And if we need a pointer to it anyway:

bp_pointer = routine_id ("BeginPaint")

--Which we also call lile normal euphoria routines

? call_func (bp_pointer, {a,b})

-- 'a' and 'b' represent the appropiate arguments off course.

Any proc/cons ??

Ralf Nieuwenhuijsen
nieuwen at xs4all.nl

(And I know it isn't backwards compatible. But I think, only things that are
not backwards compatable can be considered to be improved, instead of
extended. Name one language, where the need for back-wards compatibilty at
the end didn't cost the language all its structure and finess ?)

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu