Search the web
Sign In
New User? Sign Up
amithlondev · Amithlon-Dev
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Amithlon native software & MUI ?   Message List  
Reply | Forward Message #293 of 313 |
Re: Amithlon native software & MUI ?

Hello Martin,

On 13.03.04, you wrote:

> Yes, of course. I assume you're talking about the dispatcher? Just use
> HookEntry and there is no need to worry about registers.

> If that's not what you meant, perhaps it's better if you post a small
> code example of what you want to do.

Well I think this is a dispatcher. I've never written anything for MUI and
have no experience with it.
I get this error message:

YAM.c:425: syntax error before `void'
YAM.c:590: syntax error before `void'

and begining with the 425th line we can see this fragment of code:

==========

HOOKPROTONHNONP(AY_GoPageFunc, void)
{
GotoURL("http://www.yam.ch/");
}

==========

HOOKPROTONHNONP is defined in the SDI_Hook.h which I enclose.
As you can see it's full of m68k registers. Isn't it then architecture
related ?

Thanks in advance for any help and best regards,
--

Mi³osz 'Softfailur' Staszewski
sofcik@...


Sat Mar 13, 2004 2:06 pm

sofcik@...
Send Email Send Email

#ifndef SDI_HOOK_H
#define SDI_HOOK_H

/* Includeheader

Name: SDI_hook.h
Versionstring: $VER: SDI_hook.h 1.6 (02.03.2004)
Author: SDI
Distribution: PD
Description: defines to hide compiler specific hook stuff

1.0 21.06.02 : based on the work made for freeciv and YAM with
additional texts partly taken from YAM_hook.h changes made
by Jens Langner, largely reworked the mechanism
1.1 07.10.02 : added HOOKPROTONP and HOOKPROTONONP requested by Jens
1.2 18.10.02 : reverted to old MorphOS-method for GCC
1.3 08.02.04 : modified to get it compatible to AmigaOS4
1.4 17.02.04 : modified to get compatible to latest SDI_compiler.h changes
1.5 02.03.04 : added UNUSED define to OS4 hook specification so that the
compiler can ignore some warnings.
1.6 02.03.04 : added (APTR) casts to MorphOS prototype definition to
reduce compiler warnings.
*/

/*
** This is PD (Public Domain). This means you can do with it whatever you want
** without any restrictions. I only ask you to tell me improvements, so I may
** fix the main line of this files as well.
**
** To keep confusion level low: When changing this file, please note it in
** above history list and indicate that the change was not made by myself
** (e.g. add your name or nick name).
**
** Dirk Stöcker <stoecker@...>
*/

#include "SDI_compiler.h"

/*
** Hook macros to handle the creation of Hooks/Dispatchers for different
** Operating System versions.
** Currently AmigaOS and MorphOS is supported.
**
** For more information about hooks see include file <utility/hooks.h> or
** the relevant descriptions in utility.library autodocs.
**
** Example:
**
** Creates a hook with the name "TestHook" that calls a corresponding
** function "TestFunc" that will be called with a pointer "text"
** (in register A1) and returns a long.
**
** HOOKPROTONHNO(TestFunc, LONG, STRPTR text)
** {
** Printf(text);
** return 0;
** }
** MakeHook(TestHook, TestFunc);
**
** Every function that is created with HOOKPROTO* must have a MakeHook() or
** MakeStaticHook() to create the corresponding hook. Best is to call this
** directly after the hook function. This is required by the GCC macros.
**
** The naming convention for the Hook Prototype macros is as followed:
**
** HOOKPROTO[NH][NO][NP]
** ^^ ^^ ^^
** NoHook | NoParameter
** NoObject
**
** So a plain HOOKPROTO() creates you a Hook function that requires
** 4 parameters, the "name" of the hookfunction, the "obj" in REG_A2,
** the "param" in REG_A1 and a "hook" in REG_A0. Usually you will always
** use NH, as the hook structure itself is nearly never required.
**
** The DISPATCHERPROTO macro is for MUI dispatcher functions. It gets the
** functionname as argument. To supply this function for use by MUI, use
** The ENTRY macro, which also gets the function name as argument.
*/

