Progi1984 wrote:
remove all content after as (and the as of course) for building with Tailbite unde Linux. Good resume ?
all i removed was the "As xxxx" and the compilerif/else, changing all imported functions to having PB_ in front.
Progi1984 wrote:
If you put ImportC "", and if you import, for example, the lib mysql.a in your code, how will pb be able to detect where is mysql.a ?
Import "" is only for importing PB internal functions (objects - as in your code, gadgets, debugger, imageplugin, etc)
This is what I compiled to a userLib in Linux TB: (I am unsure if the PB_GADGET structure is actually needed - I have not retested with your structure [only just realised])
Code:
ImportC ""
PB_Object_GetOrAllocateID (Objects, *Object)
PB_Object_GetObject (Objects, Object.l)
PB_Object_IsObject (Objects, Object.l)
PB_Object_EnumerateAll (Objects, ObjectEnumerateAllCallback, *VoidData)
PB_Object_EnumerateStart (Objects)
PB_Object_EnumerateNext (Objects, *object.Long)
PB_Object_EnumerateAbort (Objects)
PB_Object_FreeID (Objects, Object.l)
PB_Object_Init (StructureSize.l, IncrementStep.l, *ObjectFreeFunction)
PB_Object_GetThreadMemory (MemoryID.l)
PB_Object_InitThreadMemory (Size.l, InitFunction, EndFunction)
EndImport
Structure PB_OBJECT
StructureSize.l
IncrementStep.l
ObjectsNumber.l
*ListFirstElement;PB_SimpleList
*FreeID; ObjectFreeFunction // to call when reallocating a static ID
CurrentID.i; // for the object enumeration without callback (static id)
*CurrentElement;PB_SimpleList // (dynamic id)
CompilerIf #PB_Compiler_Thread = 0
;// For single-thread
*ObjectsArea
CompilerElse
;// For multi-thread
IncrementShift.i
*FirstObjectsArea; PB_SimpleList // simplelists build up backwards (always add at start), so we have to later walk it backwards
*LastObjectsArea;PB_SimpleList // this is the *real* first memoryblock
*ObjectMutex;M_MUTEX
CompilerEndIf
EndStructure
Structure S_S11_Union
URL.s
EndStructure
Structure S_S11
ID.l
Type.l
StructureUnion
Union.S_S11_Union
EndStructureUnion
EndStructure
;
; ;- Macros
Macro S11_ID(object)
PB_Object_GetObject(S11Objects, object)
EndMacro
Macro S11_IS(object)
PB_Object_IsObject(S11Objects, object)
EndMacro
Macro S11_NEW(object)
PB_Object_GetOrAllocateID(S11Objects, object)
EndMacro
Macro S11_FREEID(object)
If object <> #PB_Any And S11_IS(object) = #True
PB_Object_FreeID(S11Objects, object)
EndIf
EndMacro
Macro S11_INITIALIZE(hCloseFunction)
PB_Object_Init(SizeOf(S_S11), 1, hCloseFunction)
EndMacro
ProcedureDLL S11Free(Id.l)
Protected *RObject.S_S11
If *RObject
S11_FREEID(Id)
EndIf
ProcedureReturn #True
EndProcedure
ProcedureDLL S11_Init()
Global S11Objects
;S11Objects = S11_INITIALIZE(@S11Free())
S11Objects = PB_Object_Init(SizeOf(PB_OBJECT), 1, @S11Free())
ProcedureReturn
If IsWindow(#PB_Any)
EndIf
EndProcedure
ProcedureDLL.l S11_GetType(Id.l)
Protected *RObject.S_S11 = S11_ID(Id)
If *RObject
ProcedureReturn *RObject\Type
Else
ProcedureReturn -1
EndIf
EndProcedure
ProcedureDLL.l S11_Create(Id.l, type.l)
Protected *RObject.S_S11 = S11_NEW(Id)
With *RObject
\ID = *RObject
\Type = type
EndWith
ProcedureReturn *RObject
EndProcedure