[dev] start add template support
This commit is contained in:
parent
eba3e4f97f
commit
449652f589
32
monkClass.py
32
monkClass.py
@ -23,8 +23,13 @@ class Class(Node.Node):
|
|||||||
if stack[0] == "template":
|
if stack[0] == "template":
|
||||||
debug.debug("find a template class: " + str(stack))
|
debug.debug("find a template class: " + str(stack))
|
||||||
#remove template properties ==> not manage for now ...
|
#remove template properties ==> not manage for now ...
|
||||||
|
propertyTemplate = stack[1:stack.index("class")-1]
|
||||||
|
propertyTemplate[0] = propertyTemplate[0][1:]
|
||||||
stack = stack[stack.index("class"):]
|
stack = stack[stack.index("class"):]
|
||||||
# TODO : add the template properties back ...
|
# TODO : add the template properties back ...
|
||||||
|
debug.debug("template property : " + str(propertyTemplate))
|
||||||
|
else:
|
||||||
|
self.template = []
|
||||||
if len(stack) < 2:
|
if len(stack) < 2:
|
||||||
debug.error("Can not parse class 2 : " + str(stack))
|
debug.error("Can not parse class 2 : " + str(stack))
|
||||||
return
|
return
|
||||||
@ -32,10 +37,34 @@ class Class(Node.Node):
|
|||||||
self.subList = []
|
self.subList = []
|
||||||
self.access = "private"
|
self.access = "private"
|
||||||
# heritage list :
|
# heritage list :
|
||||||
|
self.templateType = None
|
||||||
|
self.templateTypeStr = ""
|
||||||
self.inherit = []
|
self.inherit = []
|
||||||
if len(stack) == 2:
|
if len(stack) == 2:
|
||||||
# just a simple class...
|
# just a simple class...
|
||||||
return
|
return
|
||||||
|
# remove template specification:
|
||||||
|
if stack[2][0] == '<':
|
||||||
|
# This is a template
|
||||||
|
for iii in range(0, len(stack)):
|
||||||
|
if stack[iii] == '>':
|
||||||
|
self.templateType = stack[2:iii]
|
||||||
|
stack = stack[:2] + stack[iii+1:]
|
||||||
|
break;
|
||||||
|
# TODO : add tpe in rendering
|
||||||
|
if self.templateType == None:
|
||||||
|
debug.error("error in parsing class : " + str(stack) + " can not parse template property ...")
|
||||||
|
else:
|
||||||
|
copyTemplateType = self.templateType;
|
||||||
|
self.templateType = []
|
||||||
|
self.templateTypeStr = "<"
|
||||||
|
for val in copyTemplateType:
|
||||||
|
if val[0] == '<':
|
||||||
|
val = val[1:]
|
||||||
|
if val != '>':
|
||||||
|
self.templateType.append(val)
|
||||||
|
self.templateTypeStr += val + " "
|
||||||
|
self.templateTypeStr = ">"
|
||||||
if len(stack) == 3:
|
if len(stack) == 3:
|
||||||
debug.error("error in parsing class : " + str(stack))
|
debug.error("error in parsing class : " + str(stack))
|
||||||
return
|
return
|
||||||
@ -57,6 +86,7 @@ class Class(Node.Node):
|
|||||||
|
|
||||||
def to_str(self) :
|
def to_str(self) :
|
||||||
ret = "class " + self.name
|
ret = "class " + self.name
|
||||||
|
ret += self.templateTypeStr
|
||||||
if len(self.inherit) != 0 :
|
if len(self.inherit) != 0 :
|
||||||
ret += " : "
|
ret += " : "
|
||||||
isFirst = True
|
isFirst = True
|
||||||
@ -75,7 +105,7 @@ class Class(Node.Node):
|
|||||||
parent = module.get_element_with_name(self.inherit[0]['class'])
|
parent = module.get_element_with_name(self.inherit[0]['class'])
|
||||||
cparent = []
|
cparent = []
|
||||||
if parent != None:
|
if parent != None:
|
||||||
#debug.info(" plop : " + self.name + " " + str(parent) + " " + parent.get_name())
|
debug.verbose(" plop : " + self.name + " " + str(parent) + " " + parent.get_name())
|
||||||
cparent = parent.get_parents()
|
cparent = parent.get_parents()
|
||||||
pass
|
pass
|
||||||
#heritage = parent.
|
#heritage = parent.
|
||||||
|
@ -143,7 +143,9 @@ def calculate_methode_size(list):
|
|||||||
methodeSize = 0;
|
methodeSize = 0;
|
||||||
haveVirtual = False
|
haveVirtual = False
|
||||||
for element in list:
|
for element in list:
|
||||||
if element['node'].get_node_type() == 'methode' \
|
if ( element['node'].get_node_type() == 'methode' \
|
||||||
|
or element['node'].get_node_type() == 'constructor' \
|
||||||
|
or element['node'].get_node_type() == 'desctructor') \
|
||||||
and element['node'].get_virtual() == True:
|
and element['node'].get_virtual() == True:
|
||||||
haveVirtual = True
|
haveVirtual = True
|
||||||
if element['node'].get_node_type() == 'variable':
|
if element['node'].get_node_type() == 'variable':
|
||||||
|
@ -275,7 +275,7 @@ class parse_file():
|
|||||||
tok = lex.token()
|
tok = lex.token()
|
||||||
if not tok:
|
if not tok:
|
||||||
break
|
break
|
||||||
debug.debug("TOK: " + str(tok))
|
debug.verbose("TOK: " + str(tok))
|
||||||
self.stack.append( tok.value )
|
self.stack.append( tok.value )
|
||||||
self.curLine = tok.lineno
|
self.curLine = tok.lineno
|
||||||
self.curChar = tok.lexpos
|
self.curChar = tok.lexpos
|
||||||
|
0
test/class.h
Normal file
0
test/class.h
Normal file
8
test/classTemplate.h
Normal file
8
test/classTemplate.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
namespace testMonk {
|
||||||
|
template<typename T> class classTemplate {
|
||||||
|
public:
|
||||||
|
classTemplate();
|
||||||
|
~classTemplate();
|
||||||
|
};
|
||||||
|
}
|
18
test/monk_testMonk.py
Normal file
18
test/monk_testMonk.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
import monkModule
|
||||||
|
import monkTools as tools
|
||||||
|
|
||||||
|
def get_desc():
|
||||||
|
return "monk test all element that is capable"
|
||||||
|
|
||||||
|
def create():
|
||||||
|
# module name is 'ewol' and type binary.
|
||||||
|
myModule = monkModule.Module(__file__, 'testMonk', 'LIBRARY')
|
||||||
|
# enable doculentation :
|
||||||
|
myModule.set_website("http://heeroyui.github.io/monk/")
|
||||||
|
myModule.set_website_sources("http://github.com/heeroyui/monk/test/")
|
||||||
|
myModule.set_path(tools.get_current_path(__file__))
|
||||||
|
myModule.set_path_general_doc(tools.get_current_path(__file__) + "/../doc/")
|
||||||
|
# add the currrent module at the
|
||||||
|
return myModule
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user