[Gambas-devel] Question of parameters (2)

Benoit Minisini gambas at ...1...
Mon Jul 5 21:47:11 CEST 2004


On Sunday 04 July 2004 21:46, Charlie Reinl wrote:
> Salut ,
>
> Thank you Nigel.I can't take it, if you could just have a look to that,
> again.
>
> I reactivated the code where I try to pass the paameters:
>
> IN->CEditor.cpp
>
>   GB_METHOD("PrettyPrinter", NULL, CEDITOR_PrettyPrinter,
> "[(bSpace)b(iSpace)i(bEvery)b(bEveryWithOutDim)b(bAlignComments)b(bWithInCa
>se)b(bDelEmptyLines)b]"),
>
> // and
> /*
>  bSpace = TRUE
>  	iSpace (from 1 to 9 ) is one Indent
>  bSpace = FALSE
>  	iSpace is one Editor.TabLength to Indent
>    or   "\t"
> bool bEvery	= TRUE ; //=> Everything is Indeted
> //	if bEvery = FALSE => bEveryWithOutDim will be FALSE too
> //	if bEvery = FALSE => bAlignComments also will be FALSE
> bool bEveryWithOutDim = TRUE ; // => Everything is Indeted, but NOT
> Declarations
> bool bAlignComments	= TRUE ;   // => Comments are align to the folowing
> line bool bWithInCase	= TRUE ;   // => lines between 'CASE x' will be
> indented too // is not implemented yet
> bool bDelEmptyLines = TRUE ;   // => empty lines will be striped off
> */
> BEGIN_METHOD_VOID(CEDITOR_PrettyPrinter, GB_BOOLEAN bSpace; GB_INTEGER
> iSpace; GB_BOOLEAN bEvery; GB_BOOLEAN bEveryWithOutDim; GB_BOOLEAN
> bAlignComments; GB_BOOLEAN bWithInCase; GB_BOOLEAN bDelEmptyLines)
>   {
> 	if (MISSING(bSpace))
> 		bSpace = TRUE;
> 	if (MISSING(iSpace))
> 		iSpace = tabSpace();
> 	if (MISSING(bEvery))
> 		bEvery = TRUE;
> 	if (MISSING(bEveryWithOutDim))
> 		bEveryWithOutDim = TRUE;
> 	if (MISSING(bAlignComments))
> 		bAlignComments = TRUE;
> 	if (MISSING(bWithInCase))
> 		bWithInCase = FALSE; // is not implemented yet
> 	else
> 		bWithInCase = FALSE; // is not implemented yet
> 	if (MISSING(bDelEmptyLines))
> 		bDelEmptyLines = TRUE;
>
> 	if (!bEvery)
> 	{
> 		bEveryWithOutDim = FALSE;
>  		bAlignComments = FALSE;
>  	}
>
> WIDGET->PrettyPrinter(bSpace,iSpace,bEvery,bEveryWithOutDim,bAlignComments,
>bWithInCase,bDelEmptyLines); }
> END_METHOD
>
>
> IN->qeditor.h
>
> void PrettyPrinter(bool bSpace,int iSpace,bool bEvery,bool
> bEveryWithOutDim,bool bAlignComments,bool bWithInCase,bool bDelEmptyLines);
>
> IN->qeditor.cpp
>
> void QEditor::PrettyPrinter(bool bSpace,int iSpace,bool bEvery,bool
> bEveryWithOutDim,bool bAlignComments,bool bWithInCase,bool bDelEmptyLines)
>
> make shows me the following Output:
>
> CEditor.cpp:564:204: macro "BEGIN_METHOD_VOID" passed 2 arguments, but
> takes just 1
> CEditor.cpp:565: error: syntax error before `{' token
> CEditor.cpp:586: error: ISO C++ forbids declaration of `bAlignComments'
> with no
>    type
> CEditor.cpp:587: error: parse error before `}' token
> CEditor.cpp:588: error: parse error before `*' token
> CEditor.cpp:771: error: `CEDITOR_PrettyPrinter' was not declared in this
> scope make: *** [CEditor.lo] Error 1
>
> if I change CEditor.cpp:564:204: macro "BEGIN_METHOD_VOID" to
> "BEGIN_METHOD" I get that.
>
> CEditor.cpp: In function `void CEDITOR_PrettyPrinter(void*, void*)':
> CEditor.cpp:567: error: `bSpace' undeclared (first use this function)
> CEditor.cpp:567: error: (Each undeclared identifier is reported only once
> for each function it appears in.)
> CEditor.cpp:569: error: `iSpace' undeclared (first use this function)
> CEditor.cpp:569: error: `tabSpace' undeclared (first use this function)
> CEditor.cpp:571: error: `bEvery' undeclared (first use this function)
> CEditor.cpp:573: error: `bEveryWithOutDim' undeclared (first use this
> function)
> CEditor.cpp:575: error: `bAlignComments' undeclared (first use this
> function) CEditor.cpp:577: error: `bWithInCase' undeclared (first use this
> function) CEditor.cpp:581: error: `bDelEmptyLines' undeclared (first use
> this function) make: *** [CEditor.lo] Error 1
>
> Where I'm wrong, I can't find
>
> Amicalement
> Charlie
>

You should read the How To Write Components in the wiki first, to know how to 
use the macros, and to understand what you are doing.

The arguments passed to implementation methods are actually the arguments 
pushed on the interpreter stack, so you must use macros to access them. Look 
in the wiki the following macros: ARG(), VARG(), VARGOPT() and MISSING(). And 
look the implementation of methods having the same syntax than yours in the 
gambas source code.

Regards,

-- 
Benoit Minisini
mailto:gambas at ...1...




More information about the Devel mailing list