LibraryMaker

Anfängerfragen zum Programmieren mit PureBasic.
Yoshi
Beiträge: 95
Registriert: 09.01.2007 16:42

LibraryMaker

Beitrag von Yoshi »

Hat jemand Erfahrungen mit dem LibraryMaker gesammelt?

Wenn ich eine Library erstellen möchte, muss ich vorher eine "Pure Descriptor" -Datei auswählen, kann mir jemand sagen, welche Endung die hat?
Yoshi
Beiträge: 95
Registriert: 09.01.2007 16:42

Beitrag von Yoshi »

:o Hat ´hier noch keiner eine library erstellt? :shock:
Benutzeravatar
Kiffi
Beiträge: 10714
Registriert: 08.09.2004 08:21
Wohnort: Amphibios 9

Beitrag von Kiffi »

Yoshi hat geschrieben::o Hat ´hier noch keiner eine library erstellt? :shock:
mit dem LibraryMaker habe ich in der Tat noch keine Lib erstellt
(zumindest nicht, dass ich das wüsste)

Allerdings: Bist Du Dir sicher, dass Du Dich da jetzt schon rantrauen willst?
Immerhin wusstest Du bis vor ein paar Tagen nicht, was eine Schleife ist.

Meines Erachtens solltest Du erst einmal die Grundlagen beschäftigen, bevor
Du Dich an das Erstellen von Libs machst.

Grüße ... Kiffi
a²+b²=mc²
Benutzeravatar
H.Brill
Beiträge: 497
Registriert: 15.10.2004 17:42
Wohnort: 66557 Neunkirchen

Beitrag von H.Brill »

Haste denn eine .LIB oder .OBJ mit nem C - Compiler
oder Assembler erstellt ?
Ansonsten gehste mal in die Unterverzeichnisse LccWin32
und NAsm. Dort sind Beispiele bei.
Generell geht es so :
1. eine .Lib oder .Obj mit den von dir geschriebenen Funktionen
erstellen.
2. Eine .DESC - Datei (Name muß der gleiche sein, wie die obj/lib)
mit einem Editor anlegen. Das ist eine Art Beschreibungsdatei,
in der du u. a. die Funktionen nennst (Schau dir mal die
Beispieldateien an).
3. LibraryMaker starten. Oben gibst du halt das Verzeichnis deiner
.desc und .obj oder .lib - Datei an. Unten den Pfad zu deinen
Userlibraries. Weiterhin kannst du Komprimierung optional einschalten.
Dann Start drücken und die Library wird ohne Worte, wenn kein
Fehler auftritt, erstellt.

Wenn du dann PB startest, solltest du deine Funktionen in der Library
nutzen können.
PB 6.10
DarkDragon
Beiträge: 6291
Registriert: 29.08.2004 08:37
Computerausstattung: Hoffentlich bald keine mehr
Kontaktdaten:

Beitrag von DarkDragon »

Beim Library Maker kannst du eine LIB oder OBJ Datei zu einer PB User-Library machen. Das ist für dich sicher noch nicht relevant. Er erwartet eine .DESC Datei (Schau dir mal die ganzen .txt Dateien an. Vor allem die "Library SDK\Readme.txt").
Library SDK\Readme.txt hat geschrieben: V. Building the final PureLibrary
---------------------------------

The commands available in a PureLibrary are described in a file, called
'LibraryName.Desc'. Inside, you can put every commands, which langage you've
used to code your library, and more. Every line beginning by a semi-column ';'
is considered as a comment (like in PureBasic).

1. Basic example
- - - - - - -

;
; Langage used to code the library: ASM or C
ASM
;
; Number of windows DLL than the library need
2
WINMM
ODBC32
;
; Library type (Can be OBJ or LIB). Starting with 2.60, PureBasic can use both .obj (NAsm or LccWin32)
; and standard Windows .LIB file, useful to convert quickly a library. This should be mostly .obj
; here, instead you're really need to use a .lib.
;
OBJ
;
; Number of PureBasic library needed by the library. Here we need the Gadget library
;
1
Gadget
; Help directory name. Useful when doing an extension of a library and want to put
; the help file in the same directory than the base library. This is not a facultative
; result.
;
GadgetSlider
;
; Library functions:
;
; FunctionName, Arg1Type, Arg2Type, ... (DescriptionArg1, Arg2) - Description of the command show on the QuickHelp status bar
; Return type
;

