phalcon/zephir — pull request #21 by racklin (2013-10-11 17:34:30+00:00)
Title: Added new syntax named 'CBLOCK' . The content in `%{ }%` will copied into the generated .c file

Hi.

I have implement a new syntax named 'CBLOCK'.
The idea is inspired by Mozilla's XPIDL C++ Block . http://www-archive.mozilla.org/scriptable/xpidl/idl-authors-guide/keywords.html

Syntax is
```
%{
// This text is in CBLOCK.
}%
```

The CBLOCK copied text into generated .c file.
It is useful and help us to call C functions more easier, and have ability to using 3rd libs in zephir.

The CBLOCK before `namespace` `class` will copied CONTENT to generated .c file and after headers .

The CBLOCK inside method statement, will copied CONTENT to generated .c file `inline` (AT IT's Position)

Here is unit-test for example:
```
**
* CBLOCK tests
/* asfas
*/

%{
// top statement before namespace, add to after headers
#define MAX_FACTOR 40
}%

namespace Test;

%{
// top statement before class, add to after headers
// test include .h
#include "kernel/require.h"
}%

%{

// c implement fibonacci
static long fibonacci(long n) {
if (n < 2) return n;
else return fibonacci(n-2)+fibonacci(n-1);
}

}%

class Cblock
{
public function testCblock1()
{
int a = 0;
%{
a = MAX_FACTOR;
}%

return a;
}

public function testCblock2()
{
long a = 0;

%{
a = fibonacci(MAX_FACTOR);
}%

return a;
}
```

AND Generated .c file below:
```
#ifdef HAVE_CONFIG_H
#include "../ext_config.h"
#endif

#include
#include "../php_ext.h"
#include "../ext.h"

#include
#include
#include

#include "kernel/main.h"

// top statement before namespace, add to after headers
#define MAX_FACTOR 40

// top statement before class, add to after headers
// test include .h
#include "kernel/require.h"

// c implement fibonacci
static long fibonacci(long n) {
if (n < 2) return n;
else return fibonacci(n-2)+fibonacci(n-1);
}

/**
* CBLOCK tests
/* asfas
*/
ZEPHIR_INIT_CLASS(Test_Cblock) {

ZEPHIR_REGISTER_CLASS(Test, Cblock, test, cblock, test_cblock_method_entry, 0);

return SUCCESS;

}

PHP_METHOD(Test_Cblock, testCblock1) {

int a = 0;

a = MAX_FACTOR;

RETURN_LONG(a);

}

PHP_METHOD(Test_Cblock, testCblock2) {

long a = 0;

a = fibonacci(MAX_FACTOR);

RETURN_LONG(a);

}
```