Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove mutual require between erl, derl and erl-service

Fix some buglets and compiler warnings.
  • Loading branch information...
commit 01e36d27371241fd9f7f575a023fa6f10caf9ee4 1 parent 905696f
@leoliu leoliu authored
View
3  Makefile
@@ -19,7 +19,8 @@ ERL_SRC_DIR = ${datadir}/distel/src
ERL_SRC := $(wildcard src/*.erl)
ERL_OBJ := $(patsubst src/%.erl,ebin/%.beam,${ERL_SRC})
-ELISP_SRC := elisp/erlext.el elisp/mcase.el elisp/net-fsm.el elisp/epmd.el
+ELISP_SRC := elisp/erlext.el elisp/mcase.el elisp/net-fsm.el elisp/epmd.el \
+ elisp/erl.el elisp/derl.el
ELISP_OBJ := $(patsubst %.el,%.elc,${ELISP_SRC})
DOC_SRC := doc/distel.texi
View
51 elisp/derl.el
@@ -10,15 +10,16 @@
(require 'epmd)
(require 'erlext)
(require 'md5)
+(require 'erl)
(eval-when-compile
(require 'cl))
(defvar erl-nodeup-hook nil
- "Called with two args, NODE and FSM. NODE is a string of the form
-\"mynode@cockatoo\", FSM is the net-fsm process of the connection.")
+ "Called with two args, NODE and FSM. NODE is a symbol of the form
+mynode@cockatoo, FSM is the net-fsm process of the connection.")
(defvar erl-nodedown-hook nil
- "Called with one arg, NODE, a string of the form \"mynode@cockatoo\"")
+ "Called with one arg, NODE, a symbol of the form mynode@cockatoo")
(defcustom derl-use-trace-buffer t
"*Store erlang message communication in a trace buffer."
@@ -251,14 +252,14 @@ gen_digest() function:
ctl
req)
;; Decode the control message, and the request if it's present
- (let (default-enable-multibyte-characters)
- (with-temp-buffer
- (insert msg)
- (goto-char (point-min))
- (assert (= (erlext-read1) 112)) ; type = pass through..
- (setq ctl (erlext-read-whole-obj))
- (when (< (point) (point-max))
- (setq req (erlext-read-whole-obj)))))
+ (with-temp-buffer
+ (set-buffer-multibyte nil)
+ (insert msg)
+ (goto-char (point-min))
+ (assert (= (erlext-read1) 112)) ; type = pass through..
+ (setq ctl (erlext-read-whole-obj))
+ (when (< (point) (point-max))
+ (setq req (erlext-read-whole-obj))))
(ecase (tuple-elt ctl 1)
((1) ;; link: [1 FROM TO]
(let ((from (tuple-elt ctl 2))
@@ -401,15 +402,13 @@ initiated if necessary and the request is queued."
;; Tracing
-(defface derl-trace-output-face
- '((t (:inherit font-lock-string-face)))
- "Face for outgoing messages in the distributed erlang trace
-buffer.")
+(defface derl-trace-output-face '((t (:inherit font-lock-string-face)))
+ "Face for outgoing messages in the distributed erlang trace buffer."
+ :group 'erl)
-(defface derl-trace-input-face
- '((t (:inherit font-lock-comment-face)))
- "Face for incoming messages in the distributed erlang trace
-buffer.")
+(defface derl-trace-input-face '((t (:inherit font-lock-comment-face)))
+ "Face for incoming messages in the distributed erlang trace buffer."
+ :group 'erl)
(defun derl-trace-output (fmt &rest args)
(let ((msg (format ">> %s" (apply #'format (cons fmt args)))))
@@ -446,13 +445,12 @@ buffer.")
;; NB: only callable from the state machine
(run-hook-with-args 'erl-nodeup-hook node fsm-process))
-(eval-and-compile
- (defun derl-int32-to-decimal (s)
- "Converts a 32-bit number (represented as a 4-byte string) into its
+(defun derl-int32-to-decimal (s)
+ "Converts a 32-bit number (represented as a 4-byte string) into its
decimal printed representation."
- (format "%.0f" (+ (+ (aref s 3) (* 256 (aref s 2)))
- (* (+ 0.0 (aref s 1) (* 256 (aref s 0)))
- 65536)))))
+ (format "%.0f" (+ (+ (aref s 3) (* 256 (aref s 2)))
+ (* (+ 0.0 (aref s 1) (* 256 (aref s 0)))
+ 65536))))
;; Try to establish whether we have enough precision in floating-point
;; The test is pretty lame, even if it succeeds we cannot be sure
@@ -483,7 +481,7 @@ as a string of octets."
((and (<= ?a c) (<= c ?f))
(+ 10 (- c ?a)))
(t
- (error "Not hexchar" c))))
+ (error "Not hexchar: %c" c))))
(defun derl-node-p (node)
"Check if `node' is a node name, e.g. \"foo@bar\". The @ character
@@ -523,3 +521,4 @@ is not allowed in the node or host name."
(message "FAIL"))))
(provide 'derl)
+;;; derl.el ends here
View
2  elisp/epmd.el
@@ -20,11 +20,13 @@
((?a) (fsm-change-state #'epmd-recv-alive-resp))))
(defun epmd-recv-names-resp (event data)
+ (declare (special arg))
(fsm-check-event event 'data)
(assert (>= (length data) 4))
(fsm-terminate (substring arg 4)))
(defun epmd-recv-port-resp (event data)
+ (declare (special arg))
(message "Event: %s" event)
(message "data: %s" data)
(message "arg: %s" arg)
View
1  elisp/erl-service.el
@@ -11,6 +11,7 @@
(require 'erlang)
(eval-when-compile (require 'cl))
(require 'erl)
+(require 'derl)
;;;; Base framework
View
48 elisp/erl.el
@@ -16,24 +16,31 @@
;; it terminates with 'normal' status.
(eval-when-compile (require 'cl))
-(provide 'erl) ; avoid recursive require
-(require 'derl)
-(require 'erl-service)
(require 'mcase)
+(autoload 'erl-dist-send "derl")
+(autoload 'erl-dist-reg-send "derl")
+(autoload 'erl-dist-exit "derl")
+
+(defgroup erl nil
+ "Erlang-style process runtime system."
+ ;; Would prefer 'erlang should erlang.el define it.
+ :group 'languages)
+
;; Process ID structure.
;;
;; Exactly matches the [ERL-TAG erl-pid NODE ID SERIAL CREATION] vector used
;; in the `erlext' mapping, so don't change it!
+(defvar erl-pid-counter) (defvar erl-node-name) ; defined below
(defstruct (erl-pid
(:type vector)
:named
(:initial-offset 1) ; make room for erl-tag (TYPE)
(:constructor nil) ; no default constructor
(:constructor %make-erl-local-pid (&optional (id (incf erl-pid-counter))
- (node erl-node-name)
- (serial 0)
- (creation 0))))
+ (node erl-node-name)
+ (serial 0)
+ (creation 0))))
node id serial creation)
(defun make-erl-local-pid (&optional id)
@@ -47,9 +54,6 @@
;; Global book keeping state
-(defvar erl-node-name nil ; initialised below
- "Node name for Emacs.")
-
(defun erl-determine-hostname ()
"Figure out the short-names hostname."
(let ((fqdn (system-name)))
@@ -59,9 +63,9 @@
(match-string 0 fqdn)
(error "erl: Can't determine hostname.")))))
-(when (null erl-node-name)
- (setq erl-node-name
- (intern (format "distel_%S@%s" (emacs-pid) (erl-determine-hostname)))))
+(defvar erl-node-name
+ (intern (format "distel_%S@%s" (emacs-pid) (erl-determine-hostname)))
+ "Node name for Emacs.")
(defconst erl-null-pid (make-erl-local-pid 0)
"\"Null process\", the /dev/null of erl processes.
@@ -110,16 +114,13 @@ command `erl-schedule' to continue.")
;; Process-local variables
(eval-when-compile
-(defmacro defprocvar (symbol &optional initvalue docstring)
- "Define SYMBOL as a buffer-local process variable."
- `(prog1 (defvar ,symbol ,initvalue ,docstring)
- (make-variable-buffer-local ',symbol)
- ;; stop major modes' `kill-all-local-variables' from rubbing out
- ;; the process state
- (put ',symbol 'permanent-local t))))
-
-;; FIXME - what's the right incantation to have defprocvar fontified
-;; as a keyword?
+ (defmacro defprocvar (symbol &optional initvalue docstring)
+ "Define SYMBOL as a buffer-local process variable."
+ `(prog1 (defvar ,symbol ,initvalue ,docstring)
+ (make-variable-buffer-local ',symbol)
+ ;; stop major modes' `kill-all-local-variables' from rubbing
+ ;; out the process state.
+ (put ',symbol 'permanent-local t))))
(defprocvar erl-self erl-null-pid
"Current process' pid.
@@ -639,3 +640,6 @@ during the next `erl-schedule'."
(erl-spawn
(erl-register 'group-leader)
(&erl-group-leader-loop))))
+
+(provide 'erl)
+;;; erl.el ends here
View
5 elisp/net-fsm.el
@@ -168,8 +168,9 @@ error is signaled."
(defmacro fsm-build-message (&rest body)
"Execute BODY, and return the message that it creates via calls to
fsm-{insert,encode}*."
- `(let ((fsm-work-buffer (let ((default-enable-multibyte-characters nil))
- (generate-new-buffer " *fsm-msg*"))))
+ `(let ((fsm-work-buffer (with-current-buffer (generate-new-buffer " *fsm-msg*")
+ (set-buffer-multibyte nil)
+ (current-buffer))))
(unwind-protect
(progn ,@body
(with-current-buffer fsm-work-buffer (buffer-string)))
Please sign in to comment.
Something went wrong with that request. Please try again.