Author:admin

Date:2011-04-12T16:13:35.000000Z


git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@871 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
jfiat
2011-04-12 16:13:35 +00:00
parent 741c980889
commit a1f0e2f9b0

View File

@@ -30,39 +30,39 @@ extern size_t one_param_return(FILE *f);</code>
Here is the corresponding Eiffel code: Here is the corresponding Eiffel code:
<code> <code>
c_no_param c_no_param
-- Encapsulation of a C routine with no parameter. -- Encapsulation of a C routine with no parameter.
external external
"C | %"my_header.h%"" "C | %"my_header.h%""
alias alias
"no_param" "no_param"
end end
c_one_param (i: INTEGER) c_one_param (i: INTEGER)
-- Encapsulation of a C routine with one parameter. -- Encapsulation of a C routine with one parameter.
external external
"C (int) | %"my_header.h%"" "C (int) | %"my_header.h%""
alias alias
"one_param" "one_param"
end end
c_no_param_return: INTEGER c_no_param_return: INTEGER
-- Encapsulation of a C routine with no parameter -- Encapsulation of a C routine with no parameter
-- returning an INTEGER -- returning an INTEGER
external external
"C (): EIF_INTEGER| %"my_header.h%"" "C (): EIF_INTEGER| %"my_header.h%""
alias alias
"no_param_return" "no_param_return"
end end
c_one_param_return (p: POINTER): INTEGER c_one_param_return (p: POINTER): INTEGER
-- Encapsulation of a C routine with one parameter -- Encapsulation of a C routine with one parameter
-- returning an INTEGER -- returning an INTEGER
external external
"C (FILE *): EIF_INTEGER| %"my_header.h%"" "C (FILE *): EIF_INTEGER| %"my_header.h%""
alias alias
"one_param_return" "one_param_return"
end</code> end</code>
<span id="macros"></span> <span id="macros"></span>
@@ -82,29 +82,29 @@ Then, the corresponding Eiffel code will look like:
<code> <code>
menu_id: INTEGER menu_id: INTEGER
-- `ID_MENU' C encapsulation. -- `ID_MENU' C encapsulation.
external external
"C [macro %"my_header.h%"] : EIF_INTEGER" "C [macro %"my_header.h%"] : EIF_INTEGER"
alias alias
"ID_MENU" "ID_MENU"
end end
menu_id_character: CHARACTER menu_id_character: CHARACTER
-- `ID_MENU_CHARACTER' C encapsulation. -- `ID_MENU_CHARACTER' C encapsulation.
external external
"C [macro %"my_header.h%"] : EIF_CHARACTER" "C [macro %"my_header.h%"] : EIF_CHARACTER"
alias alias
"ID_MENU_CHARACTER" "ID_MENU_CHARACTER"
end end
i_th (p: POINTER; i: INTEGER): INTEGER i_th (p: POINTER; i: INTEGER): INTEGER
-- Access the `i'-th element of `p', array of C EIF_INTEGER. -- Access the `i'-th element of `p', array of C EIF_INTEGER.
external external
"C [macro %"my_header.h%"] (EIF_INTEGER *, EIF_INTEGER): EIF_INTEGER" "C [macro %"my_header.h%"] (EIF_INTEGER *, EIF_INTEGER): EIF_INTEGER"
alias alias
"i_th" "i_th"
end</code> end</code>
<span id="structs"></span> <span id="structs"></span>
@@ -125,37 +125,37 @@ typdef struct point {
Then, the corresponding Eiffel code will look like: Then, the corresponding Eiffel code will look like:
<code> <code>
x (p: POINTER): INTEGER x (p: POINTER): INTEGER
-- Access field x of struct pointed by `p'. -- Access field x of struct pointed by `p'.
external external
"C [struct %"my_header.h%"] (Point): EIF_INTEGER" "C [struct %"my_header.h%"] (Point): EIF_INTEGER"
alias alias
"x" "x"
end end
y (p: POINTER): INTEGER y (p: POINTER): INTEGER
-- Access field y of struct pointed by `p'. -- Access field y of struct pointed by `p'.
external external
"C [struct %"my_header.h%"] (Point): EIF_INTEGER" "C [struct %"my_header.h%"] (Point): EIF_INTEGER"
alias alias
"y" "y"
end end
set_x (p: POINTER; v: INTEGER) set_x (p: POINTER; v: INTEGER)
-- Set field x of struct pointed by `p'. -- Set field x of struct pointed by `p'.
external external
"C [struct %"my_header.h%"] (Point, int)" "C [struct %"my_header.h%"] (Point, int)"
alias alias
"x" "x"
end end
set_y (p: POINTER: v: INTEGER) set_y (p: POINTER: v: INTEGER)
-- Set field y of struct pointed by `p' with `v'. -- Set field y of struct pointed by `p' with `v'.
external external
"C [struct %"my_header.h%"] (Point, int)" "C [struct %"my_header.h%"] (Point, int)"
alias alias
"y" "y"
end</code> end</code>
<span id="windows"></span> <span id="windows"></span>
@@ -171,17 +171,17 @@ Therefore if you want to call an external routine defined in a DLL supposed to b
<code> <code>
my_cdecl_routine (a: INTEGER): POINTER my_cdecl_routine (a: INTEGER): POINTER
-- Encapsulation of a dll function with the `_cdecl' call mechanism. -- Encapsulation of a dll function with the `_cdecl' call mechanism.
external external
"C [dll32 %"my_dll.dll%"] (int): EIF_POINTER" "C [dll32 %"my_dll.dll%"] (int): EIF_POINTER"
end end
my_stdcall_routine (a: INTEGER): POINTER my_stdcall_routine (a: INTEGER): POINTER
-- Encapsulation of a dll function with the `_stdcall' call mechanism. -- Encapsulation of a dll function with the `_stdcall' call mechanism.
external external
"C [dllwin32 %"my_dll.dll%"] (int): EIF_POINTER" "C [dllwin32 %"my_dll.dll%"] (int): EIF_POINTER"
end</code> end</code>
{{warning|Using '''dll32''' in cases calling for '''dllwin32''' and vice versa will cause your system to crash, because the C call stack will be corrupted. For more information please read your C compiler documentation. }} {{warning|Using '''dll32''' in cases calling for '''dllwin32''' and vice versa will cause your system to crash, because the C call stack will be corrupted. For more information please read your C compiler documentation. }}
@@ -207,13 +207,13 @@ In WEL, the encapsulation is written as:
<code> <code>
cwin_send_message (hwnd: POINTER; msg, wparam, param: INTEGER) cwin_send_message (hwnd: POINTER; msg, wparam, param: INTEGER)
-- SDK SendMessage (without the result) -- SDK SendMessage (without the result)
external external
"C [macro %"wel.h%"] (HWND, UINT, WPARAM, LPARAM)" "C [macro %"wel.h%"] (HWND, UINT, WPARAM, LPARAM)"
alias alias
"SendMessage" "SendMessage"
end</code> end</code>
{{seealso|<br/> {{seealso|<br/>