- 5.2 Wrapping Simple C Declarations
- 5.3 Pointers and complex objects
- 5.3.1 Simple pointers
- 5.3.2 Run time pointer type checking
- 5.3.3 Derived types, structs, and classes
- 5.3.5 Typedef
- 5.4.1 Passing structures by value
- 5.4.2 Return by value
- 5.4.3 Linking to global structure variables
- 5.4.4 Linking to char*
- 5.4.4 Linking to const char*
- 5.4.5 Arrays
- 5.4.8 Default/optional arguments
- 5.4.9 Pointers to functions and callbacks
- 5.5 Structures and unions
- 5.6 Code Insertion
- 5.7 Interface Building Strategy
5.2 Wrapping Simple C Declarations
For example, consider the following interface file:
%module example
%inline %{
extern double sin(double x);
extern int strcmp(const char *, const char *);
extern int Foo;
%}
#define STATUS 50
#define VERSION "1.1"
When SWIG creates an extension module, these declarations are accessible as scripting language functions, variables, and constants respectively. For example, in python:
>>> example.sin(3)
5.2335956
>>> example.strcmp('Dave', 'Mike')
-1
>>> print example.cvar.Foo
42
>>> print example.STATUS
50
>>> print example.VERSION
1.1
Whenever possible, SWIG creates an interface that closely matches the underlying C/C++ code. However, due to subtle differences between languages, run-time environments, and semantics, it is not always possible to do so.
5.2.1 Basic Type Handling
In order to build an interface, SWIG has to convert C/C++ datatypes to equivalent types in the target language:
<IP_ADDRESS> Integral
When an integral value is converted from C, a cast is used to convert it to the representation in the target language. Thus, a 16 bit short in C may be promoted to a 32 bit integer. When integers are converted in the other direction, the value is cast back into the original C type. If the value is too large to fit, it is silently truncated.
bool data type is cast to and from an integer value of 0 and 1 unless the target language provides a special boolean type.
unsigned/signed char are special cases that are handled as small 8-bit integers. Normally, the char datatype is mapped as a one-character ASCII string.
As a rule of thumb, the int datatype and all variations of char and short datatypes are safe to use. For unsigned int and long data types, you will need to carefully check the correct operation of your program after it has been wrapped with SWIG.
<IP_ADDRESS> Float
SWIG recognizes the following floating point types : float and double. Floating point numbers are mapped to and from the natural representation of floats in the target language. This is almost always a C double.
<IP_ADDRESS> Unicode:
For those scripting languages that provide Unicode support, Unicode strings are often available in an 8-bit representation such as UTF-8 that can be mapped to the char * type (in which case the SWIG interface will probably work).
5.2.2 Global Variables
Whenever possible, SWIG maps C/C++ global variables into scripting language variables.
Whenever the scripting language variable is used, the underlying C global variable is accessed。 However, the way to access global variables in different script langs are different.
Finally, if a global variable has been declared as const, it only supports read-only access.
For example:
%module example
double foo;
results in a scripting language variable like this:
# Tcl
set foo [3.5] ;# Set foo to 3.5
puts $foo ;# Print the value of foo
# Python
cvar.foo = 3.5 # Set foo to 3.5
print cvar.foo # Print value of foo
# Perl
$foo = 3.5; # Set foo to 3.5
print $foo, "\n"; # Print value of foo
# Ruby
Module.foo = 3.5 # Set foo to 3.5
print Module.foo, "\n" # Print value of foo
5.2.3 Constants
Constants can be created using #define, enumerations, or a special %constant directive. The following interface file shows a few valid constant declarations :
#define I_CONST 5 // An integer constant
#define PI 3.14159 // A Floating point constant
#define S_CONST "hello world" // A string constant
#define NEWLINE '\n' // Character constant
enum boolean {NO=0, YES=1};
enum months {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG,
SEP, OCT, NOV, DEC};
%constant double BLAH = 42.37;
#define PI_4 PI/4
#define FLAGS 0x04 | 0x08 | 0x40
<IP_ADDRESS> Special cases
1.SWIG will not create constants for macros unless the value can be completely determined by the preprocessor.
#define EXTERN extern
EXTERN void foo();
what would the value of a constant called EXTERN would be?
2.for the same conservative reasons even a constant with a simple cast will be ignored, such as
#define F_CONST (double) 5 // A floating point constant with cast
3.For enumerations, it is critical that the original enum definition be included somewhere in the interface file (either in a header file or in the %{ %} block) because it needs the original enumeration declaration in order to get the correct enum values as assigned by the C compiler.
<IP_ADDRESS> A brief word about const
Typically, %constant is only used when you want to add constants to the scripting language interface that are not defined in the original header file.
If the right-most const occurs after all other type modifiers (such as pointers), then the variable is const. Otherwise, it is not. Here are some examples of const declarations:
const char a; // A constant character
char const b; // A constant character (the same)
char *const c; // A constant pointer to a character
const char *const d; // A constant pointer to a constant character
Here is an example of a declaration that is not const:
const char *e;
In this case, the pointer e can change — it’s only the value being pointed to that is read-only.
5.2.5 A cautionary tale of char *
When strings are passed from a scripting language to a C char *, the pointer usually points to string data stored inside the interpreter.
char *strcat(char *s, const char *t)
your application will perhaps crashes with a segmentation fault or other memory related problem. This is because s refers to some internal data in the target language—data that you should mot be touching.
5.3 Pointers and complex objects
5.3.1 Simple pointers
Pointers to primitive C data types such as:
int* p_int;
double*** ppp_double;
char** pp_char;
Int* null_ptr=NULL;
are fully supported by SWIG.
Rather than trying to convert the data being pointed to into a scripting representation, SWIG simply encodes the pointer itself into a representation that contains the actual value of the pointer and a type-tag.
Thus, the SWIG representation of the above pointers (in Tcl), might look like this:
_10081012_p_int
_1008e124_ppp_double
_f8ac_pp_char
_NULL_p_int
All pointers are treated as opaque objects by SWIG. Thus, a pointer may be returned by a function and passed around to other C functions as needed. (? here is something I feel unclear and need go over in the future.)
The scripting language representation of a pointer value should never be manipulated directly.
eg. the numbers used may differ from the actual machine address (e.g., on little-endian machines,
the digits may appear in reverse order)
5.3.2 Run time pointer type checking
Although this has the potential to cause a crash, NULL pointers are also
sometimes used as sentinel values or to denote a missing/empty value.
Therefore, SWIG leaves NULL pointer checking up to the application.
(? here is something I feel unclear when I wrote this blog and need go
over in the future.)
5.3.3 Derived types, structs, and classes
For everything else (structs, classes, arrays, etc…) SWIG applies a very simple rule :
Everything else is a pointer
Suppose you have an interface file like this :
%module fileio
FILE *fopen(char *, char *);
int fclose(FILE *);
unsigned fread(void *ptr, unsigned size, unsigned nobj, FILE *);
unsigned fwrite(void *ptr, unsigned size, unsigned nobj, FILE *);
void *malloc(int nbytes);
void free(void *);
In this file, SWIG doesn’t know what a FILE is, but since it’s used as a pointer, so it doesn’t really matter what it is. If you wrapped this module into Python, you can use the functions just like you expect :
# Copy a file
def filecopy(source, target):
f1 = fopen(source, "r")
f2 = fopen(target, "w")
buffer = malloc(8192)
nbytes = fread(buffer, 8192, 1, f1)
while (nbytes > 0):
fwrite(buffer, 8192, 1, f2)
nbytes = fread(buffer, 8192, 1, f1)
free(buffer)
In this case f1, f2, and buffer are all opaque objects containing C pointers. It doesn’t matter what value they contain–our program works just fine without this knowledge.
When SWIG encounters an undeclared data type, it automatically assumes that it is a structure or class.
5.3.5 Typedef
Like C, typedef can be used to define new type names in SWIG. For example:
typedef unsigned int size_t;
typedef definitions appearing in a SWIG interface are not propagated to the generated wrapper code.
Therefore, they either need to be defined in an included header file or placed in the declarations section like this:
%{
/* Include in the generated wrapper file */
typedef unsigned int size_t;
%}
/* Tell SWIG about it */
typedef unsigned int size_t;
or
%inline %{ typedef unsigned int size_t; %}
SWIG tracks typedef declarations and uses this information for run-time type checking.
For instance, if you use the above typedef and had the following function declaration:
void foo(unsigned int *ptr);
The corresponding wrapper function will accept arguments of type unsigned int * or size_t *.
5.4.1 Passing structures by value
For example, consider the following function:
double dot_product(Vector a, Vector b);
To deal with this, SWIG transforms the function to use pointers by creating a wrapper equivalent to the following:
double wrap_dot_product(Vector *a, Vector *b)
{
Vector x = *a;
Vector y = *b;
return dot_product(x, y);
}
In the target language, the dot_product() function now accepts pointers to Vectors instead of Vectors. For the most part, this transformation is transparent so you might not notice.
5.4.2 Return by value
For example, consider the following function:
Vector cross_product(Vector v1, Vector v2);
This function wants to return Vector, but SWIG only really supports pointers. As a result, SWIG creates a wrapper like this:
Vector *wrap_cross_product(Vector *v1, Vector *v2)
{
Vector x = *v1;
Vector y = *v2;
Vector *result;
result = (Vector *) malloc(sizeof(Vector));
*(result) = cross(x, y);
return result;
}
Or if SWIG was run with the -c++ option:
Vector *wrap_cross(Vector *v1, Vector *v2)
{
Vector x = *v1;
Vector y = *v2;
Vector *result = new Vector(cross(x, y)); // Uses default copy constructor
return result;
}
In both cases, SWIG allocates a new object and returns a reference to it. It is up to the user to delete the returned object when it is no longer in use.
Clearly, this will leak memory if you are unaware of the implicit memory allocation and don’t take steps to free the result.
It should also be noted that the handling of pass/return by value in C++ has some special cases.
For example, the above code fragments don’t work correctly if Vector doesn’t define a default constructor. The section on SWIG and C++ has more information about this case.
5.4.3 Linking to global structure variables
For example, a global variable like this:
Vector unit_i;
gets mapped to an underlying pair of set/get functions like this :
Vector *unit_i_get()
{
return &unit_i;
}
void unit_i_set(Vector *value)
{
unit_i = *value;
}
A global variable created in this manner will show up as a pointer in the target scripting language. It would be an extremely bad idea to free or destroy such a pointer.
Also, C++ classes must supply a properly defined copy constructor in order for assignment to work correctly.
5.4.4 Linking to char*
When a global variable of type char * appears, SWIG uses malloc() or new to allocate memory for the new value.
Specifically, if you have a variable like this
char *foo;
SWIG generates the following code:
/* C mode */
void foo_set(char *value)
{
if (foo) free(foo);
foo = (char *) malloc(strlen(value)+1);
strcpy(foo, value);
}
/* C++ mode. When -c++ option is used */
void foo_set(char *value)
{
if (foo) delete [] foo;
foo = new char[strlen(value)+1];
strcpy(foo, value);
}
If this is not the behavior that you want, consider making the variable read-only using the %immutable directive.
Alternatively, you might write a short assist-function to set the value exactly like you want. For example:
%inline %{
void set_foo(char *value)
{
strncpy(foo, value, 50);
}
%}
Note: If you write an assist function like this, you will have to call it as a function from the target scripting language (it does not work like a variable). For example, in Python you will have to write:
>>> set_foo("Hello World")
A common mistake with char * variables is to link to a variable declared like this:
char *VERSION = "1.0";
In this case, the variable will be readable, but any attempt to change the value results in a segmentation or general protection fault.
This is due to the fact that SWIG is trying to release the old value using free or delete when the string literal value currently assigned to the variable wasn’t allocated using malloc() or new.
To fix this behavior, you can either:
- mark the variable as read-only,
- write a typemap (as described in Chapter 6),
- write a special set function as shown.
- declare the variable as an array:
char VERSION[32] = "1.0";
5.4.4 Linking to const char*
SWIG still generates functions for setting and getting the value. However, the default behavior does not release the previous contents (resulting in a possible memory leak).
In fact, you may get a warning message such as this when wrapping such a variable:
example.i:20. Typemap warning. Setting const char * variable may leak memory
The reason for this behavior is that const char * variables are often used to point to string literals. For example:
const char *foo = "Hello World\n";
On the other hand, it is legal to change the pointer to point to some other value.
When setting a variable of this type, SWIG allocates a new string (using malloc or new) and changes the pointer to point to the new value.
However, the following repeated modifications of the value will result in a memory leak since the old value is not released by default.
Anyway, try to use const char* or char* as read-only.
5.4.5 Arrays
Arrays are fully supported by SWIG, but they are always handled as pointers instead of mapping them to a special array object or list in the target language.
Thus, the following declarations :
int foobar(int a[40]);
void grok(char *argv[]);
void transpose(double a[20][20]);
are processed as if they were really declared like this:
int foobar(int *a);
void grok(char **argv);
void transpose(double (*a)[20]);
Like C, SWIG does not perform array bounds checking. It is up to the user to make sure the pointer points to a suitably allocated region of memory.
Multi-dimensional arrays are transformed into a pointer to an array of one less dimension. For example:
int [10]; // Maps to int *
int [10][20]; // Maps to int (*)[20]
int [10][20][30]; // Maps to int (*)[20][30]
Array variables are supported, but are read-only by default. For example:
int a[100][200];
In this case, reading the variable ‘a’ returns a pointer of type int (*)[200]
that points to the first element of the array &a[0][0]
.
Trying to modify ‘a’ results in an error. This is because SWIG does not know how to copy data from the target language into the array.
To work around this limitation, you may want to write a few simple assist functions like this: For example:
%inline %{
void a_set(int i, int j, int val)
{
a[i][j] = val;
}
int a_get(int i, int j)
{
return a[i][j];
}
%}
In the target language, the value cannot be set/get like a normal variable but set/get it like this:
a_set(0,0,1) # set a[0][0] to 1
val = a_get(0,0) # get a[0][0]
To dynamically create arrays of various sizes and shapes, it may be useful to write some helper functions in your interface. For example:
// Some array helpers
%inline %{
/* Create any sort of [size] array */
int *int_array(int size)
{
return (int *) malloc(size*sizeof(int));
}
/* Create a two-dimension array [size][10] */
int (*int_array_10(int size))[10]
{
return (int (*)[10]) malloc(size*10*sizeof(int));
}
%}
Arrays of char are handled as a special case by SWIG. In this case, strings in the target language can be stored in the array.
For example, if you have a declaration like this,
char pathname[256];
SWIG generates functions for both getting and setting the value that are equivalent to the following code:
char *pathname_get()
{
return pathname;
}
void pathname_set(char *value)
{
strncpy(pathname, value, 256);
}
The difference is that in the target language, the value can be set/get like a normal variable.
pathname = 'python' # set
print pathname # get
5.4.8 Default/optional arguments
For example:
int plot(double x, double y, int color=WHITE);
SWIG generates wrapper code where the default arguments are optional in the target language:
plot -3.4 7.5 # Use default value
plot -3.4 7.5 10 # set color to 10 instead
5.4.9 Pointers to functions and callbacks
SWIG provides full support for function pointers provided that the callback functions are defined in C and not in the target language.
For example, consider a function like this:
int binary_op(int a, int b, int (*op)(int, int));
When you first wrap something like this into an extension module, you may find the function to be impossible to use. For instance, in Python:
>>> def add(x, y):
... return x+y
...
>>> binary_op(3, 4, add)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: Type error. Expected _p_f_int_int__int
>>>
The reason for this error is that SWIG doesn’t know how to map a scripting language function into a C callback.
However, existing C functions can be used as arguments provided you install them as constants. One way to do this is to use the %constant directive like this:
/* Function with a callback */
int binary_op(int a, int b, int (*op)(int, int));
/* Some callback functions */
%constant int add(int, int);
%constant int sub(int, int);
%constant int mul(int, int);
In this case, add, sub, and mul become function pointer constants in the target scripting language. This allows you to use them as follows:
>>> binary_op(3, 4, add)
7
>>> binary_op(3, 4, mul)
12
>>>
Unfortunately, by declaring the callback functions as constants, they are no longer accessible as functions. For example:
>>> add(3, 4)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: object is not callable: '_ff020efc_p_f_int_int__int'
>>>
If you want to make a function available as both a callback function and a function, you can use the %callback and %nocallback directives like this:
/* Function with a callback */
int binary_op(int a, int b, int (*op)(int, int));
/* Some callback functions */
%callback("%s_cb");
int add(int, int);
int sub(int, int);
int mul(int, int);
%nocallback;
%s
gets replaced by the function name. The callback mode remains in
effect until it is explicitly disabled using %nocallback
. When you do this,
the interface now works as follows:
>>> binary_op(3, 4, add_cb)
7
>>> binary_op(3, 4, mul_cb)
12
>>> add(3, 4)
7
>>> mul(3, 4)
12
Notice that when the function is used as a callback, special names
such as add_cb
are used instead. To call the function normally,
just use the original function name such as add()
.
Although SWIG does not normally allow callback functions to be written in the target language, this can be accomplished with the use of type maps and other advanced SWIG features.
See the Typemaps chapter for more about typemaps and individual target language chapters for more on callbacks and the ‘director’ feature.
5.5 Structures and unions
If SWIG encounters the definition of a C structure or union, it creates a set of accessor functions. For example:
struct Vector
{
double x, y, z;
}
gets transformed into the following set of accessor functions :
double Vector_x_get(struct Vector *obj)
{
return obj->x;
}
double Vector_y_get(struct Vector *obj)
{
return obj->y;
}
double Vector_z_get(struct Vector *obj)
{
return obj->z;
}
void Vector_x_set(struct Vector *obj, double value)
{
obj->x = value;
}
void Vector_y_set(struct Vector *obj, double value)
{
obj->y = value;
}
void Vector_z_set(struct Vector *obj, double value)
{
obj->z = value;
}
In addition, SWIG creates default constructor and destructor functions if none are defined in the interface. For example:
struct Vector *new_Vector()
{
return (Vector *) calloc(1, sizeof(struct Vector));
}
void delete_Vector(struct Vector *obj)
{
free(obj);
}
Using these low-level accessor functions, an object can be minimally manipulated from the target language using code like this:
v = new_Vector()
Vector_x_set(v, 2)
Vector_y_set(v, 10)
Vector_z_set(v, -5)
delete_Vector(v)
However, most of SWIG’s language modules also provide a high-level interface that is more convenient. Keep reading.
5.5.2 Char* strings members
Structures involving character strings require some care.
SWIG assumes that all members of type char * have been dynamically allocated using malloc() and that they are NULL-terminated ASCII strings. For example :
%module mymodule
...
struct Foo {
char *name;
...
}
This results in the following accessor functions :
// Note: If the -c++ option is used, new and delete are used to perform memory allocation.
char *Foo_name_get(Foo *obj)
{
return Foo->name;
}
char *Foo_name_set(Foo *obj, char *c)
{
if (obj->name)
free(obj->name);
obj->name = (char *) malloc(strlen(c)+1);
strcpy(obj->name, c);
return obj->name;
}
If this behavior differs from what you need in your applications, the SWIG “memberin” typemap can be used to change it. See the typemaps chapter for further details.
5.5.3 Array members
Arrays may appear as the members of structures, but they will be read-only by default. SWIG may generate a warning message:
interface.i:116. Warning. Array member will be read-only
To eliminate the warning message, typemaps can be used, but this is discussed in a later chapter. In many cases, the warning message is harmless.
5.5.4 Structure data members Occasionally, a structure will contain data members that are themselves structures. For example:
typedef struct Foo
{
int x;
} Foo;
typedef struct Bar
{
int y;
Foo f; /* Structure data member */
} Bar;
When a structure member is wrapped, it is handled as a pointer, unless the %naturalvar directive is used where it is handled more like a C++ reference (see C++ Member data).
The accessors to the member variable as a pointer are effectively wrapped as follows:
Foo *Bar_f_get(Bar *b)
{
return &b->f;
}
void Bar_f_set(Bar *b, Foo *value)
{
b->f = *value;
}
The reasons for this are have to do with the problem of modifying and accessing data inside the data member. For example, suppose you wanted to modify f.x in C like this:
Bar *b;
b->f.x = 37;
Translating them to function calls in C (as would be used inside the scripting language interface) results in the following code:
Bar *b;
Foo_x_set(Bar_f_get(b), 37);
In this code, if the Bar_f_get() function were to return a Foo instead of a Foo*, then the resulting modification would be applied to a copy of f and not the data member f itself. Clearly that’s not what you want!
It should be noted that this transformation to pointers only occurs if SWIG knows that a data member is a structure or class. For instance, if you had a structure like this,
struct Foo
{
WORD w;
};
and nothing was known about WORD, then SWIG will generate more normal accessor functions like this:
WORD Foo_w_get(Foo *f)
{
return f->w;
}
void Foo_w_set(FOO *f, WORD value)
{
f->w = value;
}
Compatibility Note: if you need to tell SWIG that an undeclared datatype is really a struct, simply use a forward struct declaration such as “struct Foo;”.
5.5.5 C constructors and destructors
When wrapping structures, it is generally useful to have a mechanism for creating and destroying objects
As there may be memory allocations happening when constructing structures that should be released when destruction.
SWIG will by default automatically generate functions for creating and destroying objects using malloc() and free() when SWIG is used on C code, with C++ being handled differently.
If you don’t want SWIG to generate default constructors for your interfaces,
you can use the %nodefaultctor
directive or the -nodefaultctor
command line option. For example:
swig -nodefaultctor example.i
or
%module foo
...
%nodefaultctor; // Don't create default constructors
... declarations ...
%clearnodefaultctor; // Re-enable default constructors
If you need more precise control, %nodefaultctor
can selectively target
individual structure definitions. For example:
%nodefaultctor Foo; // No default constructor for Foo
...
struct Foo
{
// No default constructor generated.
};
struct Bar
{
// Default constructor generated.
};
Since ignoring the implicit or default destructors most of the time produces memory leaks, SWIG will always try to generate them.
If needed, however, you can selectively disable the generation of the
default/implicit destructor by using %nodefaultdtor
:
%nodefaultdtor Foo; // No default/implicit destructor for Foo
...
struct Foo
{
// No default destructor is generated.
};
struct Bar
{
// Default destructor generated.
};
Note: There are also the -nodefault
option and %nodefault
directive,
which disable both the default or implicit destructor generation.
This could lead to memory leaks across the target languages,
and it is highly recommended you don’t use them.
5.5.6 Adding member functions to C structures
SWIG provides a special %extend directive that makes it possible to attach methods to C structures for purposes of building an object oriented interface. Suppose you have a C header file with the following declaration :
/* file : vector.h */
...
typedef struct Vector
{
double x, y, z;
} Vector;
You can make a Vector look a lot like a class by writing a SWIG interface like this:
// file : vector.i
%module mymodule
%{
#include "vector.h"
%}
%include "vector.h" // Just grab original C header file
%extend Vector
{
// Attach these functions to struct Vector.
// The newly constructed object must be returned as if the constructor
// declaration had a return value, a Vector * in this case.
Vector(double x, double y, double z)
{
Vector *v;
v = (Vector *) malloc(sizeof(Vector));
v->x = x;
v->y = y;
v->z = z;
return v;
}
~Vector()
{
free($self);
}
double magnitude()
{
return sqrt($self->x*$self->x+$self->y*$self->y+$self->z*$self->z);
}
void print()
{
printf("Vector [%g, %g, %g]\n", $self->x, $self->y, $self->z);
}
};
Note the usage of the $self
special variable. Its usage is identical to a
C++ ‘this’ pointer and should be used whenever access to the struct
instance is required.
Now, when used with proxy classes in Python, you can do things like this :
v = Vector(3, 4, 0) # Create a new vector
print v.magnitude() # Print magnitude
# 5.0
v.print() # Print it out
# [ 3, 4, 0 ]
del v # Destroy it
The %extend directive can also be used inside the definition of the Vector structure. For example:
// file : vector.i
%module mymodule
%{
#include "vector.h"
%}
typedef struct Vector {
double x, y, z;
%extend {
Vector(double x, double y, double z) { ... }
~Vector() { ... }
...
}
} Vector;
Note that %extend can be used to access externally written functions provided they follow the naming convention used in this example :
/* File : vector.c */
/* Vector methods */
#include "vector.h"
Vector *new_Vector(double x, double y, double z) {
Vector *v;
v = (Vector *) malloc(sizeof(Vector));
v->x = x;
v->y = y;
v->z = z;
return v;
}
void delete_Vector(Vector *v) {
free(v);
}
double Vector_magnitude(Vector *v) {
return sqrt(v->x*v->x+v->y*v->y+v->z*v->z);
}
// File : vector.i
// Interface file
%module mymodule
%{
#include "vector.h"
%}
typedef struct Vector {
double x, y, z;
%extend {
Vector(int, int, int); // This calls new_Vector()
~Vector(); // This calls delete_Vector()
double magnitude(); // This will call Vector_magnitude()
...
}
} Vector;
The name used for %extend should be the name of the struct and not the name of any typedef to the struct. For example:
typedef struct Integer {
int value;
} Int;
%extend Integer { ... } /* Correct name */
%extend Int { ... } /* Incorrect name */
struct Float {
float value;
};
typedef struct Float FloatValue;
%extend Float { ... } /* Correct name */
%extend FloatValue { ... } /* Incorrect name */
There is one exception to this rule and that is when the struct is anonymously named such as:
typedef struct {
double value;
} Double;
%extend Double { ... } /* Okay */
A little known feature of the %extend
directive is that it can also be used
to add synthesized attributes or to modify the behavior of existing data
attributes.
For example, suppose you wanted to make magnitude a read-only attribute of Vector instead of a method. To do this, you might write some code like this:
// Add a new attribute to Vector
%extend Vector {
const double magnitude;
}
// Now supply the implementation of the Vector_magnitude_get function
%{
const double Vector_magnitude_get(Vector *v) {
return (const double) sqrt(v->x*v->x+v->y*v->y+v->z*v->z);
}
%}
Now, for all practical purposes, magnitude will appear like an attribute of the object.
A similar technique can also be used to work with data members that you want to process. For example, consider this interface:
typedef struct Person {
char name[50];
...
} Person;
Say you wanted to ensure name was always upper case, you can rewrite the interface as follows to ensure this occurs whenever a name is read or written to:
typedef struct Person {
%extend {
char name[50];
}
...
} Person;
%{
#include <string.h>
#include <ctype.h>
void make_upper(char *name) {
char *c;
for (c = name; *c; ++c)
*c = (char)toupper((int)*c);
}
/* Specific implementation of set/get functions forcing capitalization */
char *Person_name_get(Person *p) {
make_upper(p->name);
return p->name;
}
void Person_name_set(Person *p, char *val) {
strncpy(p->name, val, 50);
make_upper(p->name);
}
%}
Note: it should be stressed that even though %extend
can be used to
add new data members, these new members can not require the allocation
of additional storage in the object (e.g., their values must be entirely
synthesized from existing attributes of the structure or obtained elsewhere).
5.5.7 Nested structures
Occasionally, a C program will involve structures like this :
typedef struct Object {
int objtype;
union {
int ivalue;
double dvalue;
char *strvalue;
void *ptrvalue;
} intRep;
} Object;
When SWIG encounters this, it performs a structure splitting operation that transforms the declaration into the equivalent of the following:
typedef union {
int ivalue;
double dvalue;
char *strvalue;
void *ptrvalue;
} Object_intRep;
typedef struct Object {
int objType;
Object_intRep intRep;
} Object;
SWIG will then create an Object_intRep structure for use inside the interface file. Accessor functions will be created for both structures. In this case, functions like this would be created :
Object_intRep *Object_intRep_get(Object *o)
{
return (Object_intRep *) &o->intRep;
}
int Object_intRep_ivalue_get(Object_intRep *o)
{
return o->ivalue;
}
int Object_intRep_ivalue_set(Object_intRep *o, int value)
{
return (o->ivalue = value);
}
double Object_intRep_dvalue_get(Object_intRep *o)
{
return o->dvalue;
}
... etc ...
Although this process is a little hairy, it works like you would expect in the target scripting language–especially when proxy classes are used. For instance, in Perl:
# Perl5 script for accessing nested member
$o = CreateObject(); # Create an object somehow
$o->{intRep}->{ivalue} = 7 # Change value of o.intRep.ivalue
Note: if you have a lot of nested structure declarations, it is advisable to double-check them after running SWIG. Nesting is handled differently in C++ mode, see Nested classes.
5.6 Code Insertion
Sometimes it is necessary to insert special code into the resulting wrapper file generated by SWIG. For example, you may want to include additional C code to perform initialization or other operations.
There are four common ways to insert code, but it’s useful to know how the output of SWIG is structured first.
5.6.1 The output of SWIG
When SWIG creates its output C/C++ file, it is broken up into five sections:
- Begin section
A placeholder for users to put code at the beginning of the C/C++ wrapper file. This is most often used to define preprocessor macros that are used in later sections. - Runtime code
This code is internal to SWIG and is used to include type-checking and other support functions that are used by the rest of the module. - Header section
This is user-defined support code that has been included by the %{ … %} directive. Usually this consists of header files and other helper functions. - Wrapper code
These are the wrappers generated automatically by SWIG. - Module initialization
The function generated by SWIG to initialize the module upon loading.
5.6.2 Code insertion blocks
The %insert directive enables inserting blocks of code into a given section of the generated code. It can be used in one of two ways:
%insert("section") "filename"
%insert("section") %{ ... %}
For example, %runtime is used instead of %insert(“runtime”). The valid sections and order of the sections in the generated C/C++ wrapper file is as shown:
%begin %{
... code in begin section ...
%}
%runtime %{
... code in runtime section ...
%}
%header %{
... code in header section ...
%}
%wrapper %{
... code in wrapper section ...
%}
%init %{
... code in init section ...
%}
Note: the bare %{ … %} directive is a shortcut that is the same as
%header %{ ... %}
.
A common use for code blocks is to write “helper” functions. These are functions that are used specifically for the purpose of building an interface, but which are generally not visible to the normal C program. For example:
%{
/* Create a new vector */
static Vector *new_Vector()
{
return (Vector *) malloc(sizeof(Vector));
}
%}
// Now tell SWIG to warp and expose it to script world
Vector *new_Vector();
5.6.3 Inlined header code blocks
Since the process of writing helper functions is fairly common, there is a special inlined form of code block that is used as follows :
%inline
%{
// Create a new vector and at the same time
// tell SWIG to warp and expose it to script world
Vector *new_Vector()
{
return (Vector *) malloc(sizeof(Vector));
}
%}
The %inline directive inserts all of the code that follows verbatim into the header portion of an interface file.
The code is then parsed by both the SWIG preprocessor and parser. Thus, the above example creates a new command new_Vector using only one declaration.
5.6.4 Initialization blocks
When code is included in the %init section, it is copied directly into the module initialization function. For example, if you needed to perform some extra initialization on module loading, you could write this:
%init %{init_variables();%}
5.7 Interface Building Strategy
This section describes the general approach for building interfaces with SWIG. The specifics related to a particular scripting language are found in later chapters.
5.7.1 Preparing a C program for SWIG
Here’s a series of steps you can follow to make an interface for a C program :
- Identify the functions that you want to wrap.
It’s probably not necessary to access every single function of a C program–thus, a little forethought can dramatically simplify the resulting scripting language interface. C header files are a particularly good source for finding things to wrap. - Create a new interface file to describe the scripting language interface to your program.
- Copy the appropriate declarations into the interface file or use SWIG’s %include directive to process an entire C source/header file.
- Make sure everything in the interface file uses ANSI C/C++ syntax.
- Most importantly, define a type before it is used!
Make sure all necessary typedef declarations and type-information is available in the interface file. if type information is not specified correctly, the wrappers can be sub-optimal and even result in uncompilable C/C++ code. - If your program has a main() function, you may need to rename it (read on).
- Run SWIG and compile.
Although this may sound complicated, the process turns out to be fairly easy once you get the hang of it.
Note: In the process of building an interface, SWIG may encounter syntax errors or other problems. The best way to deal with this is to simply copy the offending code into a separate interface file and edit it.
5.7.2 SWIG interface file
The preferred method of using SWIG is to generate a separate interface file. Suppose you have the following C header file :
/* File : header.h */
#include <stdio.h>
#include <math.h>
extern int foo(double);
extern double bar(int, int);
extern void dump(FILE *f);
A typical SWIG interface file for this header file would look like the following :
/* File : interface.i */
%module mymodule
%{
#include "header.h"
%}
extern int foo(double);
extern double bar(int, int);
extern void dump(FILE *f);
Of course, in this case, our header file is pretty simple so we could use a simpler approach and use an interface file like this:
/* File : interface.i */
%module mymodule
%{
#include "header.h"
%}
%include "header.h"
The main advantage of this approach is minimal maintenance of an interface file for when the header file changes in the future.
Note: in more complex projects, an interface file containing numerous %include and #include statements like this is one of the most common approaches to interface file design due to lower maintenance overhead.
5.7.3 Why use separate interface files?
Although SWIG can parse many header files, it is more common to write a special .i file defining the interface to a package. There are several reasons why you might want to do this:
- It is rarely necessary to access every single function in a large package. Many C functions might have little or no use in a scripted environment. Therefore, why wrap them?
- Separate interface files provide an opportunity to provide more precise rules about how an interface is to be constructed.
- Interface files can provide more structure and organization.
- SWIG can’t parse certain definitions that appear in header files. Having a separate file allows you to eliminate or work around these problems.
- Interface files provide a more precise definition of what the interface is. Users wanting to extend the system can go to the interface file and immediately see what is available without having to dig it out of header files.
5.7.4 Getting the right header files
Note: Sometimes, it is necessary to use certain header files in order for the code generated by SWIG to compile properly. Make sure you include certain header files by using a %{ %} block like this:
%module graphics
%{
#include <GL/gl.h>
#include <GL/glu.h>
%}
// Put the rest of the declarations here
...
5.7.5 What to do with main()
If your program defines a main() function, you may need to get rid of it or rename it in order to use a scripting language. As most scripting languages define their own main() procedure that is called instead.
main() also makes no sense when working with dynamic loading. There are a few approaches to solving the main() conflict :
- Get rid of main() entirely.
- Rename main() to something else. You can do this by compiling your C program with an option like -Dmain=oldmain.
- Use conditional compilation to only include main() when not using a scripting language.
Note: getting rid of main() may cause potential initialization problems of a program. To handle this problem, you may consider writing a special function called program_init() that initializes your program upon startup.
This function could then be called either from the scripting language as the first operation, or when the SWIG generated module is loaded. In many cases, the old main() program can be completely replaced by a Perl, Python, or Tcl script.


Filtering lets users to choose a smaller part of your data set which belongs to a specified criteria. This smaller data set may use for viewing or analysis purposes. In such cases, you might want to turn filterable on.
Data table allows users to filter data via dropdown or text box. The Filterable controls will be displayed on the header level of the grid.
To enable filterable, simply set filterable
to true and by default filterable is false.
{{demoSnippet.filterable}}
This property is designed to configure & filter data in the table column level. In default the table doesn't filter it’s contents. There are various additional properties are available out of the box to enhance the filtering capability. Those properties will be discuss on following sections.
The following content shows the available configurations when using column search filter text box. When users turns on filterable, text box filtering will be enabled as default filtering mechanism.
There are few more properties which effect the behaviour of filterable controls and those also applicable in column level of table configuration after enabling the filterable text box.
filterPlaceholder: string
The page property lets you to specify placeholder name for search text box. In the above example, ID & Order Method Type columns don't have placeholder name configured.
showFilterClearButton: boolean
The page property lets you to show/hide text box search filter clear button. Refer above example to see how this works.
This will allows users to configure drop down filter instead of text box search filter for the columns as they want.
To enable this simply set true to showDropdownFilter
property.
There are few more properties which effect the behaviour of filter dropdown and those also applicable in column level of table configuration after enabling the filter dropdown.
dropdownFilterMenuPosition: string = 'bottom-right' | 'bottom-left' | 'top-left' | 'top-right'
Enables users to configure the dropdown filter position. Note that, there are 4 positions users can configure to align the dropdown. According to the following example,
dropDownFilterShowOptionSelectCheckbox: boolean
Enabled users to controls the visibility of dropdown filter's option selection check boxes.
dropdownFilterCloseMenuOnSelect: boolean
Enable/disable dropdown filter close after an option is selected.
dropdownFilterShowSelectAll: boolean
Show/hide dropdown filter all option selection check box.
dropdownFilterSelectMode: string = 'multi' | 'single' | 'single-toggle'
Enables users to configure the dropdown filter option selection type. There are 3 types of selection types available in ornamentum data table dropdown filter.
dropdownFilterWrapDisplaySelectLimit: number
Used to configure the number of options to be shown in the dropdown at a time.
dropdownFilterShowSelectedOptionRemoveButton: boolean
Used to show/hide the filtered option removal from the dropdown.
dropdownFilterGroupByField: string
Enable dropdown filter options grouping under a specified name. If the group name is not specified all the values are shown as a single group.
dropdownFilterMenuHeight: number
Used to specify the column dropdown filter menu height.
dropdownFilterMenuWidth: number
Used to specify the column dropdown filter menu width.
dropdownFilterMultiSelectOptionMaxWidth: number
Used to specify the multiple option selection dropdown option max width.
dropdownFilterSearchable: boolean
Used to show/hide dropdown filter search box.
dropdownFilterSearchDebounce: boolean
Used to enable/disable dropdown filter debounce.
dropdownFilterSearchDebounceTime: number
dropdownFilterShowClearSelectionButton: boolean
Used to show/hide drop down filter selection clear button.
filter: any
Used to provide a filter to see the values matched for specified criteria.