#if !defined(__MORPHOS__) || !defined(__GNUC__)
#if defined(__amigaos4__)
#define HOOKPROTO(name, ret, obj, param) static SAVEDS ASM ret \
name(REG(a0, struct Hook *hook), REG(a2, obj), REG(a1, param))
#define HOOKPROTONO(name, ret, param) static SAVEDS ASM ret \
name(REG(a0, struct Hook *hook), REG(a2, UNUSED APTR obj), \
REG(a1, param))
#define HOOKPROTONP(name, ret, obj) static SAVEDS ASM ret \
name(REG(a0, struct Hook *hook), REG(a2, obj), \
REG(a1, UNUSED APTR param))
#define HOOKPROTONONP(name, ret) static SAVEDS ASM ret \
name(REG(a0, struct Hook *hook), REG(a2, UNUSED APTR obj,), \
REG(a1, APTR param))
#define HOOKPROTONH(name, ret, obj, param) static SAVEDS ASM ret \
name(REG(a0, UNUSED struct Hook *hook), REG(a2, obj), REG(a1, param))
#define HOOKPROTONHNO(name, ret, param) static SAVEDS ASM ret \
name(REG(a0, UNUSED struct Hook *hook), REG(a2, UNUSED APTR obj), \
REG(a1, param))
#define HOOKPROTONHNP(name, ret, obj) static SAVEDS ASM ret \
name(REG(a0, UNUSED struct Hook *hook), REG(a2, obj), \
REG(a1, UNUSED APTR param))
#define HOOKPROTONHNONP(name, ret) static SAVEDS ret name(void)
#else
#define HOOKPROTO(name, ret, obj, param) static SAVEDS ASM ret \
name(REG(a0, struct Hook *hook), REG(a2, obj), REG(a1, param))
#define HOOKPROTONO(name, ret, param) static SAVEDS ASM ret \
name(REG(a0, struct Hook *hook), REG(a1, param))
#define HOOKPROTONP(name, ret, obj) static SAVEDS ASM ret \
name(REG(a0, struct Hook *hook), REG(a2, obj))
#define HOOKPROTONONP(name, ret) static SAVEDS ASM ret \
name(REG(a0, struct Hook *hook))
#define HOOKPROTONH(name, ret, obj, param) static SAVEDS ASM ret \
name(REG(a2, obj), REG(a1, param))
#define HOOKPROTONHNO(name, ret, param) static SAVEDS ASM ret \
name(REG(a1, param))
#define HOOKPROTONHNP(name, ret, obj) static SAVEDS ASM ret \
name(REG(a2, obj))
#define HOOKPROTONHNONP(name, ret) static SAVEDS ret name(void)
#endif
#endif

#ifdef __MORPHOS__
#define SDI_TRAP_LIB 0xFF00 /* SDI prefix to reduce conflicts */

struct SDI_EmulLibEntry
{
UWORD Trap;
UWORD pad;
APTR Func;
};

#ifdef __GNUC__
#include <emul/emulregs.h>

