void* ObjectStruct::cPointerValue() { if(NULL == charPtr()) sysError("invalid cPointer","cPointerValue"); void* l; int s = sizeof(void*); memcpy((char *) &l, charPtr(), (int) sizeof(void*)); return l; }
double ObjectStruct::floatValue() { double d; memcpy((char *) &d, charPtr(), (int) sizeof(double)); return d; }
void Program::saveBinary() { if (_hash.empty()) return; // don't save binary, expect the user has explicitly requested so if (util::envVarValue("SKELCL_SAVE_BINARY") != "YES") return; for (auto& devicePtr : globalDeviceList) { try { auto size = _clPrograms[ devicePtr->id()].getInfo<CL_PROGRAM_BINARY_SIZES>(); ASSERT(size.size() == 1); std::unique_ptr<char[]> charPtr(new char[size.front()]); std::vector<char *> binary{ charPtr.get() }; _clPrograms[devicePtr->id()].getInfo(CL_PROGRAM_BINARIES, &binary); std::ofstream outfile(binaryFilename(_hash, devicePtr), std::ios_base::out | std::ios_base::trunc | std::ios_base::binary); outfile.write(binary.front(), static_cast<long>(size.front())); LOG_DEBUG_INFO("Saved binary for device ", devicePtr->id(), " to file ", binaryFilename(_hash, devicePtr)); } catch (cl::Error err) { ABORT_WITH_ERROR(err); } } }
object allocStr(register const char *str) { register object newSym; newSym = allocByte(1 + strlen(str)); strcpy(charPtr(newSym), str); return (newSym); }
size_t TEditor::getMousePtr( TPoint m ) { TPoint mouse = makeLocal( m ); mouse.x = max(0, min(mouse.x, size.x - 1)); mouse.y = max(0, min(mouse.y, size.y - 1)); return charPtr(lineMove(drawPtr, mouse.y + delta.y - drawLine), mouse.x + delta.x); }
int ObjectStruct::intValue() { int d; if(this == &objectRef(nilobj)) return 0; memcpy((char *) &d, charPtr(), (int) sizeof(int)); return d; }
object sysPrimitive(int number, object * arguments) { object returnedObject; /* someday there will be more here */ switch (number - 150) { case 0: /* do a system() call */ returnedObject = newInteger(system(charPtr(arguments[0]))); break; default: sysError("unknown primitive", "sysPrimitive"); } return (returnedObject); }
ushort TEditor::lineMove( ushort p, int count ) { ushort i = p; p = lineStart(p); int pos = charPos(p, i); while( count != 0 ) { i = p; if( count < 0 ) { p = prevLine(p); count++; } else { p = nextLine(p); count--; } } if( p != i ) p = charPtr(p, pos); return p; }
/* readClass reads a class method description */ static void readMethods(FILE *fd, boolean printit) { object classObj, methTable, theMethod, selector; # define LINEBUFFERSIZE 512 char *cp, *eoftest, lineBuffer[LINEBUFFERSIZE]; if (nextToken() != nameconst) sysError("missing name", "following Method keyword"); classObj = findClass(tokenString); setInstanceVariables(classObj); if (printit) cp = charPtr(basicAt(classObj, nameInClass)); /* now find or create a method table */ methTable = basicAt(classObj, methodsInClass); if (methTable == nilobj) /* must make */ { methTable = newDictionary(MethodTableSize); basicAtPut(classObj, methodsInClass, methTable); } /* now go read the methods */ do { if (lineBuffer[0] == '|') /* get any left over text */ strcpy(textBuffer, &lineBuffer[1]); else textBuffer[0] = '\0'; while ((eoftest = fgets(lineBuffer, LINEBUFFERSIZE, fd)) != NULL) { if ((lineBuffer[0] == '|') || (lineBuffer[0] == ']')) break; strcat(textBuffer, lineBuffer); } if (eoftest == NULL) { sysError("unexpected end of file", "while reading method"); break; } /* now we have a method */ theMethod = newMethod(); if (parse(theMethod, textBuffer, savetext)) { selector = basicAt(theMethod, messageInMethod); basicAtPut(theMethod, methodClassInMethod, classObj); if (printit) dspMethod(cp, charPtr(selector)); nameTableInsert(methTable, (int) selector, selector, theMethod); } else { /* get rid of unwanted method */ incr(theMethod); decr(theMethod); givepause(); } } while (lineBuffer[0] != ']'); }