Skip to content

Commit

Permalink
Lisp: add kinds for def{type,class,method,generic,struct,parameter}
Browse files Browse the repository at this point in the history
versionCurrent and versionAge are not updated in this commit.
They may be updated in following commits.

Signed-off-by: Masatake YAMATO <[email protected]>
  • Loading branch information
masatake committed Nov 19, 2024
1 parent 0d868ea commit 4fdd94b
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Tmain/pretend-option.d/stdout-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ f functions
v variables
m macros
c constants
t types
C classes
s structs
M methods
G generics
p parameters
2 changes: 2 additions & 0 deletions Units/parser-lisp.r/more-defsomething.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--sort=no
--fields=+KkZz
8 changes: 8 additions & 0 deletions Units/parser-lisp.r/more-defsomething.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
url input.lisp /^(defmethod url ((url quri:uri))$/;" kind:method
url-designator input.lisp /^(deftype url-designator ()$/;" kind:type
renderer-scheme input.lisp /^(defclass renderer-scheme ()$/;" kind:class
scheme input.lisp /^(define-class scheme (renderer-scheme)$/;" kind:unknown
browser-schemes input.lisp /^(defgeneric browser-schemes (browser)$/;" kind:generic
%buffer input.lisp /^(defparameter %buffer nil)$/;" kind:parameter
:nyxt/renderer/gtk input.lisp /^(nyxt:define-package :nyxt\/renderer\/gtk$/;" kind:unknown
renderer-history-entry input.lisp /^(defstruct renderer-history-entry$/;" kind:struct
60 changes: 60 additions & 0 deletions Units/parser-lisp.r/more-defsomething.d/input.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
;; Taken from https://github.com/atlas-engineer/nyxt.git

(defmethod url ((url quri:uri))
url)

(deftype url-designator ()
"Type for anything URL-like.
Means that `url' can be applied to it to get `quri:uri'."
`(satisfies has-url-method-p))

(defclass renderer-scheme ()
()
(:metaclass interface-class)
(:documentation "Renderer-specific representation of the custom scheme.
Should be redefined by the renderer."))

(define-class scheme (renderer-scheme)
((name
(alex:required-argument 'name)
:documentation "The custom scheme name to handle.
HTTPS or FILE are examples of schemes.")
(callback
nil
:type (or null function)
:documentation "A function called on URL load that returns the page contents.
It takes the URL as an argument and returns up to 5 values:
- The data for page contents (either as string or as a unsigned byte array)
- The MIME type for the contents
- The status code for the request
- An alist of headers for the request
- A status reason phrase")
(error-callback
nil
:type (or null function)
:documentation "Callback to use when a condition is signaled.
Accepts only one argument: the signaled condition."))
(:export-class-name-p t)
(:export-accessor-names-p t)
(:documentation "Representation of Nyxt-specific internal schemes.
Has `name' it can be accessed with. When accessed, runs `callback' to return
content. In case something goes wrong, runs `error-callback'.")
(:metaclass user-class))

(defgeneric browser-schemes (browser)
(:method-combination append)
(:documentation "Return a list of schemes supported by BROWSER."))

(defparameter %buffer nil)

(nyxt:define-package :nyxt/renderer/gtk
(:documentation "GTK renderer using direct CFFI bindings."))

(defstruct renderer-history-entry
title
url
original-url
gtk-object)

36 changes: 36 additions & 0 deletions parsers/lisp.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ typedef enum {
K_VARIABLE,
K_MACRO,
K_CONST,
K_TYPE,
K_CLASS,
K_STRUCT,
K_METHOD,
K_GENERIC,
K_PARAMETER,
} lispKind;

static kindDefinition LispKinds [] = {
Expand All @@ -37,6 +43,12 @@ static kindDefinition LispKinds [] = {
{ true, 'v', "variable", "variables" },
{ true, 'm', "macro", "macros" },
{ true, 'c', "const", "constants" },
{ true, 't', "type", "types" },
{ true, 'C', "class", "classes" },
{ true, 's', "struct", "structs" },
{ true, 'M', "method", "methods" },
{ true, 'G', "generic", "generics" },
{ true, 'p', "parameter", "parameters" },
};

typedef enum {
Expand Down Expand Up @@ -153,16 +165,40 @@ static int lisp_hint2kind (const vString *const hint)
if (EQN("DEFVAR"))
k = K_VARIABLE;
break;
case 4:
n = 4;
if (EQN("DEFTYPE"))
k = K_TYPE;
break;
case 5:
n = 5;
if (EQN("DEFMACRO"))
k = K_MACRO;
else if (EQN("DEFCLASS"))
k = K_CLASS;
break;
case 6:
n = 6;
if (EQN("DEFSTRUCT"))
k = K_STRUCT;
else if (EQN("DEFMETHOD"))
k = K_METHOD;
break;
case 7:
n = 7;
if (EQN("DEFGENERIC"))
k = K_GENERIC;
break;
case 8:
n = 8;
if (EQN("DEFCONSTANT"))
k = K_CONST;
break;
case 9:
n = 9;
if (EQN("DEFPARAMETER"))
k = K_PARAMETER;
break;
}
#undef EQN
return k;
Expand Down

0 comments on commit 4fdd94b

Please sign in to comment.