本文整理汇总了C++中FskMemPtrNew函数的典型用法代码示例。如果您正苦于以下问题:C++ FskMemPtrNew函数的具体用法?C++ FskMemPtrNew怎么用?C++ FskMemPtrNew使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FskMemPtrNew函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: xs_mod_init
void
xs_mod_init(xsMachine *the)
{
mod_t *mod;
UInt32 options = xsToInteger(xsArgc) > 0 && xsTypeOf(xsArg(0)) == xsIntegerType ? xsToInteger(xsArg(0)): 0;
FskErr ferr;
if ((ferr = FskMemPtrNew(sizeof(mod_t), (FskMemPtr *)&mod)) != kFskErrNone)
cryptThrowFSK(ferr);
if ((ferr = FskMemPtrNew(sizeof(bn_mod_t), (FskMemPtr *)&mod->mod_data)) != kFskErrNone) {
FskMemPtrDispose(mod);
cryptThrowFSK(ferr);
}
mod->_mod_code = &modFuncs;
xsResult = xsGet(xsThis, xsID("z")); /* must exist */
if (!xsIsInstanceOf(xsResult, xsGet(xsGet(xsGlobal, xsID("Arith")), xsID("z"))) || (mod->z = xsGetHostData(xsResult)) == NULL)
cryptThrow("kCryptTypeError");
xsResult = xsGet(xsThis, xsID("m")); /* must exist */
if (!xsIsInstanceOf(xsResult, mod->z->z_protoInteger) || (mod->m = xsGetHostData(xsResult)) == NULL)
nanError();
bn_mod_init(mod->mod_data, mod->z->z_data, mod->m->cint_data, options);
xsSetHostData(xsThis, mod);
}
开发者ID:Kazu-zamasu,项目名称:kinomajs,代码行数:28,代码来源:arith_kcl.c
示例2: KPR_mqttclient_subscribe
void KPR_mqttclient_subscribe(xsMachine* the)
{
KPR_MQTTClientRecord *self = xsGetHostData(xsThis);
FskErr err = kFskErrNone;
xsIntegerValue c = xsToInteger(xsArgc);
char **topics = NULL;
UInt8 *qoss = NULL;
int i, count;
UInt16 token;
if (c == 0 || (c % 2) != 0) xsThrowIfFskErr(kFskErrParameterError);
count = c / 2;
bailIfError(FskMemPtrNew(sizeof(char*) * count, &topics));
bailIfError(FskMemPtrNew(sizeof(UInt8*) * count, &qoss));
for (i = 0; i < count; i++) {
topics[i] = xsToString(xsArg(i * 2));
qoss[i] = xsToInteger(xsArg(i * 2 + 1));
}
bailIfError(KprMQTTClientSubscribeTopics(self->client, topics, qoss, count, &token));
xsResult = xsInteger(token);
bail:
FskMemPtrDispose(topics);
FskMemPtrDispose(qoss);
xsThrowIfFskErr(err);
}
开发者ID:Kazu-zamasu,项目名称:kinomajs,代码行数:30,代码来源:kprMQTT.c
示例3: KprURLMerge
FskErr KprURLMerge(char* base, char* reference, char** result)
{
FskErr err = kFskErrNone;
KprURLPartsRecord parts;
KprURLPartsRecord baseParts;
char* path = NULL;
UInt32 length;
KprURLSplit(reference, &parts);
if (!parts.scheme) {
KprURLSplit(base, &baseParts);
parts.scheme = baseParts.scheme;
parts.schemeLength = baseParts.schemeLength;
if (!parts.authority) {
parts.authority = baseParts.authority;
parts.authorityLength = baseParts.authorityLength;
if (!parts.pathLength) {
if (baseParts.authority && !baseParts.pathLength) {
bailIfError(FskMemPtrNew(1, &path));
FskMemMove(path, "/", 1);
parts.path = path;
parts.pathLength = 1;
}
else {
parts.path = baseParts.path;
parts.pathLength = baseParts.pathLength;
}
if (!parts.query) {
parts.query = baseParts.query;
parts.queryLength = baseParts.queryLength;
}
}
else if (*parts.path != '/') {
if (baseParts.authority && !baseParts.pathLength) {
bailIfError(FskMemPtrNew(1 + parts.pathLength, &path));
FskMemMove(path, "/", 1);
FskMemMove(path + 1, parts.path, parts.pathLength);
parts.path = path;
parts.pathLength++;
}
else if (baseParts.name) {
length = baseParts.name - baseParts.path;
bailIfError(FskMemPtrNew(length + parts.pathLength, &path));
FskMemMove(path, baseParts.path, length);
FskMemMove(path + length, parts.path, parts.pathLength);
parts.path = path;
parts.pathLength += length;
}
}
}
}
bailIfError(KprURLJoin(&parts, result));
bail:
FskMemPtrDispose(path);
return err;
}
开发者ID:giapdangle,项目名称:kinomajs,代码行数:56,代码来源:kprURL.c
示例4: httpServerListenerStart
static FskErr httpServerListenerStart(FskHTTPServerListener listener, FskSocket skt) {
FskErr err = kFskErrNone;
FskHTTPServerRequest request;
if (listener->http->stopped) {
FskInstrumentedItemSendMessage(listener->http, kFskHTTPInstrMsgConnectionRefusedStopped, listener);
listener->http->stats.connectionsRefused++;
FskNetSocketClose(skt);
goto bail;
}
err = FskMemPtrNewClear(sizeof(FskHTTPServerRequestRecord), (FskMemPtr*)&request);
BAIL_IF_ERR(err);
sFskHTTPServerRequestUpUse(request);
request->http = listener->http;
request->skt = skt;
FskNetSocketGetRemoteAddress(skt, (UInt32 *)&request->requesterAddress, &request->requesterPort);
FskNetSocketMakeNonblocking(request->skt);
err = FskHeaderStructNew(&request->requestHeaders);
BAIL_IF_ERR(err);
err = FskHeaderStructNew(&request->responseHeaders);
BAIL_IF_ERR(err);
request->in.bufferSize = request->http->defaultBufferSize;
request->out.bufferSize = request->http->defaultBufferSize;
err = FskMemPtrNew(request->in.bufferSize, (FskMemPtr*)&request->in.buf);
BAIL_IF_ERR(err);
err = FskMemPtrNew(request->out.bufferSize, (FskMemPtr*)&request->out.buf);
BAIL_IF_ERR(err);
FskListAppend((FskList*)&request->http->activeRequests, request);
FskTimeCallbackNew(&request->cycleCallback);
FskTimeCallbackNew(&request->keepAliveKillCallback);
listener->http->stats.connectionsMade++;
request->state = kHTTPNewSession;
FskInstrumentedItemNew(request, NULL, &gFskHTTPServerRequestTypeInstrumentation);
FskInstrumentedItemSetOwner(request, request->http);
FskTimeCallbackScheduleNextRun(request->cycleCallback, httpServerTimeCycle, request);
doCallCondition(request->http->callbacks->requestCondition, request, kFskHTTPConditionConnectionInitialized, request->refCon);
FskTimeCallbackNew(&request->timer);
FskTimeCallbackScheduleFuture(request->timer, 1, 0, KprHTTPServerTimerCallback, request);
bail:
if (err)
FskHTTPServerRequestDispose(request);
return err;
}
开发者ID:archite,项目名称:kinomajs,代码行数:51,代码来源:FskHTTPServer.c
示例5: sFskNetInterfaceEnumerate
static FskErr sFskNetInterfaceEnumerate(FskNetInterfaceRecord **interfaceList)
{
FskErr err;
KplNetInterfaceRecord *kplInterfaceList;
*interfaceList = NULL;
err = KplNetInterfaceEnumerate(&kplInterfaceList);
BAIL_IF_ERR(err);
while (kplInterfaceList) {
FskNetInterfaceRecord *nir;
KplNetInterfaceRecord *next = kplInterfaceList->next;
err = FskMemPtrNew(sizeof(FskNetInterfaceRecord), (FskMemPtr*)&nir);
BAIL_IF_ERR(err);
nir->name = FskStrDoCopy(kplInterfaceList->name);
nir->ip = kplInterfaceList->ip;
FskMemMove(nir->MAC, kplInterfaceList->MAC, sizeof(nir->MAC));
nir->status = kplInterfaceList->status;
nir->netmask = kplInterfaceList->netmask;
FskListAppend((FskList*)interfaceList, nir);
FskMemPtrDispose(kplInterfaceList->name);
FskMemPtrDispose(kplInterfaceList);
kplInterfaceList = next;
}
bail:
return err;
}
开发者ID:kouis3940,项目名称:kinomajs,代码行数:34,代码来源:FskNetInterface.c
示例6: KprWebSocketEndpointStartClosingHandshake
static FskErr KprWebSocketEndpointStartClosingHandshake(KprWebSocketEndpoint self, UInt16 code, char *reason)
{
FskErr err = kFskErrNone;
char *payload = NULL;
UInt32 length = sizeof(UInt16);
self->state = kKprWebSocketStateClosing;
CALLBACK(closingCallback)(self, self->closeCode, self->closeReason, self->cleanClose, self->refcon);
length += FskStrLen(reason);
bailIfError(FskMemPtrNew(length, &payload));
*((UInt16 *) payload) = FskEndianU16_NtoB(code);
FskMemCopy(&payload[2], reason, length - sizeof(UInt16));
bailIfError(KprWebSocketEndpointSendRawFrame(self, kKprWebSocketOpcodeClose, payload, length));
self->closeWasSent = true;
bail:
if (payload) FskMemPtrDispose(payload);
if (err || (self->closeWasSent && self->closeWasReceived)) {
self->cleanClose = (err == kFskErrNone);
KprWebSocketEndpointDisconnect(self);
}
return err;
}
开发者ID:giapdangle,项目名称:kinomajs,代码行数:28,代码来源:kprWebSocketEndpoint.c
示例7: KprNetworkInterfaceCallback
VOID __stdcall KprNetworkInterfaceCallback(PVOID context, PMIB_IPINTERFACE_ROW interfaceRow, MIB_NOTIFICATION_TYPE notificationType)
{
int ip;
FskErr err = kFskErrNone;
IP_ADAPTER_INFO *adapters = NULL;
DWORD result;
DWORD size = 15000;
IP_ADAPTER_INFO *adapter;
IP_ADDR_STRING *address;
for (ip = 0; ip < 3; ip++) {
err = FskMemPtrNew(size, &adapters);
result = GetAdaptersInfo(adapters, &size);
if (ERROR_BUFFER_OVERFLOW == result) {
FskMemPtrDispose(adapters);
adapters = NULL;
}
else
break;
}
if (ERROR_SUCCESS == result) {
for (adapter = adapters ; NULL != adapter ; adapter = adapter->Next) {
for (address = &adapter->IpAddressList; address; address = address->Next) {
if (FskStrLen(address->IpAddress.String) == 0)
continue;
FskNetStringToIPandPort(address->IpAddress.String, &ip, NULL);
if (0x7f000001 != ip)
KprNetworkInterfaceMark(ip, adapter->AdapterName);
}
}
KprNetworkInterfaceSweep();
}
FskMemPtrDispose(adapters);
}
开发者ID:Kazu-zamasu,项目名称:kinomajs,代码行数:34,代码来源:kprNetworkInterface.c
示例8: KprWebSocketServerRequestNew
static FskErr KprWebSocketServerRequestNew(KprWebSocketServerRequest *it, KprWebSocketServer server, FskSocket skt) {
FskErr err = kFskErrNone;
KprWebSocketServerRequest request = NULL;
bailIfError(FskMemPtrNewClear(sizeof(KprWebSocketServerRequestRecord), &request));
request->server = server;
request->skt = skt;
skt = NULL;
FskNetSocketGetRemoteAddress(request->skt, (UInt32 *)&request->requesterAddress, &request->requesterPort);
FskNetSocketMakeNonblocking(request->skt);
bailIfError(FskHeaderStructNew(&request->requestHeaders));
bailIfError(FskHeaderStructNew(&request->responseHeaders));
request->out.size = 512;
bailIfError(FskMemPtrNew(request->out.size, &request->out.buffer));
FskThreadAddDataHandler(&request->dataHandler, (FskThreadDataSource)request->skt, (FskThreadDataReadyCallback)KprWebSocketServerRequestDoRead, true, false, request);
// request->state = kHTTPNewSession;
*it = request;
bail:
if (err) {
KprWebSocketServerRequestDispose(request);
FskNetSocketClose(skt);
}
return err;
}
开发者ID:dadongdong,项目名称:kinomajs,代码行数:31,代码来源:kprWebSocketServer.c
示例9: KprQuerySerialize
FskErr KprQuerySerialize(FskAssociativeArray array, char** it)
{
FskErr err = kFskErrNone;
FskAssociativeArrayIterator iterate = FskAssociativeArrayIteratorNew(array);
SInt32 length = 0;
char* p;
while (iterate) {
if (length)
length++;
length += FskStrLen(iterate->name);
length++;
length += FskStrLen(iterate->value);
}
length++;
FskAssociativeArrayIteratorDispose(iterate);
iterate = NULL;
bailIfError(FskMemPtrNew(length, it));
iterate = FskAssociativeArrayIteratorNew(array);
p = *it;
*p = 0;
while (iterate) {
if (*p)
*p++ = '&';
FskStrCopy(p, iterate->name);
p += FskStrLen(iterate->name);
*p++ = '=';
FskStrCopy(p, iterate->value);
p += FskStrLen(iterate->value);
}
*p = 0;
FskAssociativeArrayIteratorDispose(iterate);
bail:
return err;
}
开发者ID:giapdangle,项目名称:kinomajs,代码行数:34,代码来源:kprURL.c
示例10: KprAuthorityReverse
FskErr KprAuthorityReverse(char* id, char** di)
{
FskErr err = kFskErrNone;
char *p, *q;
SInt32 c = FskStrLen(id), i;
bailIfError(FskMemPtrNew(c + 1, di));
p = id + c;
q = *di;
i = 0;
while (c) {
c--;
p--;
if (*p == '.') {
p++;
FskMemCopy(q, p, i);
q += i;
*q++ = '.';
p--;
i = 0;
}
else
i++;
}
FskMemCopy(q, p, i);
q += i;
*q = 0;
bail:
return err;
}
开发者ID:giapdangle,项目名称:kinomajs,代码行数:29,代码来源:kprURL.c
示例11: FskAssociativeArrayElementSet
// ------------------------------------------------------------------------
void FskAssociativeArrayElementSet(FskAssociativeArray array, const char *name, const void *value, UInt32 valueSize, SInt32 valueType)
{
FskAssociativeArrayNameList list;
SInt32 nameLen = FskStrLen(name) + 1;
if (kFskStringType == valueType)
valueSize = FskStrLen((const char *)value) + 1;
else if (kFskBlobType == valueType)
;
else
valueSize = 0;
FskAssociativeArrayElementDispose(array, name);
if (kFskErrNone == FskMemPtrNew(sizeof(FskAssociativeArrayNameListRec) + nameLen + valueSize, &list)) {
unsigned char *d = list->data;
list->name = (char *)d;
FskMemMove(d, name, nameLen);
d += nameLen;
list->valueType = valueType;
list->valueSize = valueSize;
list->next = NULL;
if ((kFskStringType == valueType) || (kFskBlobType == valueType)) {
FskMemMove(d, value, valueSize);
list->value = (char *)d;
}
else
list->value = (char *)value;
FskListPrepend((FskList*)(void*)&array->arrayHead, (FskListElement)list);
}
}
开发者ID:Kazu-zamasu,项目名称:kinomajs,代码行数:35,代码来源:FskAssociativeArray.c
示例12: KplFileGetPathInfo
FskErr KplFileGetPathInfo(const char *rootpath, const char *filepath, KplFileInfo *itemInfo) {
int err;
STATTYPE statbuf;
char *fullpath;
err = FskMemPtrNew(FskStrLen(rootpath) + FskStrLen(filepath) + 2, (FskMemPtr *)&fullpath);
if (err) return err;
FskStrCopy(fullpath, rootpath);
FskStrCat(fullpath, "/");
FskStrCat(fullpath, filepath);
err = STAT(fullpath, &statbuf);
if (err == -1) {
err = errnoToFskErr(errno);
goto bail;
}
GetFileInfoFromStat(&statbuf, itemInfo);
bail:
FskMemPtrDispose(fullpath);
return err;
}
开发者ID:VzqzAc,项目名称:kinomajs,代码行数:25,代码来源:KplFilesLinux.c
示例13: KprWebSocketEndpointReadFrameMessage
static FskErr KprWebSocketEndpointReadFrameMessage(KprSocketReader reader, KprWebSocketEndpoint self)
{
FskErr err = kFskErrNone;
UInt32 length = self->read.length;
if (length > 0) {
if (self->read.message == NULL) {
err = FskMemPtrNew(length, &self->read.message);
if (err != kFskErrNone) return err;
}
err = KprSocketReaderReadBytes(reader, self->read.message, length);
if (err != kFskErrNone) return err;
if (self->read.mask) {
KprWebSocketMask((UInt8 *) self->read.message, length, self->read.maskData);
}
}
KprSocketReaderSetState(reader, kKprWebSocketEndpoint_onFrameOpcode);
if ((self->needMaskedFrame && !self->read.mask)
|| (self->needNonMaskedFrame && self->read.mask)) {
self->ignoreFurtherFrame = true;
bailIfError(kFskErrBadData);
}
err = KprWebSocketEndpointHandleFrame(self, self->read.opcode, self->read.message, length);
bail:
FskMemPtrDisposeAt(&self->read.message);
return err;
}
开发者ID:giapdangle,项目名称:kinomajs,代码行数:34,代码来源:kprWebSocketEndpoint.c
示例14: FillJaggyPolygonContours
static FskErr
FillJaggyPolygonContours(
UInt32 nContours,
const UInt32 *nPts,
const FskFixedPoint2D *pts,
const FskColorSource *colorSource,
SInt32 fillRule,
const FskFixedMatrix3x2 *M,
FskConstRectangle clipRect,
FskBitmap dstBM
)
{
FskRectangleRecord dstRect;
LinkedEdge edges[MAX_EDGES], *pEdges = edges; /* Small polygons use auto edges, large ones need to be alloc'ed */
UInt32 numEdges, totPts;
FskSpan span;
FskErr err = kFskErrNone;
SInt32 n;
const UInt32 *np;
LinkedEdge *pe;
static FskInitSpanProc initProcs[] = {
FskInitSolidColorSpan,
FskInitLinearGradientSpan,
FskInitRadialGradientSpan,
FskInitTextureSpan,
NULL /* Procedure span is not yet implemented */
};
FskInitSpanProc initSpan;
if (clipRect == NULL) dstRect = dstBM->bounds;
else if (!FskRectangleIntersect(&dstBM->bounds, clipRect, &dstRect)) return kFskErrNothingRendered;
for (n = nContours, np = nPts, totPts = 0; n--; )
totPts += *np++;
FskInitSpan(&span, dstBM, sizeof(LinkedEdge)); /* Generic span init */
initSpan = initProcs[((n = colorSource->type) <= kFskColorSourceTypeMax) ? n : 0];
if ((err = (*initSpan)(&span, dstBM, M, 0, colorSource)) != kFskErrNone) /* Specialized span init - this may bump up the edge size */
return err;
span.edgeBytes = (span.edgeBytes + 3) & ~3; /* Ceil up to multiple of 4 bytes */
if ( CANT_USE_AUTO_EDGES(totPts) /* Either small enough for auto storage ... */
&& (err = (FskMemPtrNew(totPts * CLIP_MULTIPLIER * sizeof(LinkedEdge), (FskMemPtr*)(void*)(&pEdges))) != kFskErrNone) /* ... or we can allocate memory */
)
return err; /* Polygon is too big to render */
for (numEdges = 0, pe = pEdges; nContours--; pts += *nPts++, numEdges += n, pe += n)
BAIL_IF_NEGATIVE(n = TransformClipAndMakeEdges(*nPts, pts, M, &dstRect, &span, pe), err, kFskErrMemFull);
BAIL_IF_FALSE(numEdges >= 2, err, kFskErrNothingRendered);
err = ScanConvertLinkedEdges(numEdges, pEdges, fillRule, &span);
bail:
if (pEdges != edges)
FskMemPtrDispose(pEdges); /* Deallocate big polygon edges */
if ((span.disposeSpanData != NULL) && (span.spanData != NULL))
span.disposeSpanData(span.spanData);
return err;
}
开发者ID:kouis3940,项目名称:kinomajs,代码行数:59,代码来源:FskPolygon.c
示例15: loadGrammar
FskErr loadGrammar(const char *xsbPath, xsGrammar *theGrammar)
{
FskErr err;
FskFile fref = NULL;
UInt32 atom[2];
err = FskFileOpen(xsbPath, kFskFilePermissionReadOnly, &fref);
if (err) goto bail;
err = FskFileRead(fref, sizeof(atom), atom, NULL);
if (err) goto bail;
atom[0] = FskEndianU32_BtoN(atom[0]);
atom[1] = FskEndianU32_BtoN(atom[1]);
if (atom[1] == 'XS11') {
SInt32 totalSize = (SInt32)atom[0] - sizeof(atom);
while (totalSize > 0) {
UInt32 blockSize;
char *block;
err = FskFileRead(fref, sizeof(atom), atom, NULL);
if (err) break;
atom[0] = FskEndianU32_BtoN(atom[0]);
atom[1] = FskEndianU32_BtoN(atom[1]);
totalSize -= atom[0];
blockSize = atom[0] - sizeof(atom);
err = FskMemPtrNew(blockSize, &block);
if (err) break;
err = FskFileRead(fref, blockSize, block, NULL);
if (err) break;
switch (atom[1]) {
case 'SYMB':
theGrammar->symbols = block;
theGrammar->symbolsSize = blockSize;
break;
case 'CODE':
theGrammar->code = block;
theGrammar->codeSize = blockSize;
break;
default:
FskMemPtrDispose(block);
err = kFskErrBadData;
break;
}
}
}
else
err = kFskErrBadData;
bail:
FskFileClose(fref);
return err;
}
开发者ID:giapdangle,项目名称:kinomajs,代码行数:59,代码来源:FskECMAScript.c
示例16: KprPathToURL
FskErr KprPathToURL(char* path, char** result)
{
FskErr err = kFskErrNone;
unsigned char* src;
SInt32 size;
unsigned char c;
unsigned char* dst;
src = (unsigned char*)path;
#if TARGET_OS_WIN32
if ((path[0] == '/') && (path[1] == '/'))
size = 5;
else if (path[1] == ':')
size = 8;
else
return kFskErrInvalidParameter;
#else
if (path[0] == '/')
size = 7;
else
return kFskErrInvalidParameter;
#endif
while ((c = *src++)) {
if ((c < 128) && (gxURIReservedAndUnescapedSet[(int)c]))
size += 1;
else
size += 3;
}
size += 1;
bailIfError(FskMemPtrNew(size, result));
src = (unsigned char*)path;
dst = (unsigned char*)*result;
#if TARGET_OS_WIN32
if ((path[0] == '/') && (path[1] == '/')) {
FskStrCopy(*result, "file:");
dst += 5;
}
else if (path[1] == ':') {
FskStrCopy(*result, "file:///");
dst += 8;
}
#else
FskStrCopy(*result, "file://");
dst += 7;
#endif
while ((c = *src++)) {
if ((c < 128) && (gxURIReservedAndUnescapedSet[(int)c]))
*dst++ = c;
else {
*dst++ = '%';
*dst++ = gxURIHexa[c >> 4];
*dst++ = gxURIHexa[c & 15];
}
}
*dst = 0;
bail:
return err;
}
开发者ID:giapdangle,项目名称:kinomajs,代码行数:58,代码来源:kprURL.c
示例17: kcl_z_init
static char *
kcl_z_init(xsMachine *the, z_t **rp)
{
bn_context_t *ctx;
FskErr ferr;
if ((ferr = FskMemPtrNew(sizeof(z_t), (FskMemPtr *)rp)) != kFskErrNone)
return fskErrorToString(ferr);
if ((ferr = FskMemPtrNew(sizeof(bn_context_t), (FskMemPtr *)&ctx)) != kFskErrNone) {
FskMemPtrDispose(*rp);
return fskErrorToString(ferr);
}
bn_init_context(the, ctx);
(*rp)->_z_code = &zFuncs;
(*rp)->z_data = ctx;
return(NULL);
}
开发者ID:Kazu-zamasu,项目名称:kinomajs,代码行数:18,代码来源:arith_kcl.c
示例18: fxLoadModuleJSB
void fxLoadModuleJSB(txMachine* the, txString path, txID moduleID)
{
FskErr err = kFskErrNone;
txScript* script = NULL;
FskFile fref = NULL;
Atom atom;
bailIfError(FskMemPtrNewClear(sizeof(txScript), &script));
bailIfError(FskFileOpen(path, kFskFilePermissionReadOnly, &fref));
bailIfError(fxLoadModuleJSBAtom(the, fref, &atom));
bailAssert(atom.atomType == XS_ATOM_BINARY);
bailIfError(fxLoadModuleJSBAtom(the, fref, &atom));
bailAssert(atom.atomType == XS_ATOM_VERSION);
bailIfError(FskFileRead(fref, sizeof(script->version), script->version, NULL));
bailAssert(script->version[0] == XS_MAJOR_VERSION);
bailAssert(script->version[1] == XS_MINOR_VERSION);
bailAssert(script->version[2] == XS_PATCH_VERSION);
bailAssert(script->version[3] != -1);
bailIfError(fxLoadModuleJSBAtom(the, fref, &atom));
bailAssert(atom.atomType == XS_ATOM_SYMBOLS);
script->symbolsSize = atom.atomSize - sizeof(atom);
bailIfError(FskMemPtrNew(script->symbolsSize, &script->symbolsBuffer));
bailIfError(FskFileRead(fref, script->symbolsSize, script->symbolsBuffer, NULL));
bailIfError(fxLoadModuleJSBAtom(the, fref, &atom));
bailAssert(atom.atomType == XS_ATOM_CODE);
script->codeSize = atom.atomSize - sizeof(atom);
bailIfError(FskMemPtrNew(script->codeSize, &script->codeBuffer));
bailIfError(FskFileRead(fref, script->codeSize, script->codeBuffer, NULL));
bail:
if (fref)
FskFileClose(fref);
if (err) {
if (script) {
fxDeleteScript(script);
script = NULL;
}
}
fxResolveModule(the, moduleID, script, NULL, NULL);
}
开发者ID:dadongdong,项目名称:kinomajs,代码行数:43,代码来源:xs6Host.c
示例19: kcl_cint_init
static char *
kcl_cint_init(cint_t **rp)
{
FskErr ferr;
if ((ferr = FskMemPtrNew(sizeof(cint_t), (FskMemPtr *)rp)) != kFskErrNone)
return fskErrorToString(ferr);
(*rp)->cint_data = NULL; /* this = NaN */
(*rp)->_cint_code = &cintFuncs;
return(NULL);
}
开发者ID:Kazu-zamasu,项目名称:kinomajs,代码行数:11,代码来源:arith_kcl.c
示例20: fxLink
void fxLink(txMachine* the, xsGrammar* theGrammar)
{
txScript* script = NULL;
FskErr err = kFskErrNone;
err = FskMemPtrNewClear(sizeof(txScript), &script);
if (err) goto bail;
err = FskMemPtrNew(theGrammar->symbolsSize, &script->symbolsBuffer);
if (err) goto bail;
err = FskMemPtrNew(theGrammar->codeSize, &script->codeBuffer);
if (err) goto bail;
FskMemCopy(script->symbolsBuffer, theGrammar->symbols, theGrammar->symbolsSize);
script->symbolsSize = theGrammar->symbolsSize;
FskMemCopy(script->codeBuffer, theGrammar->code, theGrammar->codeSize);
script->codeSize = theGrammar->codeSize;
script->callback = theGrammar->callback;
fxRunScript(the, script, C_NULL, C_NULL, C_NULL, C_NULL);
script = C_NULL;
bail:
fxDeleteScript(script);
return;
}
开发者ID:dadongdong,项目名称:kinomajs,代码行数:21,代码来源:xs6Host.c
注:本文中的FskMemPtrNew函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论