<2023-11-02 Thu>
emacs
源码分析(二)
看这行代码:
struct Lisp_String *s = pure_alloc (sizeof *s, Lisp_String);
这里需要注意的是:
Lisp_String
有两种类型,它们的名字是一样的,一个是结构体,一个是枚举。gdb
是查看变量时要么是p struct Lisp_Symbol
;要么是p (int)Lisp_Symbol
。- 类似的还有
Lisp_Symbol
,详细看结构体Lisp_Type
的定义,如下:
enum Lisp_Type
{
/* Symbol. XSYMBOL (object) points to a struct Lisp_Symbol. */
Lisp_Symbol = 0,
/* Type 1 is currently unused. */
Lisp_Type_Unused0 = 1,
/* Fixnum. XFIXNUM (obj) is the integer value. */
Lisp_Int0 = 2,
Lisp_Int1 = USE_LSB_TAG ? 6 : 3,
/* String. XSTRING (object) points to a struct Lisp_String.
The length of the string, and its contents, are stored therein. */
Lisp_String = 4,
/* Vector of Lisp objects, or something resembling it.
XVECTOR (object) points to a struct Lisp_Vector, which contains
the size and contents. The size field also contains the type
information, if it's not a real vector object. */
Lisp_Vectorlike = 5,
/* Cons. XCONS (object) points to a struct Lisp_Cons. */
Lisp_Cons = USE_LSB_TAG ? 3 : 6,
/* Must be last entry in Lisp_Type enumeration. */
Lisp_Float = 7
};
staticpro()
这个函数是用来向Lisp_Object const *staticvec[2048]
数组中添加成员,让它们不要被gc
给回收掉。staticpro
表示static+pro(tect)
。
<2023-10-31 Tue>
用dot
绘制的emacs
的数据结构
非常可惜呀,上次边学边画了elisp
的数据结构,现在只剩下了导出的.svg
图片,原始代码.dot
文件已经找不到了。CSDN
不支持.svg
图片上传,转化后附上: