Adding new stuff
This commit is contained in:
parent
9ef8a96f9a
commit
0b3d063cb3
1580 changed files with 0 additions and 0 deletions
78
vim-plugins/bundle/xptemplate/ftplugin/c/autoimplem.xpt.vim
Normal file
78
vim-plugins/bundle/xptemplate/ftplugin/c/autoimplem.xpt.vim
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
" finish " not finished
|
||||
if !g:XPTloadBundle( 'c', 'autoimplem' ) && !exists('g:cppautoimplemneedc') && !exists('g:objcautoimlemneedc')
|
||||
finish
|
||||
endif
|
||||
|
||||
XPTemplate priority=lang-2
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
" ========================== Support functions ======================
|
||||
let s:defaultImpl = { 'void' : ''
|
||||
\, 'int' : "\treturn 0;"
|
||||
\, 'unsigned int' : "\treturn 0;"
|
||||
\, 'short' : "\treturn 0;"
|
||||
\, 'unsigned short' : "\treturn 0;"
|
||||
\, 'char' : "\treturn '\0';"
|
||||
\, 'unsigned char' : "\treturn '\0';"
|
||||
\, 'double': "\treturn 0.0;"
|
||||
\, 'float' : "\treturn 0.0f;"
|
||||
\, 'bool' : "\treturn false;"
|
||||
\}
|
||||
|
||||
let s:f.todoText = "\t/* TODO : implement here */"
|
||||
|
||||
fun! s:f.GetDefaultImplementation( type )
|
||||
|
||||
if has_key( s:defaultImpl, a:type )
|
||||
return s:defaultImpl[ a:type ]
|
||||
endif
|
||||
|
||||
" check if type is a pointer.
|
||||
if a:type =~ '.*\*$'
|
||||
return "\treturn NULL;"
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
fun! s:f.GetImplementationFile() "{{{
|
||||
let name = expand('%:p')
|
||||
|
||||
if name =~ '\.h$'
|
||||
let name = substitute( name, 'h$', '[cC]*', '' )
|
||||
elseif name =~ '\.hpp$'
|
||||
let name = substitute( name, 'hpp$', '[cC]*', '' )
|
||||
endif
|
||||
|
||||
return glob( name )
|
||||
endfunction "}}}
|
||||
|
||||
fun! s:f.WriteFunToCpp() " {{{
|
||||
let imple = s:f.GetImplementationFile()
|
||||
if imple == ''
|
||||
return
|
||||
endif
|
||||
|
||||
let retType = self.R('retType')
|
||||
let funName = self.R('funName')
|
||||
|
||||
let args = self.R( 'args' )
|
||||
let methodBody = [ retType . ' ' . funName . '(' . args . ')'
|
||||
\ , '{'
|
||||
\ , s:f.todoText
|
||||
\ , s:f.GetDefaultImplementation( retType )
|
||||
\ , '}'
|
||||
\ , '' ]
|
||||
|
||||
let txt = extend( readfile( imple ), methodBody )
|
||||
call writefile( txt, imple )
|
||||
|
||||
return args
|
||||
endfunction " }}}
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
XPT hfun " create proto in h and implementation in .c/.cc/.cpp
|
||||
`retType^ `funName^( `args^WriteFunToCpp()^^);
|
||||
..XPT
|
||||
|
||||
110
vim-plugins/bundle/xptemplate/ftplugin/c/c.xpt.vim
Normal file
110
vim-plugins/bundle/xptemplate/ftplugin/c/c.xpt.vim
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
XPTemplate priority=lang
|
||||
|
||||
|
||||
XPTvar $TRUE 1
|
||||
XPTvar $FALSE 0
|
||||
XPTvar $NULL NULL
|
||||
|
||||
XPTvar $BRif ' '
|
||||
XPTvar $BRloop ' '
|
||||
XPTvar $BRstc ' '
|
||||
XPTvar $BRfun ' '
|
||||
|
||||
XPTvar $VOID_LINE /* void */;
|
||||
XPTvar $CURSOR_PH /* cursor */
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
|
||||
XPTvar $CL /*
|
||||
XPTvar $CM *
|
||||
XPTvar $CR */
|
||||
XPTinclude
|
||||
\ _comment/doubleSign
|
||||
|
||||
XPTinclude
|
||||
\ _condition/c.like
|
||||
\ _func/c.like
|
||||
\ _loops/c.while.like
|
||||
\ _preprocessor/c.like
|
||||
\ _structures/c.like
|
||||
\ _printf/c.like
|
||||
|
||||
XPTinclude
|
||||
\ _loops/for
|
||||
|
||||
|
||||
let s:f = g:XPTfuncs()
|
||||
|
||||
|
||||
|
||||
XPT _printfElts hidden
|
||||
XSET elts|pre=Echo('')
|
||||
XSET elts=c_printf_elts( R( 'pattern' ), ',' )
|
||||
"`pattern^"`elts^
|
||||
|
||||
|
||||
XPT printf " printf\(...)
|
||||
printf(`$SParg^`:_printfElts:^`$SParg^)
|
||||
|
||||
|
||||
XPT sprintf " sprintf\(...)
|
||||
sprintf(`$SParg^`str^,`$SPop^`:_printfElts:^`$SParg^)
|
||||
|
||||
|
||||
XPT snprintf " snprintf\(...)
|
||||
snprintf(`$SParg^`str^,`$SPop^`size^,`$SPop^`:_printfElts:^`$SParg^)
|
||||
|
||||
|
||||
XPT fprintf " fprintf\(...)
|
||||
fprintf(`$SParg^`stream^,`$SPop^`:_printfElts:^`$SParg^)
|
||||
|
||||
XPT memcpy " memcpy (..., ..., sizeof (...) ... )
|
||||
memcpy(`$SParg^`dest^,`$SPop^`source^,`$SPop^sizeof(`type^int^)`$SPop^*`$SPop^`count^`$SParg^)
|
||||
|
||||
XPT memset " memset (..., ..., sizeof (...) ... )
|
||||
memset(`$SParg^`buffer^,`$SPop^`what^0^,`$SPop^sizeof(`$SParg^`type^int^`$SParg^)`$SPop^*`$SPop^`count^`$SParg^)
|
||||
|
||||
XPT malloc " malloc ( ... );
|
||||
(`type^int^*)malloc(`$SParg^sizeof(`$SParg^`type^`$SParg^)`$SPop^*`$SPop^`count^`$SParg^)
|
||||
|
||||
XPT assert " assert (.., msg)
|
||||
assert(`$SParg^`isTrue^,`$SPop^"`text^"`$SParg^)
|
||||
|
||||
|
||||
XPT fcomment
|
||||
/**
|
||||
* @author : `$author^ | `$email^
|
||||
* @description
|
||||
* `cursor^
|
||||
* @return {`int^} `desc^
|
||||
*/
|
||||
|
||||
|
||||
XPT para syn=comment " comment parameter
|
||||
@param {`Object^} `name^ `desc^
|
||||
|
||||
XPT filehead
|
||||
XSET cursor|pre=CURSOR
|
||||
/**-------------------------/// `sum^ \\\---------------------------
|
||||
*
|
||||
* <b>`function^</b>
|
||||
* @version : `1.0^
|
||||
* @since : `date()^
|
||||
*
|
||||
* @description :
|
||||
* `cursor^
|
||||
* @usage :
|
||||
*
|
||||
* @author : `$author^ | `$email^
|
||||
* @copyright `.com.cn^
|
||||
* @TODO :
|
||||
*
|
||||
*--------------------------\\\ `sum^ ///---------------------------*/
|
||||
|
||||
..XPT
|
||||
|
||||
|
||||
XPT call wraponly=param " ..( .. )
|
||||
`name^(`$SParg^`param^`$SParg^)
|
||||
|
||||
12
vim-plugins/bundle/xptemplate/ftplugin/c/c99.xpt.vim
Normal file
12
vim-plugins/bundle/xptemplate/ftplugin/c/c99.xpt.vim
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
" C99 relax some variable definition rules
|
||||
" allowing to use C++/Java style for loop
|
||||
if !g:XPTloadBundle( 'c', 'c99' )
|
||||
finish
|
||||
endif
|
||||
|
||||
XPTemplate priority=sub
|
||||
|
||||
XPTinclude
|
||||
\ _common/common
|
||||
\ _loops/java.for.like
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue