本文整理汇总了C++中IOSYMBOL函数的典型用法代码示例。如果您正苦于以下问题:C++ IOSYMBOL函数的具体用法?C++ IOSYMBOL怎么用?C++ IOSYMBOL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IOSYMBOL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getenv
IoObject *IoUser_protoName(IoUser *self, IoObject *locals, IoMessage *m)
{
/*doc User name
Returns the current user's name.
*/
char *userName = (char *)getlogin();
if (userName == NULL)
{
userName = getenv("LOGNAME");
}
if (userName == NULL)
{
return IONIL(self);
}
return IOSYMBOL(userName);
}
示例2: IO_METHOD
IO_METHOD(IoObject, tokensForString)
{
/*doc Compiler tokensForString(aString)
Returns a list of token objects lexed from the input string.
*/
IoSymbol *text = IoMessage_locals_seqArgAt_(m, locals, 0);
IoList *tokensList = IoList_new(IOSTATE);
IoLexer *lexer = IoLexer_new();
IoSymbol *name = IOSYMBOL("name");
IoSymbol *line = IOSYMBOL("line");
IoSymbol *character = IOSYMBOL("character");
IoSymbol *type = IOSYMBOL("type");
IoLexer_string_(lexer, CSTRING(text));
IoLexer_lex(lexer);
if (IoLexer_errorToken(lexer))
{
IoSymbol *errorString = IOSYMBOL(IoLexer_errorDescription(lexer));
IoLexer_free(lexer);
IoState_error_(IOSTATE, NULL, "compile error: %s", CSTRING(errorString));
}
else
{
IoToken *t;
while ((t = IoLexer_pop(lexer)))
{
IoObject *tokenObject = IoObject_new(IOSTATE);
IoObject_setSlot_to_(tokenObject, name, IOSYMBOL(IoToken_name(t)));
IoObject_setSlot_to_(tokenObject, line, IONUMBER(IoToken_lineNumber(t)));
IoObject_setSlot_to_(tokenObject, character, IONUMBER(IoToken_charNumber(t)));
IoObject_setSlot_to_(tokenObject, type, IOSYMBOL(IoToken_typeName(t)));
IoList_rawAppend_(tokensList, tokenObject);
}
}
IoLexer_free(lexer);
return tokensList;
}
示例3: av_codec_next
IoObject *IoAVCodec_encodeCodecNames(IoAVCodec *self, IoObject *locals, IoMessage *m)
{
/*doc AVCodec encodeCodecNames
Returns a list of strings with the names of the encode codecs.
*/
AVCodec *p = av_codec_next(NULL);
IoList *names = IoList_new(IOSTATE);
while (p)
{
if (p->encode)
{
IoList_rawAppend_(names, IOSYMBOL(p->name));
}
p = av_codec_next(p);
}
return names;
}
示例4: IoMySQL_close
IoObject* IoMySQL_close(IoObject* self, IoObject* locals, IoMessage* m) {
/*#io
docSlot("close",
"Closes a previously opened connection.")
*/
if(DATA(self)->connected)
mysql_close(&DATA(self)->connection);
IoObject_removeSlot_(self, IOSYMBOL("host"));
IoObject_removeSlot_(self, IOSYMBOL("user"));
IoObject_removeSlot_(self, IOSYMBOL("password"));
IoObject_removeSlot_(self, IOSYMBOL("database"));
IoObject_removeSlot_(self, IOSYMBOL("port"));
IoObject_removeSlot_(self, IOSYMBOL("socket"));
IoObject_removeSlot_(self, IOSYMBOL("usingSSL"));
return self;
}
示例5: IoList_new
IoObject *IoAVCodec_decodeCodecNames(IoAVCodec *self, IoObject *locals, IoMessage *m)
{
/*doc AVCodec decodeCodecNames
Returns a list of strings with the names of the decode codecs.
*/
AVCodec *p = first_avcodec;
IoList *names = IoList_new(IOSTATE);
while (p)
{
if (p->decode)
{
IoList_rawAppend_(names, IOSYMBOL(p->name));
}
p = p->next;
}
return names;
}
示例6: onXmppConnect
/*** Loudmouth callbacks ***/
void onXmppConnect(LmConnection *connection, int success, void* data) {
IoObject *self = data;
IoMessage *m;
if(success == 1) {
m = IoMessage_newWithName_label_(IOSTATE, IOSYMBOL("handleConnect"), IOSYMBOL("Loudmouth"));
IoMessage_locals_performOn_(m, self, self);
lm_connection_authenticate(
connection,
CSTRING(IoObject_getSlot_(self, IOSYMBOL("username"))),
CSTRING(IoObject_getSlot_(self, IOSYMBOL("password"))),
CSTRING(IoObject_getSlot_(self, IOSYMBOL("resource"))),
onXmppAuth, data, NULL, NULL
);
} else {
m = IoMessage_newWithName_label_(IOSTATE, IOSYMBOL("handleConnectFailure"), IOSYMBOL("Loudmouth"));
IoMessage_locals_performOn_(m, self, self);
}
}
示例7: IoObject_getSlot_
IoObject *IoTokyoCabinetPrefixCursor_last(IoObject *self, IoObject *locals, IoMessage *m)
{
/*doc TokyoCabinetPrefixCursor last
Move cursor to last record. Returns self
*/
IoSeq *prefix = IoObject_getSlot_(self, IOSYMBOL("prefix"));
IOASSERT(ISSEQ(prefix), "prefix must be a sequence");
IOASSERT(TokyoCabinetPrefixCursor(self), "invalid TokyoCabinetPrefixCursor");
{
UArray *p = UArray_clone(IoSeq_rawUArray(prefix));
UArray_appendCString_(p, " "); // space preceeds .
tcbdbcurjump(TokyoCabinetPrefixCursor(self), (const void *)UArray_bytes(p), (int)UArray_size(p));
UArray_free(p);
}
return IOBOOL(self, IoTokyoCabinetPrefixCursor_keyBeginsWithPrefix_(self, prefix));
}
示例8: IoObject_new
IoEditLine *IoEditLine_proto(void *state)
{
IoMethodTable methodTable[] = {
{"hasEditLib", IoEditLine_hasEditLib},
{"readLine", IoEditLine_readLine},
{"addHistory", IoEditLine_addHistory},
{NULL, NULL},
};
IoObject *self = IoObject_new(state);
IoObject_tag_(self, IoEditLine_newTag(state));
/* Make sure editline returns characters in the multi-byte charset
of the locale */
setlocale(LC_CTYPE, "");
IoObject_setDataPointer_(self, io_calloc(1, sizeof(IoEditLineData)));
DATA(self)->prompt = IOSYMBOL("");
DATA(self)->editline = el_init("io", stdin, stdout, stderr);
DATA(self)->history = history_init();
el_set(DATA(self)->editline, EL_CLIENTDATA, self);
el_set(DATA(self)->editline, EL_HIST, history, DATA(self)->history);
el_set(DATA(self)->editline, EL_PROMPT, promptCallback);
el_set(DATA(self)->editline, EL_SIGNAL, 1);
el_set(DATA(self)->editline, EL_EDITOR, "emacs");
{
HistEvent ev;
history(DATA(self)->history, &ev, H_SETSIZE, 300);
}
el_source(DATA(self)->editline, NULL);
IoState_registerProtoWithFunc_((IoState *)state, self, IoEditLine_proto);
IoObject_addMethodTable_(self, methodTable);
return self;
}
示例9: malloc
// Serialize/Deserialize
char *IoMemcached_serialize(IoMemcached *self, IoObject *locals, IoObject *object, size_t *size, uint32_t *flags) {
char *cvalue;
if(ISSEQ(object)) {
*flags = _FLAG_SEQUENCE;
*size = IOSEQ_LENGTH(object);
cvalue = (char *) malloc(*size);
strncpy(cvalue, CSTRING(object), *size);
}
else if(ISNUMBER(object)) {
*flags = _FLAG_NUMBER;
double cnumber = IoNumber_asDouble(object);
cvalue = (char *) malloc(128 * sizeof(char));
*size = snprintf(cvalue, 127, "%.16f", cnumber);
}
else if(ISNIL(object)) {
*flags = _FLAG_NIL;
*size = 3;
cvalue = (char *) malloc(3 * sizeof(char));
strncpy(cvalue, "nil", 3);
}
else if(ISBOOL(object)) {
*flags = _FLAG_BOOLEAN;
*size = 1;
cvalue = (char *) malloc(sizeof(char));
if(object == IOSTATE->ioTrue) strncpy(cvalue, "1", 1);
if(object == IOSTATE->ioFalse) strncpy(cvalue, "0", 1);
}
else {
*flags = _FLAG_OBJECT;
IoMessage *serialize = IoMessage_newWithName_(IOSTATE, IOSYMBOL("serialized"));
IoSeq *serialized = IoMessage_locals_performOn_(serialize, locals, object);
*size = IOSEQ_LENGTH(serialized);
cvalue = (char *) malloc(*size);
strncpy(cvalue, CSTRING(serialized), *size);
}
return cvalue;
}
示例10: IoObject_getSlot_
//doc Loudmouth connect Connects to the server. Returns <code>self</code>.
IoObject *IoLoudmouth_connect(IoLoudmouth *self, IoObject *locals, IoMessage *m) {
// Q: Should we io_free() these?
IoSeq* username = IoObject_getSlot_(self, IOSYMBOL("username"));
IoSeq* password = IoObject_getSlot_(self, IOSYMBOL("password"));
IoSeq* resource = IoObject_getSlot_(self, IOSYMBOL("resource"));
IoSeq* host = IoObject_getSlot_(self, IOSYMBOL("host"));
IoNumber* port = IoObject_getSlot_(self, IOSYMBOL("port"));
IoObject* use_ssl = IoObject_getSlot_(self, IOSYMBOL("useSsl"));
IOASSERT(ISSEQ(username), "Loudmouth: username should be a Sequence");
IOASSERT(ISSEQ(password), "Loudmouth: password should be a Sequence");
IOASSERT(ISSEQ(resource), "Loudmouth: resource should be a Sequence");
IOASSERT(ISSEQ(host), "Loudmouth: host should be a Sequence");
IOASSERT(ISNUMBER(port), "Loudmouth: port should be a Number");
if(LMCONN(self) == NULL) {
LmConnection *connection = lm_connection_new_with_context(CSTRING(host), main_context);
IoObject_setDataPointer_(self, connection);
lm_connection_set_jid(connection, CSTRING(IoObject_getSlot_(self, IOSYMBOL("jid"))));
lm_connection_set_port(connection, CNUMBER(port));
if(ISTRUE(use_ssl) && lm_ssl_is_supported()) {
LmSSL *ssl = lm_ssl_new(NULL, onSslError, NULL, NULL);
lm_connection_set_ssl(connection, ssl);
lm_ssl_unref(ssl);
}
LmMessageHandler* handler = lm_message_handler_new(onXmppMessage, self, NULL);
lm_connection_register_message_handler(
connection, handler,
LM_MESSAGE_TYPE_MESSAGE, LM_HANDLER_PRIORITY_NORMAL
);
lm_message_handler_unref(handler);
lm_connection_set_disconnect_function(connection, onXmppDisconnect, NULL, NULL);
}
lm_connection_open(LMCONN(self), onXmppConnect, self, NULL, NULL);
return self;
}
示例11: IoObject_new
IoSQLite3 *IoSQLite3_proto(void *state)
{
IoObject *self = IoObject_new(state);
IoObject_tag_(self, IoSQLite3_newTag(state));
IoObject_setDataPointer_(self, io_calloc(1, sizeof(IoSQLite3Data)));
DATA(self)->path = IOSYMBOL(".");
IoState_registerProtoWithId_(state, self, protoId);
{
IoMethodTable methodTable[] = {
{"setPath", IoSQLite3_setPath},
{"path", IoSQLite3_path},
{"open", IoSQLite3_open},
{"close", IoSQLite3_close},
{"exec", IoSQLite3_exec},
{"error", IoSQLite3_errorMessage},
{"version", IoSQLite3_version},
{"setTimeoutSeconds", IoSQLite3_setTimeoutSeconds},
{"timeoutSeconds", IoSQLite3_timeoutSeconds},
{"rowsChangedCount", IoSQLite3_changes},
{"lastInsertRowId", IoSQLite3_lastInsertRowId},
{"tableNames", IoSQLite3_tableNames},
{"viewNames", IoSQLite3_viewNames},
{"columnNamesOfTable", IoSQLite3_columnNamesOfTable},
{"debugOn", IoSQLite3_debugOn},
{"debugOff", IoSQLite3_debugOff},
{"isOpen", IoSQLite3_isOpen},
{"escapeString", IoSQLite3_escapeString},
{NULL, NULL},
};
IoObject_addMethodTable_(self, methodTable);
}
return self;
}
示例12: IO_METHOD
//doc ClutterActorBox with(x1, y1, x2, y2)
IO_METHOD(IoClutterActorBox, with) {
float x1 = IoMessage_locals_floatArgAt_(m, locals, 0),
y1 = IoMessage_locals_floatArgAt_(m, locals, 1),
x2 = IoMessage_locals_floatArgAt_(m, locals, 2),
y2 = IoMessage_locals_floatArgAt_(m, locals, 3);
ClutterActorBox *actorBox = clutter_actor_box_new(x1, y1, x2, y2);
IoClutterActorBox *klone = IoClutterActorBox_newWithActorBox(IOSTATE, actorBox);
IoObject_setSlot_to_(klone,
IOSYMBOL("x1"), IoMessage_locals_numberArgAt_(m, locals, 0)
);
IoObject_setSlot_to_(klone,
IOSYMBOL("y1"), IoMessage_locals_numberArgAt_(m, locals, 1)
);
IoObject_setSlot_to_(klone,
IOSYMBOL("x2"), IoMessage_locals_numberArgAt_(m, locals, 2)
);
IoObject_setSlot_to_(klone,
IOSYMBOL("y2"), IoMessage_locals_numberArgAt_(m, locals, 3)
);
IoObject_setSlot_to_(klone,
IOSYMBOL("width"), IONUMBER(clutter_actor_box_get_width(actorBox))
);
IoObject_setSlot_to_(klone,
IOSYMBOL("height"), IONUMBER(clutter_actor_box_get_height(actorBox))
);
IoObject_setSlot_to_(klone,
IOSYMBOL("area"), IONUMBER(clutter_actor_box_get_area(actorBox))
);
return klone;
}
示例13: IoObject_new
IoRegexMatch *IoRegexMatch_proto(void *state)
{
IoObject *self = IoObject_new(state);
IoObject_tag_(self, IoRegexMatch_newTag(state));
IoObject_setDataPointer_(self, calloc(1, sizeof(IoRegexMatchData)));
DATA(self)->regex = IONIL(self);
DATA(self)->subject = IOSYMBOL("");
DATA(self)->ranges = IoList_new(state);
IoState_registerProtoWithId_(state, self, protoId);
{
IoMethodTable methodTable[] = {
{"regex", IoRegexMatch_regex},
{"subject", IoRegexMatch_subject},
{"ranges", IoRegexMatch_ranges},
{0, 0},
};
IoObject_addMethodTable_(self, methodTable);
}
return self;
}
示例14: IoObject_getSlot_
IoCFFIPointer *IoCFFIPointer_ToType_(IoObject *type)
{
IoObject *pointer, *self;
IoMap *pointers;
IoSymbol *key;
// this is a hack so macros relying on self will work
self = type;
pointers = IoObject_getSlot_(IoState_protoWithInitFunction_(IOSTATE, IoCFFIPointer_proto), IOSYMBOL("pointers"));
key = IoState_on_doCString_withLabel_(IOSTATE, type, "uniqueHexId", "IoCFFIPointer_ToType_");
pointer = IoMap_rawAt(pointers, key);
if (!pointer)
{
// create new pointer and add to cache
pointer = IoCFFIPointer_new(IOSTATE);
IoObject_setSlot_to_(pointer, IOSYMBOL("pointedToType"), type);
IoMap_rawAtPut(pointers, key, pointer);
}
return pointer;
}
示例15: IoMessage_locals_seqArgAt_
IoObject *IoTokyoCabinetPrefixCursor_jump(IoObject *self, IoObject *locals, IoMessage *m)
{
/*doc TokyoCabinetPrefixCursor jump(key)
Move cursor to record before key. Returns self
*/
IoSeq *key = IoMessage_locals_seqArgAt_(m, locals, 0);
int result;
UArray *p;
IoSeq *prefix = IoObject_getSlot_(self, IOSYMBOL("prefix"));
IOASSERT(ISSEQ(prefix), "prefix must be a sequence");
p = UArray_clone(IoSeq_rawUArray(prefix));
UArray_appendPath_(p, IoSeq_rawUArray(key));
result = tcbdbcurjump(TokyoCabinetPrefixCursor(self),
(const void *)UArray_bytes(p),
(int)UArray_sizeInBytes(p));
UArray_free(p);
IOASSERT(TokyoCabinetPrefixCursor(self), "invalid TokyoCabinetPrefixCursor");
return IOBOOL(self, result);
}