Adapted to recent changes of %build_linklib.
[AROS-Contrib.git] / FryingPan / framework / Generic / GenericOOP.cpp
blobaaae711393be56b8d2bb5f7ca2833ef5fb005cbb
1 /*
2 * Amiga Generic Set - set of libraries and includes to ease sw development for all Amiga platforms
3 * Copyright (C) 2001-2011 Tomasz Wiszkowski Tomasz.Wiszkowski at gmail.com.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "GenericOOP.h"
21 #include "LibrarySpool.h"
22 #include <libclass/exec.h>
23 #include <libclass/utility.h>
24 #include <libclass/intuition.h>
25 #include <stdarg.h>
26 #include "Debug.h"
28 using namespace GenNS;
30 uint32 GenericOOP::DoMtd(Object* pObject, uint32 *pMsg)
32 return Utility->CallHookPkt((const Hook*)OCLASS(pObject), pObject, pMsg);
35 uint32 GenericOOP::DoSuperMtd(IClass *pClass, Object* pObject, uint32 *pMsg)
37 return Utility->CallHookPkt((Hook*)pClass->cl_Super, pObject, pMsg);
40 uint32 *GenericOOP::NewObj(char* Name, uint32 FirstTag, ...) // me hates mos for that.
42 va_list ap;
43 uint32 *params = new uint32 [128];
44 int pos = 0;
45 va_start(ap, FirstTag);
47 params[pos] = FirstTag;
48 while (params[pos++] != 0)
50 params[pos++] = va_arg(ap, unsigned long);
51 params[pos] = va_arg(ap, unsigned long);
52 ASSERT(pos < 128);
55 pos = (int)Intuition->NewObjectA(0, Name, (struct TagItem*)params);
56 delete [] params;
57 return (uint32*)pos;
60 uint32 *GenericOOP::NewObj(Class* cls, uint32 FirstTag, ...) // me hates mos for that.
62 va_list ap;
63 uint32 *params = new uint32 [128];
64 int pos = 0;
65 va_start(ap, FirstTag);
67 params[pos] = FirstTag;
68 while (params[pos++] != 0)
70 params[pos++] = va_arg(ap, unsigned long);
71 params[pos] = va_arg(ap, unsigned long);
72 ASSERT(pos < 128);
75 pos = (int)Intuition->NewObjectA((IClass*)cls, 0, (struct TagItem*)params);
77 delete [] params;
78 return (uint32*)pos;
81 void GenericOOP::DisposeObj(uint32 *obj)
83 Intuition->DisposeObject(obj);
86 void GenericOOP::AddChildObj(Object *parent, uint32 *child)
88 DoMtd(parent, ARRAY(OM_ADDMEMBER, (uint32)child));
91 void GenericOOP::RemChildObj(Object *parent, uint32 *child)
93 DoMtd(parent, ARRAY(OM_REMMEMBER, (uint32)child));
96 GenericOOP::~GenericOOP()
100 GenericOOP::GenericOOP()
102 ASSERTS(Utility != 0, "Please create library spool!");