--- --- {% include header.html %}
This page describes how to install, use, and contribute to SDAP.
You can find out Wiki here. Feel free to add SDAP related content to it!
Get involved and contribute to SDAP through our Community Hubs. {% include footer.html %}


| Package | Description |
|---|---|
| org.apache.solr.client.solrj |
Primary APIs for communicating with a Solr Server from a Java client.
|
| org.apache.solr.client.solrj.request |
Convenience classes for dealing with various types of Solr requests.
|
| org.apache.solr.client.solrj.response |
Convenience classes for dealing with various types of Solr responses.
|
| org.apache.solr.client.solrj.response.schema |
Convenience classes for dealing with Schema API responses.
|
| Class and Description |
|---|
| QueryResponse |
| SolrPingResponse |
| UpdateResponse
TODO -- mostly a stub until we have a defined output format
|
| Class and Description |
|---|
| CollectionAdminResponse |
| ConfigSetAdminResponse
No special handling at this time.
|
| ConfigSetAdminResponse.List |
| CoreAdminResponse |
| DocumentAnalysisResponse
A response that is returned by processing the
DocumentAnalysisRequest . |
| FieldAnalysisResponse
A response that is returned by processing the
FieldAnalysisRequest . |
| LukeResponse
This is an incomplete representation of the data returned from Luke
|
| QueryResponse |
| SimpleSolrResponse |
| SolrPingResponse |
| UpdateResponse
TODO -- mostly a stub until we have a defined output format
|
| Class and Description |
|---|
| AnalysisResponseBase
A base class for all analysis responses.
|
| AnalysisResponseBase.AnalysisPhase
A phase in the analysis process.
|
| AnalysisResponseBase.TokenInfo
Holds all information of a token as part of an analysis phase.
|
| Cluster
This class represents a cluster of Solr Docs .
|
| ClusteringResponse
Encapsulates responses from ClusteringComponent
|
| ConfigSetAdminResponse
No special handling at this time.
|
| DocumentAnalysisResponse.DocumentAnalysis
An analysis process breakdown of a document.
|
| DocumentAnalysisResponse.FieldAnalysis
An analysis process breakdown for a specific field.
|
| FacetField
A utility class to hold the facet response.
|
| FacetField.Count |
| FieldAnalysisResponse.Analysis
The analysis of a field.
|
| FieldStatsInfo
Holds stats info
|
| Group
Represents a group.
|
| GroupCommand
This class represents the result of a group command.
|
| GroupResponse
Overall grouping result.
|
| IntervalFacet
Objects of this class will contain the result of all the intervals defined
for a specific field.
|
| IntervalFacet.Count
Holds counts for facet intervals defined in a field
|
| LukeResponse.FieldInfo |
| LukeResponse.FieldTypeInfo |
| PivotField |
| RangeFacet
Represents a range facet result
|
| RangeFacet.Count |
| SolrResponseBase |
| SpellCheckResponse
Encapsulates responses from SpellCheckComponent
|
| SpellCheckResponse.Collation |
| SpellCheckResponse.Correction |
| SpellCheckResponse.Suggestion |
| SuggesterResponse
Encapsulates responses from the Suggester Component
|
| Suggestion
This class models a Suggestion coming from Solr Suggest Component.
|
| TermsResponse
Encapsulates responses from TermsComponent
|
| TermsResponse.Term |
| Class and Description |
|---|
| SolrResponseBase |
Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.


