sourceinsight 头文件和函数注释的宏实现
插入文件注释代码实现
macro InsertFileComment()
{ hbuf = GetCurrentBuf()
ln =
szName = "pengchao"
szContent = "";
SysTime = GetSysTime()
szYear=SysTime.Year
InsBufLine(hbuf, ln + , "/********************************************************************************")
InsBufLine(hbuf, ln + , "")
InsBufLine(hbuf, ln + , " **** Copyright (C), @szYear@, xx xx xx xx info&tech Co., Ltd. ****")
InsBufLine(hbuf, ln + , "")
InsBufLine(hbuf, ln + , " ********************************************************************************")
sz = GetFileName(GetBufName (hbuf))
InsBufLine(hbuf, ln + , " * File Name : @sz@")
InsBufLine(hbuf, ln + , " * Author : @szName@")
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
}
InsBufLine(hbuf, ln + , " * Date : @sz@-@szMonth@-@szDay@") szTmp = " * Description : "
nlnDesc = ln
iLen = strlen (szContent)
InsBufLine(hbuf, ln + , " * Description : @szContent@")
InsBufLine(hbuf, ln + , " * Version : 1.0")
InsBufLine(hbuf, ln + ," * Function List :")
InsBufLine(hbuf, ln + ," * ")
//插入函数列表 InsBufLine(hbuf, ln + , " * Record :")
InsBufLine(hbuf, ln + , " * 1.Date : @sz@-@szMonth@-@szDay@")
InsBufLine(hbuf, ln + , " * Author : @szName@")
InsBufLine(hbuf, ln + , " * Modification: Created file")
InsBufLine(hbuf, ln + , "")
InsBufLine(hbuf, ln + , "*************************************************************************************************************/")
InsBufLine(hbuf, ln + , "") if(iLen != )
{
return
} //如果没有功能描述内容则提示输入
//szContent = Ask("Description")
SetBufIns(hbuf,nlnDesc + ,)
DelBufLine(hbuf,nlnDesc +) //注释输出处理,自动换行
CommentContent(hbuf,nlnDesc + ," Description : ",szContent,)
}
插入函数注释代码实现
macro InsertFuncComment()
//macro FuncHeadCommentEN(hbuf, ln, szFunc, szMyName,newFunc)
{
hbuf = GetCurrentBuf()
hwnd = GetCurrentWnd()
ln = GetWndSelLnFirst(hwnd)
szMyName = "pengchao"
szFunc = GetCurSymbol()
newFunc =
iIns =
if(newFunc != )
{
symbol = GetSymbolLocationFromLn(hbuf, ln)
if(strlen(symbol) > )
{
hTmpBuf = NewBuf("Tempbuf") //将文件参数头整理成一行并去掉了注释
szLine = GetFunctionDef(hbuf,symbol)
iBegin = symbol.ichName //取出返回值定义
szTemp = strmid(szLine,,iBegin)
szTemp = TrimString(szTemp)
szRet = GetFirstWord(szTemp)
if(symbol.Type == "Method")
{
szTemp = strmid(szTemp,strlen(szRet),strlen(szTemp))
szTemp = TrimString(szTemp)
if(szTemp == "::")
{
szRet = ""
}
}
if(toupper (szRet) == "MACRO")
{
//对于宏返回值特殊处理
szRet = ""
} //从函数头分离出函数参数
nMaxParamSize = GetWordFromString(hTmpBuf,szLine,iBegin,strlen(szLine),"(",",",")")
lnMax = GetBufLineCount(hTmpBuf)
ln = symbol.lnFirst
SetBufIns (hbuf, ln, )
}
}
else
{
lnMax =
szRet = ""
szLine = ""
}
InsBufLine(hbuf, ln, "/*****************************************************************************")
InsBufLine(hbuf, ln+, " * Function : @szFunc@")
InsBufLine(hbuf, ln+, " * Description : ")
oldln = ln
szIns = " * Input : "
if(newFunc != )
{
//对于已经存在的函数输出输入参数表
i =
while ( i < lnMax)
{
szTmp = GetBufLine(hTmpBuf, i)
nLen = strlen(szTmp); //对齐参数后面的空格,实际是对齐后面的参数的说明
szBlank = CreateBlankString(nMaxParamSize - nLen + )
szTmp = cat(szTmp,szBlank)
ln = ln +
szTmp = cat(szIns,szTmp)
InsBufLine(hbuf, ln+, "@szTmp@")
iIns =
szIns = " "
i = i +
}
closebuf(hTmpBuf)
}
if(iIns == )
{
ln = ln +
InsBufLine(hbuf, ln+, " * Input : None")
}
InsBufLine(hbuf, ln+, " * Output : None")
InsBufLine(hbuf, ln+, " * Return : @szRet@")
/*InsBufLine(hbuf, ln+5, " Calls : ")
InsBufLine(hbuf, ln+6, " Called By : ")*/
InsbufLIne(hbuf, ln+, " * Others : "); SysTime = GetSysTime();
sz1=SysTime.Year
sz2=SysTime.month
sz3=SysTime.day
if (sz2 < )
{
szMonth = "0@sz2@"
}
else
{
szMonth = sz2
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} InsBufLine(hbuf, ln + , " * Record")
InsBufLine(hbuf, ln + , " * 1.Date : @sz1@@szMonth@@szDay@")
InsBufLine(hbuf, ln + , " * Author : @szMyName@")
InsBufLine(hbuf, ln + , " * Modification: Created function")
InsBufLine(hbuf, ln + , "")
InsBufLine(hbuf, ln + , "*****************************************************************************/")
if ((newFunc == ) && (strlen(szFunc)>))
{
InsBufLine(hbuf, ln+, "VOS_UINT32 @szFunc@( # )")
InsBufLine(hbuf, ln+, "{");
InsBufLine(hbuf, ln+, " #");
InsBufLine(hbuf, ln+, "}");
SearchForward()
}
hwnd = GetCurrentWnd()
if (hwnd == )
stop
sel = GetWndSel(hwnd)
sel.ichFirst =
sel.ichLim = sel.ichFirst
sel.lnFirst = ln +
sel.lnLast = ln +
//szContent = Ask("Description")
DelBufLine(hbuf,oldln + )
setWndSel(hwnd,sel)
newln = CommentContent(hbuf,oldln + ," * Description : ",szContent,) -
ln = ln + newln - oldln
if ((newFunc == ) && (strlen(szFunc)>))
{
//提示输入函数返回值名
szRet = Ask("Please input return value type")
if(strlen(szRet) > )
{
PutBufLine(hbuf, ln+, " * Return : @szRet@")
PutBufLine(hbuf, ln+, "@szRet@ @szFunc@( # )")
SetbufIns(hbuf,ln+,strlen(szRet)+strlen(szFunc) +
}
szFuncDef = ""
isFirstParam =
sel.ichFirst = strlen(szFunc)+strlen(szRet) +
sel.ichLim = sel.ichFirst + //循环输入新函数的参数
while ()
{
szParam = ask("Please input parameter")
szParam = TrimString(szParam)
szTmp = cat(szIns,szParam)
szParam = cat(szFuncDef,szParam)
sel.lnFirst = ln +
sel.lnLast = ln +
setWndSel(hwnd,sel)
sel.ichFirst = sel.ichFirst + strlen(szParam)
sel.ichLim = sel.ichFirst
oldsel = sel
if(isFirstParam == )
{
PutBufLine(hbuf, ln+, "@szTmp@")
isFirstParam =
}
else
{
ln = ln +
InsBufLine(hbuf, ln+, "@szTmp@")
oldsel.lnFirst = ln +
oldsel.lnLast = ln +
}
SetBufSelText(hbuf,szParam)
szIns = " "
szFuncDef = ", "
oldsel.lnFirst = ln +
oldsel.lnLast = ln +
oldsel.ichFirst =
oldsel.ichLim =
setWndSel(hwnd,oldsel)
}
}
return ln +
}
使用步骤:
1、创建一个quicker.em文件,添加到base工程
/*****************************************************************************
�� �� �� : AutoExpand
�������� : ��չ������ں���
������� : ��
�� �� ֵ :
���ú��� :
�������� : ����ʷ :
1.�� �� : 2008��6��18��
�� �� : ��ǿ
������ : �� *****************************************************************************/
macro AutoExpand()
{
//������Ϣ
// get window, sel, and buffer handles
hwnd = GetCurrentWnd()
if (hwnd == 0)
stop
sel = GetWndSel(hwnd)
if(sel.lnFirst != sel.lnLast)
{
/*�������*/
BlockCommandProc()
}
if (sel.ichFirst == 0)
stop
hbuf = GetWndBuf(hwnd)
language = getreg(LANGUAGE)
if(language != 1)
{
language = 0
}
nVer = 0
nVer = GetVersion()
/*ȡ���û���*/
szMyName = getreg(MYNAME)
if(strlen( szMyName ) == 0)
{
szMyName = Ask("Enter your name:")
setreg(MYNAME, szMyName)
}
// get line the selection (insertion point) is on
szLine = GetBufLine(hbuf, sel.lnFirst);
// parse word just to the left of the insertion point
wordinfo = GetWordLeftOfIch(sel.ichFirst, szLine)
ln = sel.lnFirst;
chTab = CharFromAscii(9) // prepare a new indented blank line to be inserted.
// keep white space on left and add a tab to indent.
// this preserves the indentation level.
chSpace = CharFromAscii(32);
ich = 0
while (szLine[ich] == chSpace || szLine[ich] == chTab)
{
ich = ich + 1
}
szLine1 = strmid(szLine,0,ich)
szLine = strmid(szLine, 0, ich) # " " sel.lnFirst = sel.lnLast
sel.ichFirst = wordinfo.ich
sel.ichLim = wordinfo.ich /*�Զ���ɼ������ƥ����ʾ*/
wordinfo.szWord = RestoreCommand(hbuf,wordinfo.szWord)
sel = GetWndSel(hwnd)
if (wordinfo.szWord == "pn") /*���ⵥ�ŵĴ���*/
{
DelBufLine(hbuf, ln)
AddPromblemNo()
return
}
/*��������ִ��*/
else if (wordinfo.szWord == "config" || wordinfo.szWord == "co")
{
DelBufLine(hbuf, ln)
ConfigureSystem()
return
}
/*����ʷ��¼����*/
else if (wordinfo.szWord == "hi")
{
InsertHistory(hbuf,ln+1,language)
DelBufLine(hbuf, ln)
return
}
else if (wordinfo.szWord == "abg")
{
sel.ichFirst = sel.ichFirst - 3
SetWndSel(hwnd,sel)
InsertReviseAdd()
PutBufLine(hbuf, ln+1 ,szLine1)
SetBufIns(hwnd,ln+1,sel.ichFirst)
return
}
else if (wordinfo.szWord == "dbg")
{
sel.ichFirst = sel.ichFirst - 3
SetWndSel(hwnd,sel)
InsertReviseDel()
PutBufLine(hbuf, ln+1 ,szLine1)
SetBufIns(hwnd,ln+1,sel.ichFirst)
return
}
else if (wordinfo.szWord == "mbg")
{
sel.ichFirst = sel.ichFirst - 3
SetWndSel(hwnd,sel)
InsertReviseMod()
PutBufLine(hbuf, ln+1 ,szLine1)
SetBufIns(hwnd,ln+1,sel.ichFirst)
return
}
if(language == 1)
{
ExpandProcEN(szMyName,wordinfo,szLine,szLine1,nVer,ln,sel)
}
else
{
ExpandProcCN(szMyName,wordinfo,szLine,szLine1,nVer,ln,sel)
}
} /*****************************************************************************
�� �� �� : ExpandProcEN
�������� : Ӣ��˵������չ�����
������� : szMyName �û���
wordinfo
szLine
szLine1
nVer
ln
sel
������� : ��
�� �� ֵ :
���ú��� :
�������� : ����ʷ :
1.�� �� : 2008��6��19��
�� �� : ��ǿ
������ : �����ɺ��� 2.�� �� : 2011��2��16��
�� �� : ���
������ : �����ⵥ��Ϊmantis�ţ���ʱ���ʽΪxxxxxxxx���ꡢ�¡��գ���
�м�û�зָ�������ӵ���ע�ͣ��Զ���չ��Ϊ"an" 3.�� �� : 2011��2��22��
�� �� : ���
������ : �ĵ���ע��ͷΪadd by��delete by��modify by���Զ���չ��ֱ�Ϊ"as"��"ds"��"ms"
�ĵ���ע��Ϊ��������е���sourceinsight 头文件和函数注释的宏实现的更多相关文章
- C/C++常用头文件及函数汇总
转自: C/C++常用头文件及函数汇总 C/C++头文件一览 C #include <assert.h> //设定插入点#include <ctype.h> //字符处理#in ...
- C语言常用的库文件(头文件、函数库)
C语言常用的库文件(头文件.函数库) C系统提供了丰富的系统文件,称为库文件.C的库文件分为两类,一类是扩展名为".h"的文件,称为头文件,在前面的包含命令中我们已多次使用过.在& ...
- sstream头文件-getline 函数 和 stringstream函数 和string的常见用法
2017-08-12 19:50:50 writer:pprp getline函数可以读入一行的字符,不论有没有空格 第一个参数,流 第二个参数 ,将流读入的地方 第三个参数,当读到某个字符的时候停止 ...
- include <ctype.h> 头文件包含函数总结
里面包含的函数主要是: 1.字符测试函数,函数原型一般为:int isXXXX( int ); 参数为int, 只能正确处理[0, 127]. 2.字符映射函数,函数原型一般为:int toXXXX( ...
- glibc头文件和宏定义
头文件没啥好说的,无非就是" "和< >的区别,这估计只要是学过C/C++的人都明白.现在的编译器对头文件的包含顺序没有要求,但老的C实现则不一样.当然,我们现在无需关 ...
- extern,头文件和ifndif宏
转自:CSDN->fpmystar 用#include可以包含其他头文件中变量.函数的声明,为什么还要extern关键字,如果我想引用一个全局变量或函数f(),我只要直接在源文件中包含#incl ...
- gcc 头文件是用户应用程序和函数库之间的桥梁和纽带 功能的真正逻辑实现是以硬件层为基础
gcc GCC, the GNU Compiler Collection - GNU Project - Free Software Foundation (FSF) http://gcc.gnu.o ...
- App开发流程之通用宏定义及头文件
工欲善其事,必先利其器. 在正式实现各种炫酷的功能和UI前,做好准备工作是提高后续开发效率的必经之路. 所以,这个系列,我不是在各种堆技术,更关注的是“兵马动”之前的“粮草行”,有些繁琐,但当清晰理出 ...
- sort()函数与qsort()函数及其头文件
sort()函数与qsort()函数及其头文件 sort()函数是C++中的排序函数其头文件为:#include<algorithm>头文件: qsort()是C中的排序函数,其头文件为: ...
随机推荐
- C - Co-prime
Given a number N, you are asked to count the number of integers between A and B inclusive which are ...
- python字典改变value值方法总结
今天这篇文章中我们来了解一下python之中的字典,在这文章之中我会对python字典修改进行说明,以及举例说明如何修改python字典内的值.我们开始进入文章吧. 首先我们得知道什么是修改字典 修改 ...
- 第5章:Linux系统管理
1.文件读写 1).Python内置的open函数 f = open('data.txt', 'w') f.write('hello, world') f.close() 2).避免文件句柄泄露 tr ...
- S02_CH08_ ZYNQ 定时器中断实验
S02_CH08_ ZYNQ 定时器中断实验 上一章实现了PS接受来自PL的中断,本章将在ZYNQ的纯PS里实现私有定时器中断.每隔一秒中断一次,在中断函数里计数加1,通过串口打印输出. 8.1中断原 ...
- c#泛型约束(转载)
博客地址:https://www.cnblogs.com/zhengwk/p/5541921.html 六种类型的约束: T:结构 类型参数必须是值类型.可以指定除 Nullable 以外的任何值类型 ...
- JavaScript Basics_Fundamentals Part 1_Variables
JavaScript Variables JavaScript 变量(Variables)是用于存储数据值的容器. 创建一个 JavaScript 变量,可以使用关键字 let. Example le ...
- 如何将公式插入到word
平台:win10 x64+ office 2010+ Mathpix Snipping Tool +mathtype6.9b 直接安装就行,下载好了以后,要和word连接起来还需要下载一个插件,有 ...
- [转载] 关于CI,CD,jenkins
Jenkins入门(一) https://blog.csdn.net/miss1181248983/article/details/82840006
- linux常用的操作命令
---恢复内容开始--- 最近换了工作之后,需要管理linux服务器的日常运行和维护,自然linux命令是少不了的,切换目录,vim操作等的简单的操作就不说了,有些时候还需要查看日志和监控服务器启动进 ...
- java 值传递还是引用传递
首先看一下这篇文章 -- 跳 这篇文章就进行了大致的介绍,以及一些简单的例子,但是还缺少一个关键的例子: public class QQ { public static void main(Strin ...