@@ -629,6 +629,20 @@ add_custom_command( | |||
) | |||
add_custom_command( | |||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/tc_plugin2.cpp | |||
COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/bin/cppcms_tmpl_cc | |||
-o ${CMAKE_CURRENT_BINARY_DIR}/tc_plugin2.cpp | |||
${CMAKE_CURRENT_SOURCE_DIR}/tests/tc_plugin2.tmpl | |||
DEPENDS | |||
${CMAKE_CURRENT_BINARY_DIR}/tc_sep_skin.h | |||
${CMAKE_CURRENT_SOURCE_DIR}/bin/cppcms_tmpl_cc | |||
${CMAKE_CURRENT_SOURCE_DIR}/tests/tc_skin.tmpl | |||
${CMAKE_CURRENT_SOURCE_DIR}/tests/tc_plugin2.tmpl | |||
) | |||
@@ -650,13 +664,14 @@ if(NOT DISABLE_SHARED) | |||
COMPILE_DEFINITIONS "${SKIN3_DEFS}") | |||
target_link_libraries(skin3 ${CPPCMS_LIB}) | |||
foreach(SKIN tc_skin_a tc_skin_b tc_skin tc_sep_skin_a tc_sep_skin_b tc_sep_skin tc_plugin) | |||
foreach(SKIN tc_skin_a tc_skin_b tc_skin tc_sep_skin_a tc_sep_skin_b tc_sep_skin tc_plugin tc_plugin2) | |||
add_library(${SKIN} SHARED ${CMAKE_CURRENT_BINARY_DIR}/${SKIN}.cpp) | |||
target_link_libraries(${SKIN} ${CPPCMS_LIB}) | |||
if(IS_WINDOWS) | |||
set_target_properties(${SKIN} PROPERTIES COMPILE_DEFINITIONS DLL_EXPORT) | |||
endif() | |||
endforeach() | |||
target_link_libraries(tc_plugin2 tc_sep_skin) | |||
add_library(plugin SHARED tests/test_plugin_so.cpp) | |||
target_link_libraries(plugin ${CPPCMS_LIB}) | |||
@@ -112,7 +112,7 @@ class html_type: | |||
class view_block: | |||
pattern=r'^<%\s*view\s+(\w+)\s+uses\s+(:?:?\w+(::\w+)*)(\s+extends\s+(:?:?\w+(::\w+)?))?(?P<abs>\s+abstract)?\s*%>$' | |||
pattern=r'^<%\s*view\s+(\w+)\s+uses\s+(:?:?\w+(::\w+)*)(\s+extends\s+(:?:?\w+(::\w+)?))?(?P<abs>\s+abstract)?(?P<inline>\s+inline)?\s*%>$' | |||
basic_pattern='view' | |||
basic_name='view' | |||
type='view' | |||
@@ -124,7 +124,12 @@ class view_block: | |||
self.topmost = 1 | |||
else: | |||
constructor='%s(_s,_content)' % self.extends; | |||
output_declaration( "struct %s :public %s" % (self.class_name , self.extends )) | |||
global dll_api | |||
if self.inline: | |||
api_ref = '' | |||
else: | |||
api_ref = dll_api | |||
output_declaration( "struct %s %s :public %s" % (api_ref, self.class_name , self.extends )) | |||
output_declaration( "{") | |||
if self.uses!='' : | |||
output_declaration( "\t%s &content;" % self.uses) | |||
@@ -139,6 +144,7 @@ class view_block: | |||
def use(self,m): | |||
self.abstract = m.group('abs')!=None | |||
self.inline = m.group('inline')!=None | |||
global view_name | |||
global output_template | |||
self.class_name=m.group(1) | |||
@@ -1110,6 +1116,17 @@ def main(): | |||
output_template = output_declaration | |||
else: | |||
output_template = output_definition | |||
if header_file!='': | |||
global header_define | |||
global dll_api | |||
header_define = "CPPCMS_GENERATED_HEADER_%s_TMPL_HEADER_INCLUDED" % ( re.sub("[^a-zA-Z0-9]+", "_", header_file ).upper()) | |||
if sys.version_info >= (2,5): | |||
from hashlib import md5 | |||
else: | |||
from md5 import md5 | |||
dll_api = 'VIEW_%s_API' % md5(header_define).hexdigest().upper() | |||
global output_fd | |||
if output_file!='': | |||
output_fd=open(output_file,"w") | |||
@@ -1202,6 +1219,8 @@ definitions = StringIO.StringIO(); | |||
inline_cpp_to = output_declaration | |||
inline_templates = "default" | |||
output_template = output_definition | |||
header_define = '' | |||
dll_api = '' | |||
################ | |||
@@ -1209,13 +1228,26 @@ main() | |||
################ | |||
if header_file!='': | |||
header_define = "CPPCMS_GENERATED_HEADER_%s_TMPL_HEADER_INCLUDED" % ( re.sub("[^a-zA-Z0-9]+", "_", header_file ).upper()) | |||
output_hfd=open(header_file,"w") | |||
output_hfd.write("#ifndef %s\n" % ( header_define )) | |||
output_hfd.write("#define %s\n\n" % ( header_define )) | |||
output_hfd.write("#if defined(__WIN32) || defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__)\n") | |||
output_hfd.write("# ifdef DLL_EXPORT\n") | |||
output_hfd.write("# ifdef %s_SOURCE\n" % dll_api) | |||
output_hfd.write("# define %s __declspec(dllexport)\n" % dll_api) | |||
output_hfd.write("# else\n") | |||
output_hfd.write("# define %s __declspec(dllimport)\n" % dll_api) | |||
output_hfd.write("# endif\n") | |||
output_hfd.write("# else\n") | |||
output_hfd.write("# define %s\n" % dll_api) | |||
output_hfd.write("# endif\n") | |||
output_hfd.write("#else\n") | |||
output_hfd.write("# define %s\n" % dll_api) | |||
output_hfd.write("#endif\n") | |||
output_hfd.write(declarations.getvalue()); | |||
output_hfd.write("#endif // %s\n" % ( header_define )) | |||
output_hfd.close() | |||
output_fd.write('#define %s_SOURCE\n' % dll_api); | |||
output_fd.write('#include "%s"\n\n' % os.path.basename(header_file)); | |||
else: | |||
output_fd.write(declarations.getvalue()); | |||
@@ -0,0 +1,6 @@ | |||
<% c++ #include "tc_sep_skin.h" %> | |||
<% skin plugin2 %> | |||
<% view master_plugin uses data::master extends tc_skin::master_api2 %> | |||
<% template call() %>Plugin2: <% include f1() %><% end %> | |||
<% end view %> | |||
<% end skin %> |
@@ -219,11 +219,17 @@ TBD | |||
<% end template %> | |||
<% end view %> | |||
<% view master_api uses data::master abstract %> | |||
<% view master_api uses data::master abstract inline %> | |||
<% template m1() = 0 %> | |||
<% end view %> | |||
<% view helper_api uses data::helper abstract%> | |||
<% view master_api2 uses data::master abstract %> | |||
<% template f1() %>f1-test<% end %> | |||
<% template call() = 0 %> | |||
<% end view %> | |||
<% view helper_api uses data::helper abstract inline %> | |||
<% template h1()=0%> | |||
<% end view %> | |||
@@ -243,6 +249,7 @@ TBD | |||
<% using master_api as m from "plugin",name1 %><% include m1() from m %><% end using %> | |||
<% using master_api as m from skin1,"master_plugin" %><% include m1() from m %><% end using %> | |||
<% using master_api as m from skin1,name1 %><% include m1() from m %><% end using %> | |||
<% using master_api2 as m from "plugin2","master_plugin" %><% include call() from m %><% end using %> | |||
<% end template %> | |||
<% end view %> | |||
@@ -497,6 +497,7 @@ public: | |||
"plugin::master_plugin::m1 Text\n" //from "tc_plugin",name1 include m1() | |||
"plugin::master_plugin::m1 Text\n" //from skin1,"master_plugin" include m1() | |||
"plugin::master_plugin::m1 Text\n" //from skin1,name1 include m1() | |||
"Plugin2: f1-test\n" // master_api2 as m from "plugin2","master_plugin"; include call() | |||
""); | |||
c.skin1="plugin"; | |||
@@ -536,6 +537,7 @@ int main(int argc,char **argv) | |||
cfg["views"]["skins"][1]="tc_sep_skin_b"; | |||
cfg["views"]["skins"][2]="tc_sep_skin"; | |||
cfg["views"]["skins"][3]="tc_plugin"; | |||
cfg["views"]["skins"][4]="tc_plugin2"; | |||
} | |||
else { | |||
std::cout << "Using shared header/body" << std::endl; | |||