Skip to content

Commit cb938de

Browse files
committed
Document class loader implementation method
1 parent 0d63d84 commit cb938de

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
*~
22
*.elc
3+
*.info
4+
*.texi
35
.cask
46
dist
57
ede-php-autoload-pkg.el
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#+TITLE: How to create a new class loader
2+
3+
* Examples
4+
5+
To see class loader implementation examples, look at the standard
6+
class loaders defined in ~ede-php-autoload/class-loader~. The
7+
simplest one is ~ede-php-autoload-classmap-class-loader~.
8+
9+
* Define the class loader
10+
11+
A class loader is an EIEIO class. It is a subclass of
12+
~ede-php-autoload-class-loader~. It should implement the following
13+
methods, even if it implies doing nothing in it:
14+
15+
- ~ede-php-autoload-find-class-def-file~ that retrieves the file in
16+
which the given class is defined.
17+
18+
- ~ede-php-autoload-get-class-name-for-file~ which returns the name
19+
of the class that should be defined in the given file.
20+
21+
- ~ede-php-autoload-complete-type-name~ that return possible
22+
completions for the prefix of a fully qualified name.
23+
24+
At this point, the class loader can be used by sending an instance
25+
of it to an ~ede-php-autoload-project~ like this:
26+
27+
#+BEGIN_SRC emacs-lisp
28+
(ede-php-autoload-project "Custom project" :loaders (my-custom-class-loader "Custom loader" <args>))
29+
#+END_SRC
30+
31+
* Define the factory
32+
33+
Giving a class loader by instance to the EDE project is not really
34+
handy, and does not play nicely with other class loaders. It is
35+
necesary to define a factory to be able to use the new class loader
36+
with a user-friendly API like this:
37+
38+
#+BEGIN_SRC emacs-lisp
39+
(ede-php-autoload-project "Custom project"
40+
:class-autoloads '(:custom <args>))
41+
#+END_SRC
42+
43+
The factory can be defined using the macro ~ede-php-autoload-class-loader-define-factory~:
44+
45+
#+BEGIN_SRC emacs-lisp
46+
(ede-php-autoload-class-loader-define-factory :custom (configuration)
47+
(my-custom-class-loader "Custom" configuration))
48+
#+END_SRC

0 commit comments

Comments
 (0)