Toggle Menu
Progress:
Product Launched (BETA) to Play Store
Developers: Ishita Verma, Rohit Nistala, Vishal Sanganaboina, Mariam Shaikh Advisors: Code For India, SafeCity India Year: 2013


this is a canvas. Your browser might not be able to play this game
Angle
Velocity
Angle
Velocity
Player 1
computer?
Player 2
computer?


In a real computer, what will happen if you make a recursive call without making the problem smaller?
" The run-time stack overflows, halting the program"
- "The operating system detects the infinite recursion because of the repeated state"
- "The program keeps running until you press Ctrl-C"
- "The results are nondeterministic"
Without making the problem smaller, the program will call itself infinite numbers of time until the stack is full.


This visualization presents selected results from the 2012 study, "Leaf morphology shift linked to climate change" by Greg R. Guerin, Haixia Wen, and Andrew J. Lowe. The study compared leaf widths, lengths, and surface areas on Dodonaea viscosa subsp. angustissima in the Adelaide Geosyncline region, South Australia. Among other results, the study found that leaf width corollated negatively with latitude; leaves farther north within the region were narrower than leaves farther south.


| More feedback from the subsidiaries |
| Tuesday, 12 noon The queries in response to your email are coming in non-stop. Now, the German subsidiary wants to know how to use IAS 19, as a first-time adopter. From the information in Erik's last email, decide what Clover Chemikalien should do. Click the one correct option, and then click Submit. | |||||||||||||
|
|