The final sample:
-----------------

ASM
0
OBJ
0
Misc
;
; Misc library descriptor
;
;
InitMisc
InitFunction
;
FreeMiscs
EndFunction
;
PeekS, Long (Address) - Retrieve a string from the specified address
String
;
PeekL, Long (Address) - Retrieve a long from the specified address
Long | DebuggerCheck


Possible parameter type: Only one parameter type can be put at once.

* Byte: The parameter will be a byte (1 byte)
* Word: The parameter will be a word (2 bytes)
* Long: The parameter will be a long (4 bytes)
* String: The parameter will be a string (see below for an explaination of string handling)
* Quad: The parameter will be a quad (8 bytes)
* Float: The parameter will be a float (4 bytes)
* Double: The parameter will be a double (8 bytes)
* Any: The parameter can be anything (the compiler won't check the type)
* Array: The parameter will be an array. It will have to be passed like: array()
* LinkedList: The parameter will be an linkedlist. It will have to be passed like: list()


Possible return flags: The flags can be combined with the '|' operand.

* DebuggerCheck: The command need a PB_CommandName_DEBUG() routine, which will be called before the call
of the real command (when the debugger is on), useful to check if the parameters are corrects. This function
should be put in a different file, to not be linked with the final executable. You should put all the debug
functions in the same file, to ease the management. This function has to be declared CDECL.

* Byte: The return is a byte (1 byte)
* Long: The return is a long (4 bytes)
* Float: The return is a long (4 bytes)
* Double: The return is a double (8 bytes)
* Quad: The return is a quad (8 bytes)
* String: The return is a string (see below for an explaination of string handling)
* None: This function doesn't return anything

* InitFunction: The function is an 'InitFunction' which will be called automatically when
the program starts. This function won't appear in the available user command list. This function
can not have any parameters. A debug function can be attached this function, if debugger specific
code should be initialized once.

* EndFunction: The function is an 'EndFunction' which will be called automatically when
the program ends. It's very useful to clean up all the resource allocated by the library commands

* StdCall: The function is truly stdcall. It's only useful for ASM library, to force the first parameter to
pushed on the stack (instead of 'eax').

* MMX: Informs the compiler than this function has an MMX specific version (see below)
* SSE: Informs the compiler than this function has an SSE specific version (see below)
* SSE2: Informs the compiler than this function has an SSE2 specific version (see below)
* 3DNOW: Informs the compiler than this function has an 3DNOW specific version (see below)

* CDecl: The function call will be CDecl, which means than it's the compiler which will readjust the
stack.

* Virtual: The function is not a real function, but a function pointer. The compiler will make an indirect call
by using the PB_Command label as a function pointer. Can be useful to have a same function doing different
operation depending of the context.

* Thread: Informs the compiler than this function has a THREAD specific version. If the function needs to be
tuned to be threadsafe, and the performance/size impact will be important, it's advised to use this flag
and create a function which will be used only when the executable will be thread safe (ie: compiled with the
/THREAD flag). The command should be named PB_CommandName_THREAD()

* Unicode: Informs the compiler than this function has an UNICODE specific version. If the function returns
a string or has some string parameter, it's strongly recommanded to use this flag and add the unicode version
so the command can be used in unicode program as well (else it will work in ascii only).
The command should be named PB_CommandName_UNICODE(). Note: if your command also has the 'Thread' flag, you
need to do another command name PB_CommandName_THREAD_UNICODE() which will be used if the program is compiled
with the /THREAD and /UNICODE flag.

* Assembly: Tells than this function is written in assembly (so the first parameter is on eax, and the name
decoration doesn't have @NbParams*4). This allow to mix assembly and C command in the same library.




2. Examples of variable parameters
- - - - - - - - - - - - - - - -

2.1 One, two or tree parameters

CustomBox, String, [Long], [Long], (Title$ [, Flags [, Hidden]]) - My Custom box
Long

Now, you have to create 3 PB functions, named like this:
PB_CustomBox (char *String)
PB_CustomBox2(char *String, Long)
PB_CustomBox3(char *String, Long, Long)

2.2 One or tree parameters

CustomBox, String, [Long, Long], (Title$ [, Flags , Hidden]) - My Custom box
Long

Now, you have to create 2 PB functions, named like this:
PB_CustomBox (char *String)
PB_CustomBox2(char *String, Long, Long)


3. Advanced flags
- - - - - - -

* Starting with PureBasic 3.50 it's possible to force an asm procedure to be stdcall
(ie: last argument pushed on the stack, instead in 'eax'), by using the 'StdCall'
keyword in the return field. This is very handy, especially for DLL wrapper.

Example:

MyDLLWrapper, Long, Long, () - My DLL wrapper
Long | StdCall

* It's possible to put an 'ANY' flags, instead of Long, Float, etc.. arguments type. This
mean that's the last type which is used, without convertion. For example, you can do
a function which sometimes need float, sometimes long, depending of the flags. It is
especially used with the CallFunction() and CallFunctionFast() command.

Example:

MySpecialFunction, Long, Any, (Flags, Float or Long or String)
Long


Once this file is finished, you have to mix the .obj with the .desc to produce a
real PureLibrary. To do this, copy the .Desc and the .obj in the same directory and
run the LibraryMaker tool. Select this path as 'Source Object Path' and a destination
path. If errors are found, they will be signaled.

4. Conditional directives
- - - - - - - - - - - -

As PureBasic is a crossplatform programming langage it sometimes useful to uses the same
.desc file for several OS. In this case, it could have some minor changes to do to the .desc
to fit the system rules. To do it, it's possible to use CompilerIf/CompilerElse/CompilerEndIf
directory, like in PureBasic. The /CONSTANT command line flag will be used to declare the constants.
It's possible to use several constants and to nest the statements.

Example:

; Custom library
;
CompilerIf WINDOWS
; Do all the Windows related stuff here
CompilerElse
CompilerIf LINUX
; Do the stuff for linux
CompilerElse
; Default case
CompilerEndIf
CompilerEndIf
Angenommen es gäbe einen Algorithmus mit imaginärer Laufzeit O(i * n), dann gilt O((i * n)^2) = O(-1 * n^2) d.h. wenn man diesen Algorithmus verschachtelt ist er fertig, bevor er angefangen hat.
Yoshi
Beiträge: 95
Registriert: 09.01.2007 16:42

Beitrag von Yoshi »

Das sieht ja ziemlich kompliziert aus.

Ist es mit dem LibraryMaker möglich eigene Progressbar gadgets zu entwickelön, d.h. dass man andere Symbole hat (z.B. 10 Fußbälle die nacheinander erscheinen)?
Benutzeravatar
edel
Beiträge: 3667
Registriert: 28.07.2005 12:39
Computerausstattung: GameBoy
Kontaktdaten:

Beitrag von edel »

Nein, denn coden musst du sie schon selber.
Kaeru Gaman
Beiträge: 17389
Registriert: 10.11.2004 03:22

Beitrag von Kaeru Gaman »

das hat aber mit ner LIB nix zu schigge, das wäre ein OwnerDrawn Gadget.
kann man auch komplett ohne LIB machen,
aber selber coden und selber grafix malen muss man auf jeden.
Der Narr denkt er sei ein weiser Mann.
Der Weise weiß, dass er ein Narr ist.
Yoshi
Beiträge: 95
Registriert: 09.01.2007 16:42

Beitrag von Yoshi »

Und wie macht man so ein OwnerDrawn Gadget?

Also ich hab es im Visual Designer nicht gefunden.
Kaeru Gaman
Beiträge: 17389
Registriert: 10.11.2004 03:22

Beitrag von Kaeru Gaman »

> Also ich hab es im Visual Designer nicht gefunden.

ja nä, logesch...
wenn ich sage, du musst es selber machen, dann meine ich, du musst es selber machen.
das nennt man im volksmund "selber machen", und das bedeutet "selber machen"

die boardsuche hilft auch hier, die suche nach "ownerdrawn" sollte doch einiges zutage fördern.
im zweifelsfalle schau dir die liste der postings von edel an,
er hat innerhalb der letzten monate einiges drüber geschrieben...

aber ernsthaft... das ist genausowenig anfänger-stuff wie ne lib.
schreib doch erstmal was funktionierendes mit nem stinknormalen progressbar...
Der Narr denkt er sei ein weiser Mann.
Der Weise weiß, dass er ein Narr ist.
Antworten