插入文件注释代码实现

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 头文件和函数注释的宏实现的更多相关文章

  1. C/C++常用头文件及函数汇总

    转自: C/C++常用头文件及函数汇总 C/C++头文件一览 C #include <assert.h> //设定插入点#include <ctype.h> //字符处理#in ...

  2. C语言常用的库文件(头文件、函数库)

    C语言常用的库文件(头文件.函数库) C系统提供了丰富的系统文件,称为库文件.C的库文件分为两类,一类是扩展名为".h"的文件,称为头文件,在前面的包含命令中我们已多次使用过.在& ...

  3. sstream头文件-getline 函数 和 stringstream函数 和string的常见用法

    2017-08-12 19:50:50 writer:pprp getline函数可以读入一行的字符,不论有没有空格 第一个参数,流 第二个参数 ,将流读入的地方 第三个参数,当读到某个字符的时候停止 ...

  4. include <ctype.h> 头文件包含函数总结

    里面包含的函数主要是: 1.字符测试函数,函数原型一般为:int isXXXX( int ); 参数为int, 只能正确处理[0, 127]. 2.字符映射函数,函数原型一般为:int toXXXX( ...

  5. glibc头文件和宏定义

    头文件没啥好说的,无非就是" "和< >的区别,这估计只要是学过C/C++的人都明白.现在的编译器对头文件的包含顺序没有要求,但老的C实现则不一样.当然,我们现在无需关 ...

  6. extern,头文件和ifndif宏

    转自:CSDN->fpmystar 用#include可以包含其他头文件中变量.函数的声明,为什么还要extern关键字,如果我想引用一个全局变量或函数f(),我只要直接在源文件中包含#incl ...

  7. gcc 头文件是用户应用程序和函数库之间的桥梁和纽带 功能的真正逻辑实现是以硬件层为基础

    gcc GCC, the GNU Compiler Collection - GNU Project - Free Software Foundation (FSF) http://gcc.gnu.o ...

  8. App开发流程之通用宏定义及头文件

    工欲善其事,必先利其器. 在正式实现各种炫酷的功能和UI前,做好准备工作是提高后续开发效率的必经之路. 所以,这个系列,我不是在各种堆技术,更关注的是“兵马动”之前的“粮草行”,有些繁琐,但当清晰理出 ...

  9. sort()函数与qsort()函数及其头文件

    sort()函数与qsort()函数及其头文件 sort()函数是C++中的排序函数其头文件为:#include<algorithm>头文件: qsort()是C中的排序函数,其头文件为: ...

随机推荐

  1. 2.3负载均衡:Ribbon

    基于上一篇文章的工程,启动eureka-server 工程:启动service-hi工程,它的端口为8765:将service-hi的配置文件的端口改为8763,并启动,这时你会发现:service- ...

  2. 2019牛客暑期多校训练营(第三场)F Planting Trees 单调队列

    F Planting Trees 题目链接 https://ac.nowcoder.com/acm/contest/883/F 题目描述 The semester is finally over an ...

  3. 关于@service、@controller和@transactional 在spring中的位置说明

    Spring容器优先加载由ServletContextListener(对应applicationContext.xml)产生的父容器,而SpringMVC(对应mvc_dispatcher_serv ...

  4. 一、python快速入门(每个知识点后包含练习)

    1. 编程与编程语言 编程的目的是什么? #计算机的发明,是为了用机器取代/解放人力,而编程的目的则是将人类的思想流程按照某种能够被计算机识别的表达方式传递给计算机,从而达到让计算机能够像人脑/电脑一 ...

  5. 安卓开发之ListView入门

    <!--这个地方最好用match_parent 这样效率高--> <ListView android:layout_width="match_parent" an ...

  6. echarts —— 重叠图

    平时做堆叠图比较多,但是今天遇到一个要做重叠图的需求,记录一下~ 1.堆叠图,对应的 series: [] ,需要设置一个stack: "1",其中每个堆叠图的stack属性值都要 ...

  7. S/4HANA中的销售计划管理

    大家好,我所在的S/4HANA Sales(SD)成都研发团队,主要负责S/4HANA里销售模块相关的标准产品研发. 作为产品研发团队,我们遵循SCRUM迭代式增量软件开发过程,以两个星期为一个迭代, ...

  8. Redis和MemCache静态Map做缓存区别

    本地缓存和分布式缓存 本地缓存:使用自带的map或者guava实现的是本地缓存,最主要的特点是轻量以及快速,生命周期随着jvm的销毁而结束,并且在多实例的情况下,每个实例都需要各自保存一份缓存,缓存不 ...

  9. JAVA 内存模型(主内存,工作内存)

    JVM将内存组织为主内存和工作内存两个部分. 主内存是所有的线程所共享的,主要包括本地方法区和堆. 每个线程都有一个工作内存不是共享的,工作内存中主要包括两个部分: 1:一个是属于该线程私有的栈; 2 ...

  10. 命令行工具--LLDP

    目录 命令行工具--LLDP 一.场景引入 二.什么是LLDP? 三.在CentOS上安装LLDP 四.命令详解 五.脚本 命令行工具--LLDP 一.场景引入 有的时候,我们需要知道服务器上联交换机 ...