#define HOOKPROTO(name, ret, obj, param) static ret name(void) \
{ struct Hook *hook = (APTR)REG_A0; obj = (APTR)REG_A2; \
param = (APTR)REG_A1;
#define HOOKPROTONO(name, ret, param) static ret name(void) \
{ struct Hook *hook = (APTR)REG_A0; param = (APTR)REG_A1;
#define HOOKPROTONP(name, ret, obj) static ret name(void) \
{ struct Hook *hook = (APTR)REG_A0; obj = (APTR)REG_A2;
#define HOOKPROTONONP(name, ret) static ret name(void) \
{ struct Hook *hook = (APTR)REG_A0;
#define HOOKPROTONH(name, ret, obj, param) static ret name(void) \
{ obj = (APTR)REG_A2; param = (APTR)REG_A1;
#define HOOKPROTONHNO(name, ret, param) static ret name(void) \
{ param = (APTR)REG_A1;
#define HOOKPROTONHNP(name, ret, obj) static ret name(void) \
{ obj = (APTR)REG_A2;
#define HOOKPROTONHNONP(name, ret) static ret name(void) {
#define MakeHook(hookname, funcname) \
} static const struct SDI_EmulLibEntry Gate_##funcname = \
{SDI_TRAP_LIB, 0, (void(*)()) funcname}; \
struct Hook hookname = {{NULL, NULL}, (HOOKFUNC)&Gate_##funcname, \
NULL, NULL}
#define MakeStaticHook(hookname, funcname) \
} static const struct SDI_EmulLibEntry Gate_##funcname = \
{SDI_TRAP_LIB, 0, (void(*)()) funcname}; \
static struct Hook hookname = {{NULL, NULL}, \
(HOOKFUNC)&Gate_##funcname, NULL, NULL}
#define DISPATCHERPROTO(name) \
struct IClass; \
static ULONG name(struct IClass * cl, Object * obj, Msg msg); \
static ULONG Trampoline_##name(void) {return name((struct IClass *) \
REG_A0, (Object *) REG_A2, (Msg) REG_A1);} \
static const struct SDI_EmulLibEntry Gate_##name = {SDI_TRAP_LIB, 0, \
(void(*)())Trampoline_##name}; \
static ULONG name(struct IClass * cl, Object * obj, Msg msg)
#else
#define MakeHook(hookname, funcname) \
static const struct SDI_EmulLibEntry Gate_##funcname = {SDI_TRAP_LIB, \
0, (APTR) funcname}; \
struct Hook hookname = {{NULL, NULL}, \
(HOOKFUNC)&Gate_##funcname, NULL, NULL}
#define MakeStaticHook(hookname, funcname) \
static const struct SDI_EmulLibEntry Gate_##funcname = {SDI_TRAP_LIB, \
0, (APTR) funcname}; \
static struct Hook hookname = {{NULL, NULL}, \
(HOOKFUNC)&Gate_##funcname, NULL, NULL}
#define DISPATCHERPROTO(name) \
struct IClass; \
static ASM ULONG name(REG(a0, \
struct IClass * cl), REG(a2, Object * obj), REG(a1, Msg msg)); \
static const struct SDI_EmulLibEntry Gate_##name = {SDI_TRAP_LIB, 0, \
(APTR)name}; \
static ASM ULONG name(REG(a0, \
struct IClass * cl), REG(a2, Object * obj), REG(a1, Msg msg))
#endif

#define ENTRY(func) (APTR)&Gate_##func
#else
#define DISPATCHERPROTO(name) static SAVEDS ASM ULONG name(REG(a0, \
struct IClass * cl), REG(a2, Object * obj), REG(a1, Msg msg))
#define ENTRY(func) (APTR)func
#define MakeHook(hookname, funcname) struct Hook hookname = {{NULL, NULL}, \
(HOOKFUNC)funcname, NULL, NULL}
#define MakeStaticHook(hookname, funcname) static struct Hook hookname = \
{{NULL, NULL}, (HOOKFUNC)funcname, NULL, NULL}
#endif

#define InitHook(hook, orighook, data) ((hook)->h_Entry = (orighook).h_Entry,\
(hook)->h_SubEntry = (orighook).h_SubEntry,(hook)->h_Data = (APTR)(data))

#endif /* SDI_HOOK_H */


Forward
Message #293 of 313 |
Expand Messages Author Sort by Date

Hi all, I would like to ask if it is possible to recompile for Amithlon things that were written with MUI in mind and they pass some args through emulated 68k ...
Miosz Staszewski
sofcik@...
Send Email
Mar 12, 2004
9:38 pm

... Yes, of course. I assume you're talking about the dispatcher? Just use HookEntry and there is no need to worry about registers. If that's not what you...
Martin Blom
leviticus_mb
Offline Send Email
Mar 13, 2004
11:45 am

Hello Martin, ... Well I think this is a dispatcher. I've never written anything for MUI and have no experience with it. I get this error message: YAM.c:425:...
Miosz Staszewski
sofcik@...
Send Email
Mar 13, 2004
2:06 pm

... OK. I don't understand why people keep making the Hooks so complicated. ... Anyway. You could define your own macros in the spirit of the existing, but it...
Martin Blom
leviticus_mb
Offline Send Email
Mar 13, 2004
3:42 pm

... I won't bet on this, this is an amiga.lib function with the purpose to serve as 68k->C interface... Regards - Rudolph...
rudolph.riedel@...
rudolph_riedel
Offline Send Email
Mar 13, 2004
5:55 pm

... It's used in AHI, for example, and there is no implementation in the sources I have, at least. It was my understanding that it was added to the AOS4...
Martin Blom
leviticus_mb
Offline Send Email
Mar 13, 2004
9:43 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help