Repository: lucy-clownfish Updated Branches: refs/heads/master 613601b4e -> 8d82f9adc
Rework CFCPerlPod_md_to_pod parameters Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/65b1a324 Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/65b1a324 Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/65b1a324 Branch: refs/heads/master Commit: 65b1a324dd398a3ae98c5e3e8deb19d55b6fe149 Parents: 613601b Author: Nick Wellnhofer <wellnho...@aevum.de> Authored: Wed Jul 8 15:32:54 2015 +0200 Committer: Nick Wellnhofer <wellnho...@aevum.de> Committed: Wed Jul 8 18:15:32 2015 +0200 ---------------------------------------------------------------------- compiler/perl/lib/Clownfish/CFC.xs | 10 ++++------ compiler/src/CFCPerlClass.c | 4 ++-- compiler/src/CFCPerlPod.c | 30 ++++++++++++++---------------- compiler/src/CFCPerlPod.h | 5 ++--- 4 files changed, 22 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/65b1a324/compiler/perl/lib/Clownfish/CFC.xs ---------------------------------------------------------------------- diff --git a/compiler/perl/lib/Clownfish/CFC.xs b/compiler/perl/lib/Clownfish/CFC.xs index 8e8f0f3..fb1f883 100644 --- a/compiler/perl/lib/Clownfish/CFC.xs +++ b/compiler/perl/lib/Clownfish/CFC.xs @@ -2414,17 +2414,15 @@ PPCODE: SV* -_md_to_pod(self, klass, source) - CFCPerlPod *self; +_md_to_pod(source, klass) CFCClass *klass; const char *source; CODE: - RETVAL = S_sv_eat_c_string(CFCPerlPod_md_to_pod(self, klass, source)); + RETVAL = S_sv_eat_c_string(CFCPerlPod_md_to_pod(source, klass)); OUTPUT: RETVAL SV* -_gen_subroutine_pod(self, func, alias, klass, code_sample, class_name, is_constructor) - CFCPerlPod *self; +_gen_subroutine_pod(func, alias, klass, code_sample, class_name, is_constructor) CFCFunction *func; const char *alias; CFCClass *klass; @@ -2432,7 +2430,7 @@ _gen_subroutine_pod(self, func, alias, klass, code_sample, class_name, is_constr const char *class_name; int is_constructor; CODE: - char *value = CFCPerlPod_gen_subroutine_pod(self, func, alias, klass, + char *value = CFCPerlPod_gen_subroutine_pod(func, alias, klass, code_sample, class_name, is_constructor); RETVAL = S_sv_eat_c_string(value); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/65b1a324/compiler/src/CFCPerlClass.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCPerlClass.c b/compiler/src/CFCPerlClass.c index dc1d234..8112328 100644 --- a/compiler/src/CFCPerlClass.c +++ b/compiler/src/CFCPerlClass.c @@ -357,7 +357,7 @@ CFCPerlClass_create_pod(CFCPerlClass *self) { // Get the class's brief description. const char *raw_brief = CFCDocuComment_get_brief(docucom); - char *brief = CFCPerlPod_md_to_pod(pod_spec, client, raw_brief); + char *brief = CFCPerlPod_md_to_pod(raw_brief, client); // Get the class's long description. char *description; @@ -367,7 +367,7 @@ CFCPerlClass_create_pod(CFCPerlClass *self) { } else { const char *raw_description = CFCDocuComment_get_long(docucom); - description = CFCPerlPod_md_to_pod(pod_spec, client, raw_description); + description = CFCPerlPod_md_to_pod(raw_description, client); } // Create SYNOPSIS. http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/65b1a324/compiler/src/CFCPerlPod.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCPerlPod.c b/compiler/src/CFCPerlPod.c index 5a26ad5..9ef4bb8 100644 --- a/compiler/src/CFCPerlPod.c +++ b/compiler/src/CFCPerlPod.c @@ -60,13 +60,13 @@ static const CFCMeta CFCPERLPOD_META = { }; static char* -S_nodes_to_pod(CFCClass *klass, cmark_node *node); +S_nodes_to_pod(cmark_node *node, CFCClass *klass); static char* S_pod_escape(const char *content); static char* -S_convert_link(CFCClass *klass, cmark_node *link); +S_convert_link(cmark_node *link, CFCClass *klass); static char* S_pod_link(const char *text, const char *name); @@ -181,7 +181,7 @@ CFCPerlPod_methods_pod(CFCPerlPod *self, CFCClass *klass) { } else { meth_pod - = CFCPerlPod_gen_subroutine_pod(self, (CFCFunction*)method, + = CFCPerlPod_gen_subroutine_pod((CFCFunction*)method, meth_spec.alias, klass, meth_spec.sample, class_name, false); @@ -223,7 +223,7 @@ CFCPerlPod_constructors_pod(CFCPerlPod *self, CFCClass *klass) { else { CFCFunction *init_func = CFCClass_function(klass, slot.func); char *sub_pod - = CFCPerlPod_gen_subroutine_pod(self, init_func, slot.alias, klass, + = CFCPerlPod_gen_subroutine_pod(init_func, slot.alias, klass, slot.sample, class_name, true); pod = CFCUtil_cat(pod, sub_pod, NULL); FREEMEM(sub_pod); @@ -233,7 +233,7 @@ CFCPerlPod_constructors_pod(CFCPerlPod *self, CFCClass *klass) { } char* -CFCPerlPod_gen_subroutine_pod(CFCPerlPod *self, CFCFunction *func, +CFCPerlPod_gen_subroutine_pod(CFCFunction *func, const char *alias, CFCClass *klass, const char *code_sample, const char *class_name, int is_constructor) { @@ -287,7 +287,7 @@ CFCPerlPod_gen_subroutine_pod(CFCPerlPod *self, CFCFunction *func, // Incorporate "description" text from DocuComment. const char *long_doc = CFCDocuComment_get_description(docucomment); if (long_doc && strlen(long_doc)) { - char *perlified = CFCPerlPod_md_to_pod(self, klass, long_doc); + char *perlified = CFCPerlPod_md_to_pod(long_doc, klass); pod = CFCUtil_cat(pod, perlified, NULL); FREEMEM(perlified); } @@ -298,7 +298,7 @@ CFCPerlPod_gen_subroutine_pod(CFCPerlPod *self, CFCFunction *func, if (param_names[0]) { pod = CFCUtil_cat(pod, "=over\n\n", NULL); for (size_t i = 0; param_names[i] != NULL; i++) { - char *perlified = CFCPerlPod_md_to_pod(self, klass, param_docs[i]); + char *perlified = CFCPerlPod_md_to_pod(param_docs[i], klass); pod = CFCUtil_cat(pod, "=item *\n\nB<", param_names[i], "> - ", perlified, NULL); FREEMEM(perlified); @@ -309,7 +309,7 @@ CFCPerlPod_gen_subroutine_pod(CFCPerlPod *self, CFCFunction *func, // Add return value description, if any. const char *retval_doc = CFCDocuComment_get_retval(docucomment); if (retval_doc && strlen(retval_doc)) { - char *perlified = CFCPerlPod_md_to_pod(self, klass, retval_doc); + char *perlified = CFCPerlPod_md_to_pod(retval_doc, klass); pod = CFCUtil_cat(pod, "Returns: ", perlified, NULL); FREEMEM(perlified); } @@ -318,18 +318,16 @@ CFCPerlPod_gen_subroutine_pod(CFCPerlPod *self, CFCFunction *func, } char* -CFCPerlPod_md_to_pod(CFCPerlPod *self, CFCClass *klass, const char *md) { - (void)self; // unused - +CFCPerlPod_md_to_pod(const char *md, CFCClass *klass) { cmark_node *doc = cmark_parse_document(md, strlen(md)); - char *pod = S_nodes_to_pod(klass, doc); + char *pod = S_nodes_to_pod(doc, klass); cmark_node_free(doc); return pod; } static char* -S_nodes_to_pod(CFCClass *klass, cmark_node *node) { +S_nodes_to_pod(cmark_node *node, CFCClass *klass) { char *result = CFCUtil_strdup(""); if (node == NULL) { return result; @@ -441,7 +439,7 @@ S_nodes_to_pod(CFCClass *klass, cmark_node *node) { case CMARK_NODE_LINK: if (ev_type == CMARK_EVENT_ENTER) { - char *pod = S_convert_link(klass, node); + char *pod = S_convert_link(node, klass); result = CFCUtil_cat(result, pod, NULL); FREEMEM(pod); cmark_iter_reset(iter, node, CMARK_EVENT_EXIT); @@ -533,10 +531,10 @@ S_pod_escape(const char *content) { } static char* -S_convert_link(CFCClass *klass, cmark_node *link) { +S_convert_link(cmark_node *link, CFCClass *klass) { cmark_node *child = cmark_node_first_child(link); const char *uri = cmark_node_get_url(link); - char *text = S_nodes_to_pod(klass, child); + char *text = S_nodes_to_pod(child, klass); char *retval; if (!CFCUri_is_clownfish_uri(uri)) { http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/65b1a324/compiler/src/CFCPerlPod.h ---------------------------------------------------------------------- diff --git a/compiler/src/CFCPerlPod.h b/compiler/src/CFCPerlPod.h index c87c30d..e2352e4 100644 --- a/compiler/src/CFCPerlPod.h +++ b/compiler/src/CFCPerlPod.h @@ -99,8 +99,7 @@ const char* CFCPerlPod_get_description(CFCPerlPod *self); char* -CFCPerlPod_md_to_pod(CFCPerlPod *self, struct CFCClass *klass, - const char *source); +CFCPerlPod_md_to_pod(const char *md, struct CFCClass *klass); /** Autogenerate pod for either a Clownfish::CFC::Model::Method or a * Clownfish::CFC::Model::Function. @@ -113,7 +112,7 @@ CFCPerlPod_md_to_pod(CFCPerlPod *self, struct CFCClass *klass, * argument handling is different for constructors. */ char* -CFCPerlPod_gen_subroutine_pod(CFCPerlPod *self, struct CFCFunction *func, +CFCPerlPod_gen_subroutine_pod(struct CFCFunction *func, const char *alias, struct CFCClass *klass, const char *code_sample, const char *class_name, int is_constructor);