Compile with -Wall and fix all compiler warnings.
[AROS-Contrib.git] / bgui / miscc.c
blob6107d4617e3b5a3c26987fe08431e437d85640b3
1 #include "include/classdefs.h"
2 #include <utility/hooks.h>
3 #include <intuition/classes.h>
4 #include <intuition/cghooks.h>
5 #include <proto/alib.h>
6 #include <proto/exec.h>
7 #include <proto/utility.h>
8 #include <proto/graphics.h>
9 #include <proto/intuition.h>
10 #include <libraries/locale.h>
12 #ifndef BGUI_COMPILERSPECIFIC_H
13 #include <bgui/bgui_compilerspecific.h>
14 #endif
16 BOOL DisplayAGuideInfo(struct NewAmigaGuide *nag, Tag tag, ...)
18 AROS_SLOWSTACKTAGS_PRE_AS(tag, BOOL)
19 struct Library * AmigaGuideBase;
20 AmigaGuideBase = OpenLibrary("amigaguide.library",0);
22 retval = FALSE;
23 if (NULL != AmigaGuideBase)
25 AMIGAGUIDECONTEXT handle = OpenAmigaGuideA(nag, AROS_SLOWSTACKTAGS_ARG(tag));
26 if (0 != handle)
28 retval = TRUE;
29 CloseAmigaGuide(handle);
31 CloseLibrary(AmigaGuideBase);
33 AROS_SLOWSTACKTAGS_POST
36 ASM ULONG ScaleWeight(REG(d2) ULONG e, REG(d3) ULONG f, REG(d4) ULONG a)
38 ULONG r = UMult32(a,e);
39 return UDivMod32((f >> 1) + r, f);
42 //void MyPutChProc_StrLenfA(REG(d0) BYTE c, REG(a3) ULONG * putChData)
43 REGFUNC2(void, MyPutChProc_StrLenfA,
44 REGPARAM(D0, BYTE, c),
45 REGPARAM(A3, ULONG *, putChData))
47 (*putChData)++;
49 REGFUNC_END
51 ASM ULONG StrLenfA(REG(a0) UBYTE * FormatString, REG(a1) RAWARG DataStream)
53 ULONG c = 0;
54 RawDoFmt(FormatString, DataStream, ((APTR)MyPutChProc_StrLenfA), &c);
55 return c;
58 //void MyPutChProc_SPrintfA(REG(d0) char c, REG(a3) char **PutChData)
59 REGFUNC2(void, MyPutChProc_SPrintfA,
60 REGPARAM(D0, char, c),
61 REGPARAM(A3, char **, PutChData))
63 **PutChData = c;
64 (*PutChData)++;
66 REGFUNC_END
68 ASM VOID SPrintfA(REG(a3) UBYTE * buffer, REG(a0) UBYTE * format, REG(a1) RAWARG args)
70 RawDoFmt(format, args, ((APTR)MyPutChProc_SPrintfA), &buffer);
74 ASM REGFUNC3(VOID, LHook_Count,
75 REGPARAM(A0, struct Hook *, hook),
76 REGPARAM(A2, struct Locale *, loc),
77 REGPARAM(A1, ULONG, chr))
79 hook->h_Data++;
81 REGFUNC_END
83 ASM REGFUNC3(VOID, LHook_Format,
84 REGPARAM(A0, struct Hook *, hook),
85 REGPARAM(A2, struct Locale *, loc),
86 REGPARAM(A1, ULONG, chr))
88 char * cptr = (char *)hook->h_Data;
89 *(cptr++) = (char)chr;
90 hook->h_Data = cptr;
92 REGFUNC_END
95 ASM struct RastPort *BGUI_ObtainGIRPort(REG(a0) struct GadgetInfo * gi)
97 struct RastPort * rp;
98 BYTE * userdata = NULL;
100 if (NULL != gi)
102 if (NULL != gi->gi_Window)
103 userdata = gi->gi_Window->UserData;
105 if (NULL != gi->gi_Layer)
107 /* Does this make sense?? */
108 LockLayerRom(gi->gi_Layer); // this function returns void!!
109 UnlockLayerRom(gi->gi_Layer);
112 rp = ObtainGIRPort(gi);
113 if (NULL != rp)
114 rp->RP_User = (APTR)userdata;
116 return rp;
119 IPTR AsmDoMethod(Object * obj, STACKULONG MethodID, ...)
121 AROS_SLOWSTACKMETHODS_PRE(MethodID)
122 if (!obj)
123 retval = 0L;
124 else
125 retval = CallHookPkt ((struct Hook *)OCLASS(obj)
126 , obj
127 , AROS_SLOWSTACKMETHODS_ARG(MethodID)
129 AROS_SLOWSTACKMETHODS_POST
132 IPTR AsmDoMethodA(REG(a2) Object * obj, REG(a1) Msg message)
134 return DoMethodA(obj, message);
137 IPTR AsmDoSuperMethod( Class * cl, Object * obj, STACKULONG MethodID, ...)
139 AROS_SLOWSTACKMETHODS_PRE(MethodID)
140 if ((!obj) || (!cl))
141 retval = 0L;
142 else
143 retval = CallHookPkt ((struct Hook *)cl->cl_Super
144 , obj
145 , AROS_SLOWSTACKMETHODS_ARG(MethodID)
147 AROS_SLOWSTACKMETHODS_POST
150 IPTR AsmDoSuperMethodA( REG(a0) Class * cl, REG(a2) Object * obj, REG(a1) Msg message)
152 return DoSuperMethodA(cl,obj,message);
155 IPTR AsmCoerceMethod( Class * cl, Object * obj, STACKULONG MethodID, ...)
157 AROS_SLOWSTACKMETHODS_PRE(MethodID)
158 if ((!obj) || (!cl))
159 retval = 0L;
160 else
161 retval = CallHookPkt ((struct Hook *)cl
162 , obj
163 , AROS_SLOWSTACKMETHODS_ARG(MethodID)
165 AROS_SLOWSTACKMETHODS_POST
168 IPTR AsmCoerceMethodA( REG(a0) Class * cl, REG(a2) Object * obj, REG(a1) Msg message)
170 return CoerceMethodA(cl, obj, message);