示例#1
0
文件: net.cpp 项目: amigrave/SilkJS
static JSVAL net_socketpair(JSARGS args) {
    int sv[2];
    if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == -1) {
        return False();
    }
    JSARRAY a = Array::New();
    a->Set(0, Integer::New(sv[0]));
    a->Set(1, Integer::New(sv[1]));
    return a;
}
示例#2
0
文件: mysql.cpp 项目: sequoiar/SilkJS
static JSVAL fetch_lengths(JSARGS args) {
	HandleScope scope;
	MYSQL_RES *result = (MYSQL_RES *) args[0]->IntegerValue();
	unsigned int num_fields = mysql_num_fields(result);
	unsigned long *lengths = mysql_fetch_lengths(result);
	JSARRAY a = Array::New();;
	for (unsigned int i=0; i<num_fields; i++) {
		a->Set(i, Integer::New(lengths[i]));
	}
	return scope.Close(a);
}
示例#3
0
文件: mysql.cpp 项目: sequoiar/SilkJS
static JSVAL fetch_fields(JSARGS args) {
	HandleScope scope;
	MYSQL_RES *result = (MYSQL_RES *) args[0]->IntegerValue();
	unsigned int num_fields = mysql_num_fields(result);
	MYSQL_FIELD *fields = mysql_fetch_fields(result);
	JSARRAY a = Array::New();;
	for (unsigned int i=0; i<num_fields; i++) {
		JSOBJ o = Object::New();
		MakeField(&fields[i], o);
		a->Set(i, o);
	}
	return scope.Close(a);
}