EXCLUSIVE: Quando Rondo: I Stole a Bike Trying to Get Away from the Police, Got Caught
by VladTVIn this clip, Quando Rondo recounted a few of the incidents that landed him in juvenile hall, specifically a shoplifting episode that got him his longest stint in juvie. He also opened up about the social isolation that he felt as a result of going to juvenile hall so much and missing out on the coming of age activities his friends were experiencing.


Kellie Hays
About
Portfolio
(current)
Contact
Portfolio
Wireframe
UV Site
Trivia Game
Word Guess Game
Crystal Counter
Rock Paper Scissors
© Copyright 2019 Kellie Hays


Egypt
Stronger Than Fate
Once upon a time, the queen of Egypt gave birth to a baby boy. The fairies gathered around the child to bless him, but one of the fairies shook her head. “I fear it is the prince’s fate to die by crocodile or serpent or dog,” the fairy said. “We can do nothing.” The king and queen were heartbroken and decided not to tempt fate. They built a castle atop a mountain and hired men to guard it day and night, and there the young prince lived, protected. One day the boy noticed a dog playing outside his window. At once he wished to have a dog, and since the king and queen never denied him a wish, they decided to grant this as well. They found him a puppy, and trained him to protect the prince. The prince and his puppy were great friends, but one day when he was 20, the prince told his father he longed to see the world. “I know about the prophecy,” he said, “but my dog will protect me.” Again, the king could not refuse. He sent the prince and his dog by ship to the other side of the Nile. There a beautiful horse awaited him, and with his dog by his side, the prince rode everywhere. He was delighted by all he saw. One day while visiting a foreign land, he fell in love with a princess, and she fell in love with him. “I wish to marry you,” the prince told her, “but my fate is to die at the hands of a crocodile, a serpent or a dog; you must not marry me.” But the princess loved him dearly. “We shall resist fate,” she said. “True love can conquer anything so long as we believe it can.” And so they married. A few years passed, and the prince learned his father was ill. He and his wife traveled to visit him in Egypt. One night, while they were fast asleep in the palace, the princess suddenly heard a sound that woke her. She stared into the darkness and spied a serpent coiled in the corner. She tried to recall all she had learned from the fairies. Quickly, she remembered that serpents couldn’t resist milk. So she slipped out of bed and filled a bowl with milk. When the creature saw the bowl, it began to lap it up so quickly that the princess was sure it would choke to death. When the serpent had finished the milk, it fell fast asleep, and the princess summoned the guards to capture it and send it far away. She had saved her husband from his deadly fate. Sadly, the king died the next day. The prince began his rule. One day, as he was out hunting with one of his dogs, he suddenly tripped over a log on the riverbank. To his astonishment, he heard a voice. This log was, in truth, a crocodile, and it said, “You cannot escape fate.  Terrified, the prince shared the news with his wife. “I’m doomed,” he said, but she was determined to save him. “There is nothing we cannot overcome,” she said, remembering a plant her fairy godmother had told her about. The four-leafed herb grew in the desert and could keep water in a pit for one whole year. The next day the princess set out to find it. She left in the middle of the night, guided by starlight.  “I will love you as I love the prince,” she promised the donkey as they traveled on, enduring heat and storms and thirst. At last they came to a mountain that cast a cool shadow. The plant grew at the very top of that mountain, but it was surrounded by a deep chasm. The princess, however, had carried along a rope. She made a noose with one end and tossed the other across the chasm with all her strength. It caught on a branch. Trusting this to hold her weight, she climbed across the chasm. A fierce wind assailed her, and still she climbed. Blinded by sand, she felt her way up the mountain to the very top. She climbed on until she felt plants beneath her feet, and taking one she counted leaves — one, two, three, four. Her heart pounding, she held fast to the plant and slid down the rock, leapt over the chasm and mounted her donkey. “Let’s go!” she cried. They rode across the desert. Back home, the princess saw her beloved standing near the river beside a pit of sand he had dug. Beside the pit was a pot of water, and only a short distance away stood the crocodile. Its mouth was watering. The princess ran to the hole. “Pour in the water,” she said, and as the prince did, she tossed in the plant. Sure enough, the water did not seep through the sand, but remained. The angry crocodile plunged back into the river and swam away. The prince stared at his wife with gratitude and love. With her strength and commitment, he had overcome the second of the three fates the fairies had predicted so long ago. Suddenly a wild duck flew past. The prince’s dog began to chase the duck, and he ran into his master’s legs. The prince and his dog both lost their balance and fell into the river, where mud and rushes caught them. It seemed they might drown, but there was the princess with the rope in her hand. She cast the rope to her beloved and pulled him and his dog ashore. Again, the prince stared into his wife’s eyes. “Your love is stronger than my fate,” he said. “This is true,” she said with a smile. And they lived happily ever after.
Source: Here


IDs vs Classes
Do you want to get specific or general?
March 8th, 2015
I’m just starting to explore this magical world of CSS. It’s impressive how much can be done by it and how lean and effective style got after CSS. Still, sometimes CSS can be confusing (at least for beginners, like me!). One good example of it refers to the use of IDs and Classes.
At first, Classes and IDs may seem disturbingly similar, if not the same thing. After all, by adding a class or an id to a tag, it is possible to define specific styles to the class/ id on your CSS stylesheet, and it will be automatically applied to that tag. So, if both accomplish to style your tag with the elements you wish, what’s the difference between them?
The difference is about specificity. Classes are designed to be used in several elements, as a set of style rules that you may want to apply in multiple tags. IDs, instead, are unique. They are designed to reference one single element, and shouldn’t be repeated in any other tags in your HTML. They can even be used together, in the same tag, if you wish to!.
Also, IDs have an special feature that you can’t find in Classes. By using IDs, you can set a scroll browser functionality, that is pretty cool. Imagine that you have a website http://mywebsite.com. If you have set up a tag with an ID, for example 'div id=“unique_id”', you can scroll to this element by using the URL http://mywebsite.com#unique_id. Isn’t it awesome?
In short, to guarantee you’ll never confuse it again, keep in mind: IDs are unique, Classes are general. Just memorize that, and you’ll hit it overtime!


Expenses
Amount
Category
{{ category.name }}
Remarks
Date
Add to Expenses
Expenses
Today
Yesterday
This week
This month
This year
{{ expense.remarks }}
{{ expense.amount }}


Places (QML)
The Places example demonstrates how to search for Places. In particular it shows how further information such as reviews, images and related content can be retrieved.
Running the Example
To run the example from Qt Creator, open the Welcome mode and select the example from Examples. For more information, visit Building and Running an Example.
The example can work with any of the available geo services plugins. However, some plugins may require additional plugin parameters in order to function correctly. Plugin parameters can be passed on the command line using the --plugin
argument, which takes the form:
--plugin.<parameter name> <parameter value>
Refer to the documentation for each of the geo services plugins for details on what plugin parameters they support. The default plugin used by this example is Qt Location Open Street Map Plugin, which does not require any parameters.
Overview
The Places example presents an application window displaying a map. At the top of the window is a search box, which is used to enter a place search query. To search for a place enter a search term into the text box and click the magnifying glass icon. To search for a place by category, click the category icon to display the list of available categories and select the desired category. The place search query will be for places that are near the current location shown on the map.
For some plugins like Qt Location HERE Plugin the search box provides search term suggestions when three or more characters are entered. Selecting one of the suggestions will cause a place search to be performed with the selected search text.
Clicking on a search result will display details about the place. If a places has rich content (editorials, reviews and images), these can be accessed by the buttons on the details page. To find similar places click the "Find similar" button.
The geo service provider can be changed by accessing the "Provider" menu.
Displaying Categories
Before search by category can be performed, the list of available categories needs to be retrieved. This is achieved by creating a CategoryModel.
CategoryModel { id: categoryModel hierarchical: true }
The CategoryModel type provides a model of the available categories. It can provide either a flat list or a hierarchical tree model. In this example, we use a hierarchical tree model, by setting the hierarchical property to true. The plugin property is set during example intalization.
Next we create a ListView to display the category model.
ListView { id: root property variant categoryModel property variant rootIndex signal searchCategory(variant category) signal showSubcategories(variant index) snapMode: ListView.SnapToItem model: DelegateModel { id: delegeteDataModel model: root.categoryModel rootIndex: root.rootIndex delegate: CategoryDelegate { onSearchCategory: root.searchCategory(category); onShowSubcategories: root.showSubcategories(delegeteDataModel.modelIndex(index)) } } }
Because a hierarchical model is being used, a DelegateModel is needed to provide navigation functionality. If flat list model was being used the view could use the CategoryModel directly.
The rootIndex property sets the root index of the DelegateModel. Categories are displayed by the CategoryDelegate, which provides two signals. The onShowSubcategories emits the showSubcategories() signal with root index to the current index causing the sub categories of the selected category to be displayed. The onSearchCategory handler emits the searchCategory() signal with a category parameter indicating which specific category has been chosen.
The CategoryDelegate displays the category name and emits the searchCategory() signal when the Label is clicked:
Label { id: labelItem text: category.name anchors.left: icon.right anchors.verticalCenter: parent.verticalCenter anchors.right: arrow.left } MouseArea { id: mouse anchors.fill: parent onClicked: root.searchCategory() }
The CategoryDelegate also displays arrow ToolButton when hasModelChildren property is set.
ToolButton { id: arrow anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter anchors.rightMargin: 15 visible: model.hasModelChildren iconSource: "../../resources/right.png" onClicked: root.showSubcategories() }
Presenting Search Suggestions
The PlaceSearchSuggestionModel type is used to fetch suggested search terms based on a partially entered search term.
A new suggestion search is triggered whenever the entered search term is changed.
SearchBar { id: searchBar onSearchTextChanged: { if (searchText.length >= 3 && suggestionModel != null) { suggestionModel.searchTerm = searchText; suggestionModel.update(); } } }
Suggestions are only queried if the length of the search term is three or more characters.
When the status of the PlaceSearchSuggestionModel changes, search suggestions are displayed.
PlaceSearchSuggestionModel { id: suggestionModel searchArea: searchRegion onStatusChanged: { if (status == PlaceSearchSuggestionModel.Ready) stackView.showSuggestions() } }
The main object in the "SuggestionsShown" state is the ListView showing the search suggestions.
ListView { id: suggestionView property variant suggestionModel signal suggestionSelected(string text) model: suggestionModel delegate: Item { width: parent.width height: label.height * 1.5 Label { id: label text: suggestion } MouseArea { anchors.fill: parent onClicked: suggestionSelected(suggestion) } } }
A Label object is used as the delegate to display the suggestion text. Clicking on the suggested search term updates the search term and triggers a place search using the search suggestion.
Searching for Places
The PlaceSearchModel type is used to search for places.
PlaceSearchModel { id: placeSearchModel searchArea: searchRegion function searchForCategory(category) { searchTerm = ""; categories = category; recommendationId = ""; searchArea = searchRegion limit = -1; update(); } function searchForText(text) { searchTerm = text; categories = null; recommendationId = ""; searchArea = searchRegion limit = -1; update(); } function searchForRecommendations(placeId) { searchTerm = ""; categories = null; recommendationId = placeId; searchArea = null; limit = -1; update(); } onStatusChanged: { switch (status) { case PlaceSearchModel.Ready: if (count > 0) stackView.showPlaces() else stackView.showMessage(qsTr("Search Place Error"),qsTr("Place not found !")) break; case PlaceSearchModel.Error: stackView.showMessage(qsTr("Search Place Error"),errorString()) break; } } }
First some of the model's properties are set, which will be used to form the search request. The searchArea property is set to the searchRegion object which is a geocircle with a center that is linked to the current location displayed on the Map.
Finally, we define three helper functions searchForCategory(), searchForText() and searchForRecommendations() which set either the categories or searchTerm or recommendationId properties and invokes the update() method to start the place search. The search results are displayed in a ListView.
ListView { id: searchView width: parent.width height: parent.height property variant placeSearchModel signal showPlaceDetails(variant place, variant distance) signal showMap() model: placeSearchModel delegate: SearchResultDelegate { onShowPlaceDetails: searchView.showPlaceDetails(place, distance) onSearchFor: placeSearchModel.searchForText(query); } footer: RowLayout { width: parent.width Button { text: qsTr("Previous") enabled: placeSearchModel.previousPagesAvailable onClicked: placeSearchModel.previousPage() Layout.alignment: Qt.AlignHCenter } Button { text: qsTr("Clear") onClicked: { placeSearchModel.reset() showMap() } Layout.alignment: Qt.AlignHCenter } Button { text: qsTr("Next") enabled: placeSearchModel.nextPagesAvailable onClicked: placeSearchModel.nextPage() Layout.alignment: Qt.AlignHCenter } } }
The delegate used in the ListView, SearchResultDelegate, is designed to handle multiple search result types via a Loader object. For results of type PlaceResult the delegate is:
Component { id: placeComponent Item { id: placeRoot width: root.width height: Math.max(icon.height, 3 * placeName.height) Rectangle { anchors.fill: parent color: "#44ffffff" visible: mouse.pressed } Rectangle { anchors.fill: parent color: "#dbffde" visible: model.sponsored !== undefined ? model.sponsored : false Label { text: qsTr("Sponsored result") horizontalAlignment: Text.AlignRight anchors.right: parent.right anchors.bottom: parent.bottom font.pixelSize: 8 visible: model.sponsored !== undefined ? model.sponsored : false } } GridLayout { rows: 2 columns: 2 anchors.fill: parent anchors.leftMargin: 30 flow: GridLayout.TopToBottom Image { // anchors.verticalCenter: parent.verticalCenter id:icon source: place.favorite ? "../../resources/star.png" : place.icon.url() Layout.rowSpan: 2 } Label { id: placeName text: place.favorite ? place.favorite.name : place.name Layout.fillWidth: true } Label { id: distanceText font.italic: true text: Helper.formatDistance(distance) Layout.fillWidth: true } } Rectangle { anchors.left: parent.left anchors.right: parent.right anchors.margins: 15 height: 1 color: "#46a2da" } MouseArea { id: mouse anchors.fill: parent onClicked: { if (model.type === undefined || type === PlaceSearchModel.PlaceResult) { if (!place.detailsFetched) place.getDetails(); root.showPlaceDetails(model.place, model.distance); } } } } }
Displaying Place Content
Places can have additional rich content, including editorials, reviews and images. Rich content is accessed via a set of models. Content models are generally not created directly by the application developer, instead models are obtained from the editorialModel, reviewModel and imageModel properties of the Place type.
ListView { id:view property Place place signal showEditorial(variant editorial) width: parent.width height: parent.height model: place.editorialModel delegate: EditorialDelegate { onShowEditorial: view.showEditorial(model) } }
Files:
- places/helper.js
- places/places.qml
- places/forms/Message.qml
- places/forms/MessageForm.ui.qml
- places/forms/PlaceDetails.qml
- places/forms/PlaceDetailsForm.ui.qml
- places/forms/SearchBoundingBox.qml
- places/forms/SearchBoundingBoxForm.ui.qml
- places/forms/SearchBoundingCircle.qml
- places/forms/SearchBoundingCircleForm.ui.qml
- places/forms/SearchCenter.qml
- places/forms/SearchCenterForm.ui.qml
- places/forms/SearchOptions.qml
- places/forms/SearchOptionsForm.ui.qml
- places/items/MainMenu.qml
- places/items/MapComponent.qml
- places/items/SearchBar.qml
- places/views/CategoryDelegate.qml
- places/views/CategoryView.qml
- places/views/EditorialDelegate.qml
- places/views/EditorialPage.qml
- places/views/EditorialView.qml
- places/views/ImageView.qml
- places/views/RatingView.qml
- places/views/ReviewDelegate.qml
- places/views/ReviewPage.qml
- places/views/ReviewView.qml
- places/views/SearchResultDelegate.qml
- places/views/SearchResultView.qml
- places/views/SuggestionView.qml
- places/main.cpp
- places/places.pro
- places/places.qrc


If you see this, something didn't load correctly. Check the browser console for error messages. Is there a file in the tests subdirectory? Did you create the file in the main directory?


Sign in
Please sign in first to enjoy the service, or
Sign up
Account
Password
Submit
Already has an account? Please
Sign in
Account
Password
Name
Phone
Submit


4.0.0-2
The Core Application class.
Available options are:
| Name | Description |
|---|---|
| appName | the name of your app. Will be used for console logging. |
| appDir | the location to use to load the default 'package.json' file. |
| namespace | any additional namespaces to use to load modules in the node _ modules folder. Can be a string or array of strings. |
| modules | an array of paths to require into the application |
| debug | Boolean to display debug messages, including startup banner |
| script | Boolean to indicate the application is a CLI script, silences all logging/output messages except for explicit console.log calls |
| silent | Don't show any console output. Useful for CLI scripts. |
Extends Dispatcher
(Object)
the configuration options
import {application} from 'nxus-core'
application.start()
export default application
The core Dispatcher class, which implements promisified
Extends EventEmitter
import { Dispatcher } from 'nxus-core'
class MyClass extends Dispatcher {
...
}
The Nxus Core package includes the basic Application framework for building a Nxus app.
You'll probably find the following resources useful background and help in building Nxus applcations.
The full set of Nxus docs is available at http://docs.gonxus.org.
> npm install nxus-core --save
In your root application, create a new Application instance:
import {Application} from 'nxus-core'
let app = new Application(options)
app.start()
export default app
Nxus is built around the concept of a boot cycle. The application dispatches events in the following order:
| Boot Stage | Description |
|---|---|
init |
indicates the application is starting up and initializing modules. Other modules are not gauranteed to be available at this phase. |
load |
modules are initialized and loading. This is the place to do any internal setup (outside of the constructor). Other modules are not gauranteed to be available at this phase. |
startup |
all modules have been loaded and are available. This is the place to do any setup that requires data/input from other modules (like Storage) |
launch |
the application is launching and all services have been started. Routes are accessible. Use onceAfter('launch') to gaurantee execution after the application has completely launched |
By defaul the Application will look for other Nxus modules in the following order:
package.json
file.namespace
application config option.In order to access module commands, use the Application.get() method.
let router = Application.get('router')
The Application exposes a core config
object that contains application and module specific configuration values.
Nxus uses the rc library to provide application configuration.
The application configuration can usually be found in a .nxusrc
file in the root folder.
You can override specific confirguation values using command line environment variables, which supports nesting.
nxus_myconfig__value__first=true npm start
will translate into an application config of
console.log(app.config.myconfig) // {value: {first: true}}
The NxusModule class is a base class for all Nxus modules.
(object)
: The application configuration for this module.
(Logger)
: The logger for the module.


GabDecker is a TweetDeck-like interface to Gab.com.
GabDecker requires a JavaScript-enabled browser to get more than this static page.
News
Gab API Explorer
© 2018 Bill St. Clair GitHub


Vetan1675.github.io
Invacare Action 4 NG Handbücher.
Invacare Action 4 NG Handbücher and Oyl manufacturing company RT120AR Handbücher.


Machine Learning: An Introduction and Guide
March 26 2017
Hi, I'm Jake Mayeux. I am a student at Northeastern university studying Computer Science and Engineering. This article is meant to serve as a guide and introduction for those interested in Machine Learning. I will be using Python to show how some things work which means I assume you have basic understanding of how to use and run Python code.
Contents
- What is Machine Learning?
- Machine Learning for Artificial Intelligence
- Machine Learning in Data Analysis
- Bibliography
What is Machine Learning?
You have most likely heard of machine learning by now but you may not know what it really is. Machine learning is a term used in Computer Science to describe a computer program or algorithm that has the ability to learn. Machine learning has many different applications from artificial intelligence to big data analysis. Deep learning, a type of machine learning, is now even used to power Google's search engine3.
There are many different types of machine learning all with different pros and cons. In this article I am going to cover how to use machine learning for data analysis and for artificial intelligence. I will provide code samples along the way so make sure you have Python 2.7 installed if you would like to follow along. If you want to work with Python in an isolated environment to ensure you do not have conflicting packages see virtual environments. I will try to make this as easy to follow for those without knowledge of programming.
Machine Learning for Artificial Intelligence1
Machine learning can simulate the way a brain learns to solve challenges that would normally be highly complex for a computer algorithm. For example Andrej Kaparthy created a neural network that was taught to play the old Atari game Pong. He was able to accomplish this by creating an artificial neural network and training it using reinforcement learning. The following image shows a visualization for how the model will work. A large matrix representing the pixels of the screen will be fed into the neural network which will then output a probability of moving up or down.
The first step here is to create the artificial neural network. Here is a sample of Python code that shows how the neural network can be coded. W1 and W2 are two matrices that contain random numbers and x is a matrix that holds the input information, in this case it would be the matrix of pixels. The following code is courtesy of Andrej.
h = np.dot(W1, x) # compute hidden layer neuron activations
h[h<0] = 0 # ReLU nonlinearity: threshold at zero
logp = np.dot(W2, h) # compute log probability of going up
p = 1.0 / (1.0 + np.exp(-logp)) # sigmoid function (gives probability of going up)
So what is going on here? The two matrices that we initialized, W1 and W2 represent the neural network. We begin with random matrices which will give us random output. The math going on here is a bit tricky but all you need to know is that the random values contained within W1 and W2 represent connections in a neural network similar to the one illustrated in the diagram below.
Of course we do not want random values but once we start to train the network we can reinforce the "good parts" of the matrices so that it will be more likely to give us the output we want based on the given input. As we continue to train the model the connections that are considered good will be enforced more and more. This may be a bit confusing at first but lets see how it all fits together when we go to train our model.
With the forward pass we feed our data into the network and receive probabilities for moving up or down. We then sample the action by performing a weighted random selection between the outputs and performing the action in game. We then assess whether or not the move was good based on whether or not we end up scoring a point. Then, on the backward pass, we either reinforce (if the decision was good) or weaken (if the decision was bad) the aspects of the neural network that brought us to the conclusion of going up or down. And that's it! We then train the network by repeating this process over and over until it "learns" how to play pong. It will start out by making random movements and over time make better and better moves until it always knows the best move to make with great certainty.
Here is a video of Andrej Kaparthy's AI in action. You can check out his blog here for more information
Machine Learning in Data Analysis2
As technology becomes increasingly integrated with our everyday life, telemetry finds its way into more and more of the software we use everyday. Companies like Microsoft, Amazon and Google record massive amounts of data through tracking cookies planted on websites and usage data reported from their software. To uncover valuable trends and information hidden within these large data sets, data researchers use machine learning algorithms to analyze and make sense of the data.
I am going to show you how you can use machine learning with Python to analyze data and find trends using the same algorithms used by Big Data.
To begin lets setup our work environment. Make a new directory for the project. If you are going to setup a virtual environment you should do so now. Run the following command to install the dependencies needed for this project. All following code samples are courtesy of Jason Brownlee.
$ pip install scipy numpy matplotlib pandas sklearn
Import all the needed libraries with the following code
import pandas
from pandas.tools.plotting import scatter_matrix
import matplotlib.pyplot as plt
from sklearn import model_selection
from sklearn.metrics import classification_report
from sklearn.metrics import confusion_matrix
from sklearn.metrics import accuracy_score
from sklearn.linear_model import LogisticRegression
from sklearn.tree import DecisionTreeClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
from sklearn.naive_bayes import GaussianNB
from sklearn.svm import SVC
We will be working with the iris flowers dataset. This dataset is often used as a hello world example for machine learning. You can find the dataset here. Use the following code to load the data into a labeled dataset.
url = "https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data"
names = ['sepal-length', 'sepal-width', 'petal-length', 'petal-width', 'class']
dataset = pandas.read_csv(url, names=names)
Before feeding the data into our model we will split it into two arrays. The first array will be used to train the model and will consist of the first 80% of the iris data set. The other 20% of the data will be used to test the model. After training the model with the first 80%, we will have it generate data and see how close it is to the other 20%. The following code splits the data like so. We set the scoring variable to accuracy which determines how we will determine the best algorithm. The seed is used for the random number generator and is there just to make sure that we both get the same results.
# Split-out validation dataset array = dataset.values X = array[:,0:4] Y = array[:,4] validation_size = 0.20 seed = 7 scoring = 'accuracy' X_train, X_validation, Y_train, Y_validation = model_selection.train_test_split(X, Y, test_size=validation_size, random_state=seed)
Now that we have loaded the data we are ready to run it through the learning algorithms. We will use 6 different algorithms and assess their accuracy to choose the best model for our data. After running the following code you should see it output the score or fitness for each algorithm. You should use this value to choose the best algorithm for your data.
models = []
models.append(('LR', LogisticRegression()))
models.append(('LDA', LinearDiscriminantAnalysis()))
models.append(('KNN', KNeighborsClassifier()))
models.append(('CART', DecisionTreeClassifier()))
models.append(('NB', GaussianNB()))
models.append(('SVM', SVC()))
results = []
names = []
for name, model in models:
kfold = model_selection.KFold(n_splits=10, random_state=seed)
cv_results = model_selection.cross_val_score(model, X_train, Y_train, cv=kfold, scoring=scoring)
results.append(cv_results)
names.append(name)
msg = "%s: %f (%f)" % (name, cv_results.mean(), cv_results.std())
print(msg)
After choosing which algorithm you want to go with, you can use it to make predictions for your data. In this example I chose the KNN algorithm to predict possible values that could be included in the data set.
knn = KNeighborsClassifier()
knn.fit(X_train, Y_train)
predictions = knn.predict(X_validation)
The predictions matrix now contains data that was generated by the model
Congratulations! You are now able to use machine learning in real world applications. I hope you found this article useful and informative.
Bibliography
- Karpathy, Andrej. "Deep Reinforcement Learning: Pong from Pixels." Deep Reinforcement Learning: Pong from Pixels. N.p., 31 May 2016. Web. 22 Mar. 2017.
- Brownlee, Jason. "Your First Machine Learning Project in Python Step-By-Step." Machine Learning Mastery. N.p., 13 Mar. 2017. Web. 21 Mar. 2017.
- Metz, Cade. "AI Is About to Learn More Like Humans-with a Little Uncertainty." Wired. Conde Nast, 03 Feb. 2017. Web. 22 Mar. 2017.
- Moynihan, Tim. "Ex-Googlers Build a Neural Network to Protect Your Heart." Wired. Conde Nast, 20 Mar. 2017. Web. 21 Mar. 2017.
- "Machine Learning." Wikipedia. Wikimedia Foundation, 22 Mar. 2017. Web. 22 Mar. 2017.
- Z., Zygmunt. "FastML." Bayesian Machine Learning - FastML. N.p., 28 Mar. 2016. Web. 22 Mar. 2017.
- Metz, Cade. "AI Is Transforming Google Search. The Rest of the Web Is Next." Wired. Conde Nast, 04 Feb. 2016. Web. 22 Mar. 2017.


Exchange Bitcoin (BTC) at the best available rate with no registration and zero fees.
The first digital cryptocurrency in the world was Bitcoin. The project initially started as Satoshi Nakamoto proposal, who has published the project's whitepaper on bitcointalk in 2008. In 2009 he mined the fist genesis block of Bitcoin.
Bitcoin is some sort of a new digital "gold", you may earn a part of it, hold it, mine or use as a payment method. Despite other faster and more scalable cryptos on the market, Bitcoin is still the leader, the most demanded and the most influental cryptocurrency, the most tradeble pair on exchanges. If the Bitcoin price drops it is also affects the price of the most coins and tokens.
News background and the forecasts of experts. The events that occur around Bitcoin, directly affect the cost of cryptocurrency. For example, hacking of exchange platforms and negative statements by experts in the cryptocurrency sphere lead to decline in the BTC price. On the other hand, positive developments contribute to the Bitcoin value rise. Recall at least the inclusion of Bitcoin Cash in the listing of Coinbase, after which the course BTC price soared up.
The BTC price is directly dependent on the decisions of the governments of large countries regarding the circulation and use of virtual money. The emergence of prohibitions, taxes or fines for miners has a negative impact on the exchange rate of Bitcoin. This is especially noticeable when it comes to large market players, such as China or the United States.
Fluctuations in the Bitcoin exchange rate price led to the division of experts into two groups. Some believe the situation with a correction issues are temporary, and already in 2019, Bitcoin will reach new heights. Others, however, argue that the era of cryptocurrency is ceasing to exist.
In the context of BTC price, one cannot be categorical, because the cost of the digital currency, including in 2019, depends on many factors.
Despite a number of negative factors, the forecast for Bitcoin for 2019, according to many experts, is positive. The reason is that the popularity of cryptocurrency is growing. It is planned that by the beginning of 2020 the number of BTC users will rise to the level of five million people. For comparison, back in 2014, this parameter was about 1.5 million. Against this background, it can be argued that in the coming years, Bitcoin will dominate among other competitors and is unlikely to leave the “throne”.
#4 Anthony Pompliano Bitcoin Price Prediction
Bitcoin may foreseen price drop up to $3000, the bear market will continue till Q3 2019, next there can be some positive bullish market attempts.
In 2016, the miners experienced another decline in the rewards for the mined block, which decreased to 12.5 Bitcoins. In 2018 and the next 2019, this parameter will remain unchanged, but the complexity of the cryptocurrency network continues to grow. This happens due to the emergence of new ASIC-miners, who ousted farms on the GPU and processors, making the production process more costly for network participants. In addition, on August 9, 2018, 17.198 million coins have already been mined. This means that miners have 3.802 million BTC left, after which there will be nothing to extract. The calculations made show that mining profitability is decreasing, and payback periods, on the contrary, are growing. As a result, interest in cryptocurrency, as an object of extraction, is gradually decreasing, which may lead to a decrease in the BTC price.
Despite the high capitalization of BTC, which is 109.2 billion as of August 9, 2018, this is a “drop in the ocean” compared to the sum of the total cashless turnover. As a result, Bitcoin is still subject to the influence of large players who are able to buy or sell BTC in large volumes. Against this background, there remains the risk of a collapse in the course, which can occur at any time.
You can easily buy Bitcoin via Atomic Wallet Interface and process a payment with your bank card.
Atomic Wallet allows you to exchange cryptocurrency using a built-in instant exchange between more than 60 assets at the best available rate via Changelly, ChangeNOW or Shapeshift.


--- layout: post title: Mobile pull-based advertising date: 2004-08-26 00:00:00 category: mobile ---
Nice article about pull-based advertising. Last time I posted something about this, I received a snotty email from a guy at TxtVrt (www dot txtvert dot co dot uk, no google juice from me) insinuating that we'd nicked the idea from them. More realistically it's such a blindingly obvious thing to do that I can't see why this isn't already endemic in the UK.
It's such a cheap and easy thing for an advertiser to do, to track effectiveness and provide a return-path. Can anyone reading this see a downside to it, particularly at a time when web URLs are usually stuck at the foot of a billboard?


--- layout: default title: Chartmander - HTML5 canvas charts --- {% include nav.html %} Attractive charts for your new webapp or design mockup
Student at SPSE Kosice Slovakia


Curious Cat
Home
Services
Gallery
About
Contact
Contact Us
Please leave your name, phone number, and a brief message through a form below,
we will contact you within the next 24 hours.
Book Online Form
Name:
Email:
Date:
Message:
Submit


Uses of Class
com.jme.bullet.collision.PhysicsCollisionObject
-
Packages that use PhysicsCollisionObject Package Description com.jme.bullet com.jme.bullet.animation A dynamic animation control and some associated classes.com.jme.bullet.collision com.jme.bullet.control com.jme.bullet.objects -
-
Uses of PhysicsCollisionObject in com.jme.bullet
Methods in com.jme.bullet with parameters of type PhysicsCollisionObject Modifier and Type Method Description void
PhysicsSpace. addCollisionObject(PhysicsCollisionObject obj)
Add the specified collision object to this space.void
PhysicsSpace. removeCollisionObject(PhysicsCollisionObject obj)
Remove the specified collision object from this space. -
Uses of PhysicsCollisionObject in com.jme.bullet.animation
Methods in com.jme.bullet.animation with parameters of type PhysicsCollisionObject Modifier and Type Method Description void
RagdollCollisionListener. collide(PhysicsLink physicsLink, PhysicsCollisionObject object, PhysicsCollisionEvent event)
Invoked when a collision involving a linked rigid body occurs. -
Uses of PhysicsCollisionObject in com.jme.bullet.collision
Methods in com.jme.bullet.collision that return PhysicsCollisionObject Modifier and Type Method Description PhysicsCollisionObject
PhysicsRayTestResult. getCollisionObject()
Access the collision object that was hit.PhysicsCollisionObject
PhysicsSweepTestResult. getCollisionObject()
Access the collision object that was hit.PhysicsCollisionObject
PhysicsCollisionEvent. getObjectA()
Access collision object A.PhysicsCollisionObject
PhysicsCollisionEvent. getObjectB()
Access collision object B.Methods in com.jme.bullet.collision with parameters of type PhysicsCollisionObject Modifier and Type Method Description boolean
PhysicsCollisionGroupListener. collide(PhysicsCollisionObject nodeA, PhysicsCollisionObject nodeB)
Invoked when two physics objects of the registered group are about to collide.void
RagdollCollisionListener. collide(com.jme.animation.Bone bone, PhysicsCollisionObject object, PhysicsCollisionEvent event)
Invoked when a collision involving a KinematicRagdollControl occurs.void
PhysicsSweepTestResult. fill(PhysicsCollisionObject collisionObject, com.jme.math.Vector3f hitNormalLocal, float hitFraction, boolean normalInWorldSpace)
Fill in the fields of this result.PhysicsCollisionEvent
PhysicsCollisionEventFactory. getEvent(int type, PhysicsCollisionObject source, PhysicsCollisionObject nodeB, long manifoldPointObjectId)
Obtain an unused event.void
PhysicsCollisionEvent. refactor(int type, PhysicsCollisionObject source, PhysicsCollisionObject nodeB, long manifoldPointObjectId)
Reuse this event.Constructors in com.jme.bullet.collision with parameters of type PhysicsCollisionObject Constructor Description PhysicsCollisionEvent(int type, PhysicsCollisionObject nodeA, PhysicsCollisionObject nodeB, long manifoldPointObjectId)
Instantiate a collision event.PhysicsSweepTestResult(PhysicsCollisionObject collisionObject, com.jme.math.Vector3f hitNormalLocal, float hitFraction, boolean normalInWorldSpace)
-
Uses of PhysicsCollisionObject in com.jme.bullet.control
Subclasses of PhysicsCollisionObject in com.jme.bullet.control Modifier and Type Class Description class
CharacterControl
You might want to tryBetterCharacterControl
as well.class
GhostControl
A physics control to link a PhysicsGhostObject to a spatial.class
RigidBodyControl
A physics control to link a PhysicsRigidBody to a spatial.class
VehicleControl
A physics control to link a PhysicsVehicle to a spatial. -
Uses of PhysicsCollisionObject in com.jme.bullet.objects
Subclasses of PhysicsCollisionObject in com.jme.bullet.objects Modifier and Type Class Description class
PhysicsCharacter
A collision object for simplified character simulation, based on Bullet's btKinematicCharacterController.class
PhysicsGhostObject
A collision object for intangibles, based on Bullet's btPairCachingGhostObject.class
PhysicsRigidBody
A collision object for a rigid body, based on Bullet's btRigidBody.class
PhysicsVehicle
A collision object for simplified vehicle simulation based on Bullet's btRaycastVehicle.Methods in com.jme.bullet.objects that return PhysicsCollisionObject Modifier and Type Method Description PhysicsCollisionObject
VehicleWheel. getGroundObject()
returns the object this wheel is in contact with or null if no contactPhysicsCollisionObject
PhysicsGhostObject. getOverlapping(int index)
Access an overlapping collision object by its position in the list.Methods in com.jme.bullet.objects that return types with arguments of type PhysicsCollisionObject Modifier and Type Method Description java.util.List<PhysicsCollisionObject>
PhysicsGhostObject. getOverlappingObjects()
Access a list of overlapping objects.
-


The life of TikTok head Alex Zhu, the Musical.ly cofounder in charge of Gen Z's beloved video-sharing app, Business Insider - Business Insider Singapore
by Paige Leskin, Business Insider US- TikTok, the viral video-sharing app, is headed up by Alex Zhu, as revealed in a recent New York Times profile.
- Zhu is the cofounder and former co-CEO of Musical.ly, a US lip-syncing app that TikTok’s parent company ByteDance acquired for $1 billion, then shut down and merged into TikTok in 2018.

- Visit Business Insider’s homepage for more stories.
Alex Zhu is a relatively secretive figure, and largely stays out of the media. In a recent profile in The New York Times, the 40-year-old Zhu was described as having “a little artsy oddness.” Zhu refers to himself on LinkedIn as a “designtrepreneur,” and lists his work location as Mars.
Source: The New York Times, Alex Zhu on LinkedIn
Zhu grew up in Anhui, a landlocked province in eastern China that stretches across two river basins.
Source: The New York Times
Zhu then attended Zhejiang University, one of the most prestigious institutions in China. He studied civil engineering, and graduated with a bachelor’s degree in 2000.
Source: Alex Zhu on LinkedIn
By 2002, Zhu was hired to run the product design team at WebEx, a videoconferencing software maker later acquired by Cisco. Zhu left WebEx in 2004 to work at the German software company SAP in Shanghai.
Source: The New York Times, Alex Zhu on LinkedIn
Zhu found his way to the US by 2010 working out of SAP’s Bay Area office. He took a special interest in education while there, and came up with the idea to develop an app for hosting short-form education videos.
Source: Business Insider
Throughout 2013, Zhu and Luyu Yang — cofounders and longtime friends —spent six months building the educational app, called Cicada, and raised $250,000. “It was doomed to be a failure,” Zhu later told Business Insider. “The day we released this application to the market, we realized it was never going to take off.”
Source: Business Insider
With only 8% of their money remaining, Zhu was determined to brainstorm a new idea instead of returning the funding to investors. As the team scrambled, Zhu took a brief gig at Microsoft driving its “mobile disruption” initiatives in the summer of 2014.
Source: Business Insider, Alex Zhu on LinkedIn
Around this time, Zhu embarked on a memorable train ride from San Francisco to Mountain View, California. He noticed a group of teens nearby passing around their phones, half of them listening to music while the other half were taking photos and decorating them in emoji.
Source: Business Insider
Zhu thought about how he could combine these different features into a single social app for teens, and the idea for Musical.ly was born. The team behind Cicada turned Zhu’s idea into an app in only 30 days, and in July 2014, launched Musical.ly for creating 15-second lip-syncing music videos.
Source: Business Insider
Musical.ly came to the US, and hit its stride when it reached the No. 1 spot in the US iTunes store. That same year, Zhu returned to China to reunite with his Cicada-turned-Muisical.ly cofounder and co-CEO, Yang, to build up the company together out of Shanghai.
Source: Business Insider
In November 2017, a massive Chinese company called ByteDance acquired Musical.ly for $1 billion. At the time, Zhu said the deal would help Musical.ly to expand into Asian markets as a standalone app. It’s not clear how much Zhu made from the acquisition.
Source: Business Insider
However, less than a year later, ByteDance shut down Musical.ly and merged it into its existing short-form video app called TikTok. “Combining Musical.ly and TikTok is a natural fit given the shared mission of both experiences — to create a community where everyone can be a creator,” Zhu said at the time.
Source: Business Insider, Musical.ly
Following the death of Musical.ly, Zhu was given the title of TikTok’s senior vice president, and stayed on to help with the transition. He then left ByteDance to take some time off to reportedly “rest, go clubbing in Shanghai and listen to jazz.” He kept a low profile and stayed out of the media.
Source: Musical.ly, The New York Times
Then, Zhu rejoined the TikTok team earlier this year, not long after ByteDance achieved a $75 billion valuation. Zhu then took over as head of TikTok, he revealed in a November interview with the Times.
Source: The New York Times
Zhu’s interview came at a tricky time for TikTok, which faces scrutiny in the US over allegations it censors content dealing with “highly controversial topics” at the request of the Chinese government. Zhu told the Times that if China’s president ever asked him to take down a video from TikTok or access users’ data, he would refuse.
Source: Business Insider


--- layout: home title: Delly_Publisher tagline: Personal Article Publishing Blog --- {% include JB/setup %}
{{ site.tagline }}{% endif %}
{{ post.excerpt }} Read More...