[lua] added %luacode feature, documentation & examples
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10312 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
39ad0f01f6
commit
e543cd9040
12 changed files with 279 additions and 25 deletions
25
Examples/lua/arrays/example.c
Normal file
25
Examples/lua/arrays/example.c
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/* File : example.c */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/* we are using the qsort function, which needs a helper function to sort */
|
||||
int compare_int(const void * a, const void * b)
|
||||
{
|
||||
return ( *(int*)a - *(int*)b );
|
||||
}
|
||||
|
||||
void sort_int(int* arr, int len)
|
||||
{
|
||||
qsort(arr, len, sizeof(int), compare_int);
|
||||
}
|
||||
|
||||
// ditto doubles
|
||||
int compare_double(const void * a, const void * b)
|
||||
{
|
||||
return ( *(double*)a - *(double*)b );
|
||||
}
|
||||
|
||||
void sort_double(double* arr, int len)
|
||||
{
|
||||
qsort(arr, len, sizeof(double), compare_double);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue