/*--------------------------------------------------------------------------*/ int sci_getcallbackobject(char *fname, unsigned long fname_len) { SciErr sciErr; int* piAddrpObjUID = NULL; int nbRow = 0; int nbCol = 0; char** pObjUID = NULL; unsigned long graphicHandle = 0; CheckInputArgument(pvApiCtx, 1, 1); CheckOutputArgument(pvApiCtx, 0, 1); if ((checkInputArgumentType(pvApiCtx, 1, sci_strings))) { sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrpObjUID); if (sciErr.iErr) { printError(&sciErr, 0); return 1; } // Retrieve a matrix of string at position 1. if (getAllocatedMatrixOfString(pvApiCtx, piAddrpObjUID, &nbRow, &nbCol, &pObjUID)) { Scierror(202, _("%s: Wrong type for argument #%d: String matrix expected.\n"), fname, 1); return 1; } if (nbCol != 1 || nbRow == 0) { Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), fname, 1); return FALSE; } } else { Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 1); return FALSE; } graphicHandle = getHandle(pObjUID[0]); freeAllocatedMatrixOfString(nbRow, nbCol, pObjUID); /* Create return variable */ if (graphicHandle == 0) /* Non-existing object --> return [] */ { double* stkAdr = NULL; nbRow = 0; nbCol = 0; sciErr = allocMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, nbRow, nbCol, &stkAdr); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(999, _("%s: Memory allocation error.\n"), fname); return 1; } } else /* Return the handle */ { long long* stkAdr = NULL; nbRow = 1; nbCol = 1; sciErr = allocMatrixOfHandle(pvApiCtx, nbInputArgument(pvApiCtx) + 1, nbRow, nbCol, &stkAdr); if (sciErr.iErr) { printError(&sciErr, 0); Scierror(999, _("%s: Memory allocation error.\n"), fname); return 1; } *stkAdr = (long long)graphicHandle; } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; ReturnArguments(pvApiCtx); return TRUE; }
void mxLineEdit::setMaxLength (int max) { SendMessage ((HWND) getHandle (), EM_LIMITTEXT, (WPARAM) max, 0L); }
int mxExpressionTray::handleEvent (mxEvent *event) { MDLCACHE_CRITICAL_SECTION_( g_pMDLCache ); int iret = 0; if ( HandleToolEvent( event ) ) { return iret; } switch ( event->event ) { case mxEvent::Action: { iret = 1; switch ( event->action ) { default: iret = 0; break; case IDC_EXPRESSIONCLASS: { int index = g_pExpressionClass->getSelectedIndex(); if ( index >= 0 ) { CExpClass *current = expressions->GetClass( index ); if ( current ) { // Switch classname expressions->ActivateExpressionClass( current ); current->SelectExpression( 0 ); } } } break; case IDC_CONTEXT_NEWEXP: g_pFlexPanel->NewExpression(); break; case IDC_CONTEXT_EDITEXP: if ( m_nClickedCell != -1 ) { g_pFlexPanel->EditExpression(); } break; case IDC_CONTEXT_REVERT: if ( m_nClickedCell != -1 ) { g_pFlexPanel->RevertExpression( m_nClickedCell ); } break; case IDC_CONTEXT_SAVEEXP: if ( m_nClickedCell != -1 ) { g_pFlexPanel->SaveExpression( m_nClickedCell ); } break; case IDC_CONTEXT_DELETEXP: if ( m_nClickedCell != -1 ) { g_pControlPanel->DeleteExpression( m_nClickedCell ); } break; case IDC_TRAYSCROLL: { if (event->modifiers == SB_THUMBTRACK) { int offset = event->height; slScrollbar->setValue( offset ); m_nTopOffset = offset; redraw(); } else if ( event->modifiers == SB_PAGEUP ) { int offset = slScrollbar->getValue(); offset -= m_nGranularity; offset = max( offset, slScrollbar->getMinValue() ); slScrollbar->setValue( offset ); InvalidateRect( (HWND)slScrollbar->getHandle(), NULL, TRUE ); m_nTopOffset = offset; redraw(); } else if ( event->modifiers == SB_PAGEDOWN ) { int offset = slScrollbar->getValue(); offset += m_nGranularity; offset = min( offset, slScrollbar->getMaxValue() ); slScrollbar->setValue( offset ); InvalidateRect( (HWND)slScrollbar->getHandle(), NULL, TRUE ); m_nTopOffset = offset; redraw(); } } break; case IDC_AB: { AB(); } break; case IDC_THUMBNAIL_INCREASE: { ThumbnailIncrease(); } break; case IDC_THUMBNAIL_DECREASE: { ThumbnailDecrease(); } break; case IDC_CONTEXT_CREATEBITMAP: { if ( m_nClickedCell >= 0 ) { CExpClass *active = expressions->GetActiveClass(); if ( active ) { CExpression *exp = active->GetExpression( m_nClickedCell ); if ( exp ) { active->SelectExpression( m_nClickedCell ); exp->CreateNewBitmap( models->GetActiveModelIndex() ); redraw(); } } } } break; } break; } case mxEvent::MouseDown: { if ( !( event->buttons & mxEvent::MouseRightButton ) ) { // Figure out cell # int cell = GetCellUnderPosition( event->x, event->y ); CExpClass *active = expressions->GetActiveClass(); if ( active ) { if ( cell == m_nCurCell && cell >= 0 && cell < active->GetNumExpressions() ) { mxETButton *btn = GetItemUnderCursor( event->x, event->y ); if ( btn && btn->m_fnCallback ) { (this->*(btn->m_fnCallback))( cell ); return iret; } } if ( cell >= 0 && cell < active->GetNumExpressions() ) { active->SelectExpression( cell, event->modifiers & mxEvent::KeyShift ? false : true ); int cx, cy, cw, ch; if ( ComputeRect( cell, cx, cy, cw, ch ) ) { m_bDragging = true; m_nDragCell = cell; m_nXStart = (short)event->x; m_nYStart = (short)event->y; m_rcFocus.left = cx; m_rcFocus.top = cy; m_rcFocus.right = cx + cw; m_rcFocus.bottom = cy + ch - m_nDescriptionHeight; POINT pt; pt.x = pt.y = 0; ClientToScreen( (HWND)getHandle(), &pt ); OffsetRect( &m_rcFocus, pt.x, pt.y ); m_rcOrig = m_rcFocus; DrawFocusRect(); } } else { Deselect(); active->DeselectExpression(); redraw(); } } } iret = 1; } break; case mxEvent::MouseDrag: { if ( m_bDragging ) { // Draw drag line of some kind DrawFocusRect(); // update pos m_rcFocus = m_rcOrig; OffsetRect( &m_rcFocus, ( (short)event->x - m_nXStart ), ( (short)event->y - m_nYStart ) ); DrawFocusRect(); } iret = 1; } break; case mxEvent::MouseUp: { iret = 1; if ( event->buttons & mxEvent::MouseRightButton ) { SetClickedCell( GetCellUnderPosition( (short)event->x, (short)event->y ) ); ShowRightClickMenu( (short)event->x, (short)event->y ); return iret; } int cell = GetCellUnderPosition( event->x, event->y ); CExpClass *active = expressions->GetActiveClass(); if ( m_bDragging ) { DrawFocusRect(); m_bDragging = false; // See if we let go on top of the choreo view if ( active ) { // Convert x, y to screen space POINT pt; pt.x = (short)event->x; pt.y = (short)event->y; ClientToScreen( (HWND)getHandle(), &pt ); HWND maybeTool = WindowFromPoint( pt ); // Now tell choreo view CExpression *exp = active->GetExpression( m_nDragCell ); if ( exp && maybeTool ) { if ( IsWindowOrChild( g_pChoreoView, maybeTool ) ) { if ( g_pChoreoView->CreateExpressionEvent( pt.x, pt.y, active, exp ) ) { return iret; } } if ( IsWindowOrChild( g_pExpressionTool, maybeTool ) ) { if ( g_pExpressionTool->SetFlexAnimationTrackFromExpression( pt.x, pt.y, active, exp ) ) { return iret; } } } } } if ( active ) { // Over a new cell if ( cell >= 0 && cell < active->GetNumExpressions() && cell != m_nCurCell && m_nCurCell != -1 ) { // Swap cells CExpression *exp = active->GetExpression( m_nCurCell ); if ( exp ) { active->SwapExpressionOrder( m_nCurCell, cell ); active->SetDirty( true ); active->SelectExpression( cell ); } } } } break; case mxEvent::Size: { int width = w2(); int ch = GetCaptionHeight(); g_pExpressionClass->setBounds( 5, 5 + ch, width - 120, 20 ); m_pABButton->setBounds( width - 60, 4 + ch, 60, 16 ); m_pThumbnailIncreaseButton->setBounds( width - 60 - 40, 4 + ch, 16, 16 ); m_pThumbnailDecreaseButton->setBounds( width - 60 - 20, 4 + ch, 16, 16 ); m_nTopOffset = 0; RepositionSlider(); redraw(); iret = 1; } break; case mxEvent::MouseWheeled: { // Figure out cell # POINT pt; pt.x = event->x; pt.y = event->y; ScreenToClient( (HWND)getHandle(), &pt ); if ( event->height < 0 ) { m_nTopOffset = min( m_nTopOffset + 10, slScrollbar->getMaxValue() ); } else { m_nTopOffset = max( m_nTopOffset - 10, 0 ); } RepositionSlider(); redraw(); iret = 1; } break; }; if ( iret ) { SetActiveTool( this ); } return iret; }
void mxRadioButton::setChecked (bool b) { SendMessage ((HWND) getHandle (), BM_SETCHECK, (WPARAM) b ? BST_CHECKED:BST_UNCHECKED, 0L); }
void mxLineEdit::clear() { SendMessage( (HWND)getHandle(), WM_SETTEXT, (WPARAM)0, (LPARAM)"" ); }
bool WindowControl::FindThis(HWND controlHandle) { setHandle(controlHandle); return getHandle() != NULL; }
Socket::Status TcpSocket::connect(const IpAddress& remoteAddress, unsigned short remotePort, Time timeout) { // Create the internal socket if it doesn't exist create(); // Create the remote address sockaddr_in address = priv::SocketImpl::createAddress(remoteAddress.toInteger(), remotePort); if (timeout <= Time::Zero) { // ----- We're not using a timeout: just try to connect ----- // Connect the socket if (::connect(getHandle(), reinterpret_cast<sockaddr*>(&address), sizeof(address)) == -1) return priv::SocketImpl::getErrorStatus(); // Connection succeeded return Done; } else { // ----- We're using a timeout: we'll need a few tricks to make it work ----- // Save the previous blocking state bool blocking = isBlocking(); // Switch to non-blocking to enable our connection timeout if (blocking) setBlocking(false); // Try to connect to the remote address if (::connect(getHandle(), reinterpret_cast<sockaddr*>(&address), sizeof(address)) >= 0) { // We got instantly connected! (it may no happen a lot...) return Done; } // Get the error status Status status = priv::SocketImpl::getErrorStatus(); // If we were in non-blocking mode, return immediatly if (!blocking) return status; // Otherwise, wait until something happens to our socket (success, timeout or error) if (status == Socket::NotReady) { // Setup the selector fd_set selector; FD_ZERO(&selector); FD_SET(getHandle(), &selector); // Setup the timeout timeval time; time.tv_sec = static_cast<long>(timeout.asMicroseconds() / 1000000); time.tv_usec = static_cast<long>(timeout.asMicroseconds() % 1000000); // Wait for something to write on our socket (which means that the connection request has returned) if (select(static_cast<int>(getHandle() + 1), NULL, &selector, NULL, &time) > 0) { // At this point the connection may have been either accepted or refused. // To know whether it's a success or a failure, we must check the address of the connected peer if (getRemoteAddress() != sf::IpAddress::None) { // Connection accepted status = Done; } else { // Connection refused status = priv::SocketImpl::getErrorStatus(); } } else { // Failed to connect before timeout is over status = priv::SocketImpl::getErrorStatus(); } } // Switch back to blocking mode setBlocking(true); return status; } }
void ListViewControl::RemoveRow(int rowNum) { ListView_DeleteItem(getHandle(), rowNum); }
void ListViewControl::EnableFullRowSelect() { if ( getHandle() != NULL ) SendMessage(getHandle(), LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT); }
int ListViewControl::GetNumColumns() { HWND header = (HWND)SendMessage(getHandle(), LVM_GETHEADER, 0, 0); return (int)SendMessage(header, HDM_GETITEMCOUNT, 0, 0); }
bool ListViewControl::SetColumnWidth(int column, int width) { return ListView_SetColumnWidth(getHandle(), column, width) == TRUE; }
int ListViewControl::GetColumnWidth(int column) { return SendMessage(getHandle(), LVM_GETCOLUMNWIDTH, column, 0); }
void ListViewControl::RedrawHeader() { HWND hHeader = (HWND)SendMessage(getHandle(), LVM_GETHEADER, 0, 0); RedrawWindow(hHeader, NULL, NULL, RDW_INVALIDATE); }
bool ListViewControl::DeleteAllItems() { return SendMessage(getHandle(), LVM_DELETEALLITEMS, 0, 0) == TRUE; }
void Connection::parsePacket(const boost::system::error_code& error) { m_connectionLock.lock(); m_readTimer.cancel(); if (error) { handleReadError(error); } if (m_connectionState != CONNECTION_STATE_OPEN || m_readError) { closeConnection(); m_connectionLock.unlock(); return; } uint32_t timePassed = std::max<uint32_t>(1, (time(nullptr) - m_timeConnected) + 1); if ((++m_packetsSent / timePassed) > (uint32_t)g_config.getNumber(ConfigManager::MAX_PACKETS_PER_SECOND)) { std::cout << convertIPToString(getIP()) << " disconnected for exceeding packet per second limit." << std::endl; closeConnection(); m_connectionLock.unlock(); return; } if (timePassed > 2) { m_timeConnected = time(nullptr); m_packetsSent = 0; } //Check packet checksum uint32_t checksum; int32_t len = m_msg.getMessageLength() - m_msg.getReadPos() - 4; if (len > 0) { checksum = adlerChecksum(m_msg.getBuffer() + m_msg.getReadPos() + 4, len); } else { checksum = 0; } uint32_t recvChecksum = m_msg.get<uint32_t>(); if (recvChecksum != checksum) { // it might not have been the checksum, step back m_msg.SkipBytes(-4); } if (!m_receivedFirst) { // First message received m_receivedFirst = true; if (!m_protocol) { // Game protocol has already been created at this point m_protocol = m_service_port->make_protocol(recvChecksum == checksum, m_msg); if (!m_protocol) { closeConnection(); m_connectionLock.unlock(); return; } m_protocol->setConnection(shared_from_this()); } else { m_msg.GetByte(); // Skip protocol ID } m_protocol->onRecvFirstMessage(m_msg); } else { m_protocol->onRecvMessage(m_msg); // Send the packet to the current protocol } try { m_readTimer.expires_from_now(boost::posix_time::seconds(Connection::read_timeout)); m_readTimer.async_wait( std::bind(&Connection::handleReadTimeout, std::weak_ptr<Connection>(shared_from_this()), std::placeholders::_1)); // Wait to the next packet boost::asio::async_read(getHandle(), boost::asio::buffer(m_msg.getBuffer(), NetworkMessage::header_length), std::bind(&Connection::parseHeader, shared_from_this(), std::placeholders::_1)); } catch (boost::system::system_error& e) { if (m_logError) { std::cout << "[Network error - Connection::parsePacket] " << e.what() << std::endl; m_logError = false; } closeConnection(); } m_connectionLock.unlock(); }
JNIEXPORT jint JNICALL Java_net_rubygrapefruit_platform_internal_jni_WindowsConsoleFunctions_isConsole(JNIEnv *env, jclass target, jint output, jobject result) { CONSOLE_SCREEN_BUFFER_INFO console_info; HANDLE handle = getHandle(env, output, result); if (handle == NULL) { return CONSOLE_NONE; } #ifndef WINDOWS_MIN // Cygwin/msys console detection, uses an API not available on older Windows versions // Look for a named pipe at the output or input handle, with a specific name: // Cygwin: \cygwin-xxxx-from-master (stdin) // Cygwin: \cygwin-xxxx-to-master (stdout/stderr) // Msys: \msys-xxxx-from-master (stdin) // Msys: \msys-xxxx-to-master (stdout/stderr) DWORD type = GetFileType(handle); if (type == FILE_TYPE_PIPE) { size_t size = sizeof(_FILE_NAME_INFO) + MAX_PATH*sizeof(WCHAR); _FILE_NAME_INFO* name_info = (_FILE_NAME_INFO*)malloc(size); if (GetFileInformationByHandleEx(handle, FileNameInfo, name_info, size) == 0) { mark_failed_with_errno(env, "could not get handle file information", result); free(name_info); return CONSOLE_NONE; } ((char*)name_info->FileName)[name_info->FileNameLength] = 0; int consoleType = CONSOLE_NONE; if (wcsstr(name_info->FileName, L"\\cygwin-") == name_info->FileName || wcsstr(name_info->FileName, L"\\msys-") == name_info->FileName) { if (output == STDIN_DESCRIPTOR) { if (wcsstr(name_info->FileName, L"-from-master") != NULL) { consoleType = CONSOLE_CYGWIN; } } else { if (wcsstr(name_info->FileName, L"-to-master") != NULL) { consoleType = CONSOLE_CYGWIN; } } } free(name_info); return consoleType; } #endif // Else, no Cygwin console detection if (output == STDIN_DESCRIPTOR) { DWORD mode; if (!GetConsoleMode(handle, &mode)) { if (GetLastError() != ERROR_INVALID_HANDLE) { mark_failed_with_errno(env, "could not get console buffer", result); } return CONSOLE_NONE; } return CONSOLE_WINDOWS; } if (!GetConsoleScreenBufferInfo(handle, &console_info)) { if (GetLastError() != ERROR_INVALID_HANDLE) { mark_failed_with_errno(env, "could not get console buffer", result); } return CONSOLE_NONE; } return CONSOLE_WINDOWS; }
bool WindowControl::FindThis(HWND hParent, u32 controlId) { setHandle(GetDlgItem(hParent, controlId)); return getHandle() != NULL; }
Peer::~Peer() { VLOG(5) << "{" << static_cast< void * >(this) << "}" << " flags=" << std::hex << getHandle()->flags << " UV_CLOSING " << (getHandle()->flags & 0x00001) << " UV_CLOSED " << (getHandle()->flags & 0x00002) << " UV_STREAM_READING " << (getHandle()->flags & 0x00004) << " UV_STREAM_SHUTTING " << (getHandle()->flags & 0x00008) << " UV_STREAM_SHUT " << (getHandle()->flags & 0x00010) << " UV_STREAM_READABLE " << (getHandle()->flags & 0x00020) << " UV_STREAM_WRITABLE " << (getHandle()->flags & 0x00040) << " UV_STREAM_BLOCKING " << (getHandle()->flags & 0x00080) << " UV_STREAM_READ_PARTIAL " << (getHandle()->flags & 0x00100) << " UV_STREAM_READ_EOF " << (getHandle()->flags & 0x00200) << " UV_TCP_NODELAY " << (getHandle()->flags & 0x00400) << " UV_TCP_KEEPALIVE " << (getHandle()->flags & 0x00800) << " UV_TCP_SINGLE_ACCEPT " << (getHandle()->flags & 0x01000) << " UV_HANDLE_IPV6 " << (getHandle()->flags & 0x10000) ; assert(!uvRefCnt_); assert(!uv_is_active(reinterpret_cast< uv_handle_t * >(getHandle()))); getLoopData()->down(); #ifdef COMMS_DEBUG_OBJECT_COUNT --counter; #endif }
/* * Class: org_tritonus_lowlevel_cdda_cdparanoia_Cdparanoia * Method: readTOC * Signature: ([I[I[I[I[Z[Z[Z[I)I */ JNIEXPORT jint JNICALL Java_org_tritonus_lowlevel_cdda_cdparanoia_Cdparanoia_readTOC (JNIEnv* env, jobject obj, jintArray anValues, jintArray anStartFrame, jintArray anLength, jintArray anType, jbooleanArray abAudio, jbooleanArray abCopy, jbooleanArray abPre, jintArray anChannels) { handle_t* handle; cdrom_drive* cdrom; int nFirstTrack; int nLastTrack; jint* pnValues; jint* pnStartFrame; jint* pnLength; jint* pnType; jboolean* pbAudio; jboolean* pbCopy; jboolean* pbPre; jint* pnChannels; int nTrack; if (debug_flag) { fprintf(debug_file, "Java_org_tritonus_lowlevel_cdda_cdparanoia_Cdparanoia_readTOC(): begin\n"); } handle = getHandle(env, obj); cdrom = handle->drive; checkArrayLength(env, anValues, 2); pnValues = (*env)->GetIntArrayElements(env, anValues, NULL); if (pnValues == NULL) { throwRuntimeException(env, "GetIntArrayElements failed"); } // TODO: check if first track is guaranteed to be 1 pnValues[0] = 1; pnValues[1] = cdda_tracks(cdrom); nFirstTrack = 1; nLastTrack = cdda_tracks(cdrom); (*env)->ReleaseIntArrayElements(env, anValues, pnValues, 0); checkArrayLength(env, anStartFrame, 100); pnStartFrame = (*env)->GetIntArrayElements(env, anStartFrame, NULL); if (pnStartFrame == NULL) { throwRuntimeException(env, "GetIntArrayElements failed"); } checkArrayLength(env, anLength, 100); pnLength = (*env)->GetIntArrayElements(env, anLength, NULL); if (pnLength == NULL) { throwRuntimeException(env, "GetIntArrayElements failed"); } checkArrayLength(env, anType, 100); pnType = (*env)->GetIntArrayElements(env, anType, NULL); if (pnType == NULL) { throwRuntimeException(env, "GetIntArrayElements failed"); } checkArrayLength(env, abAudio, 100); pbAudio = (*env)->GetBooleanArrayElements(env, abAudio, NULL); if (pbAudio == NULL) { throwRuntimeException(env, "GetBooleanArrayElements failed"); } checkArrayLength(env, abCopy, 100); pbCopy = (*env)->GetBooleanArrayElements(env, abCopy, NULL); if (pbCopy == NULL) { throwRuntimeException(env, "GetBooleanArrayElements failed"); } checkArrayLength(env, abPre, 100); pbPre = (*env)->GetBooleanArrayElements(env, abPre, NULL); if (pbPre == NULL) { throwRuntimeException(env, "GetBooleanArrayElements failed"); } checkArrayLength(env, anChannels, 100); pnChannels = (*env)->GetIntArrayElements(env, anChannels, NULL); if (pnChannels == NULL) { throwRuntimeException(env, "GetIntArrayElements failed"); } for (nTrack = nFirstTrack; nTrack <= nLastTrack; nTrack++) { pnStartFrame[nTrack - nFirstTrack] = cdda_track_firstsector(cdrom, nTrack); pnLength[nTrack - nFirstTrack] = cdda_track_lastsector(cdrom, nTrack) - cdda_track_firstsector(cdrom, nTrack) + 1; pnType[nTrack - nFirstTrack] = 0; // TODO: toc_entry.cdte_ctrl & CDROM_DATA_TRACK; pbAudio[nTrack - nFirstTrack] = cdda_track_audiop(cdrom, nTrack); pbCopy[nTrack - nFirstTrack] = cdda_track_copyp(cdrom, nTrack); pbPre[nTrack - nFirstTrack] = cdda_track_preemp(cdrom, nTrack); pnChannels[nTrack - nFirstTrack] = cdda_track_channels(cdrom, nTrack); if (debug_flag) { fprintf(debug_file, "Java_org_tritonus_lowlevel_cdda_cdparanoia_Cdparanoia_readTOC(): %d: %d %ld %ld\n", nTrack - nFirstTrack, nTrack, (long) pnStartFrame[nTrack - nFirstTrack], (long) pnLength[nTrack - nFirstTrack]); } } (*env)->ReleaseIntArrayElements(env, anStartFrame, pnStartFrame, 0); (*env)->ReleaseIntArrayElements(env, anLength, pnLength, 0); (*env)->ReleaseIntArrayElements(env, anType, pnType, 0); (*env)->ReleaseBooleanArrayElements(env, abAudio, pbAudio, 0); (*env)->ReleaseBooleanArrayElements(env, abCopy, pbCopy, 0); (*env)->ReleaseBooleanArrayElements(env, abPre, pbPre, 0); (*env)->ReleaseIntArrayElements(env, anChannels, pnChannels, 0); if (debug_flag) { fprintf(debug_file, "Java_org_tritonus_lowlevel_cdda_cdparanoia_Cdparanoia_readTOC(): end\n"); } return 0; }
void io::MMapInputStream::_map() { sys::Handle_T handle = getHandle(); mData = (sys::byte*)mOs.mapFile(handle, mLength, PROT_READ, MAP_SHARED, 0); }
/*********************************************************************** * Handler implementation **********************************************************************/ bool Pothos::RemoteHandler::runHandlerOnce(std::istream &is, std::ostream &os) { bool done = false; //deserialize the request const auto reqArgs = recvDatagram(is); //process the request and form the reply Pothos::ObjectKwargs replyArgs; replyArgs["tid"] = reqArgs.at("tid"); POTHOS_EXCEPTION_TRY { const auto &action = reqArgs.at("action").extract<std::string>(); if (action == "RemoteProxyEnvironment") { Pothos::ProxyEnvironmentArgs envArgs; for (const auto &entry : reqArgs) { if (entry.second.type() != typeid(std::string)) continue; envArgs[entry.first] = entry.second.extract<std::string>(); } const auto &name = reqArgs.at("name").extract<std::string>(); auto env = Pothos::ProxyEnvironment::make(name, envArgs); replyArgs["envID"] = getNewObjectId(Pothos::Object(env)); //a unique process ID for this server const auto info = Pothos::System::HostInfo::get(); replyArgs["upid"] = Pothos::Object(Pothos::ProxyEnvironment::getLocalUniquePid()); replyArgs["nodeId"] = Pothos::Object(info.nodeId); replyArgs["peerAddr"] = Pothos::Object(_peerAddr); } else if (action == "~RemoteProxyEnvironment") { removeObjectAtId(reqArgs.at("envID")); done = true; } else if (action == "findProxy") { auto env = getObjectAtId(reqArgs.at("envID")).extract<Pothos::ProxyEnvironment::Sptr>(); auto proxy = env->findProxy(reqArgs.at("name").extract<std::string>()); replyArgs["handleID"] = getNewObjectId(Pothos::Object(proxy)); } else if (action == "convertObjectToProxy") { auto env = getObjectAtId(reqArgs.at("envID")).extract<Pothos::ProxyEnvironment::Sptr>(); auto proxy = env->convertObjectToProxy(reqArgs.at("local")); replyArgs["handleID"] = getNewObjectId(Pothos::Object(proxy)); } else if (action == "convertProxyToObject") { auto env = getObjectAtId(reqArgs.at("envID")).extract<Pothos::ProxyEnvironment::Sptr>(); auto proxy = getObjectAtId(reqArgs.at("handleID")).extract<Pothos::Proxy>(); auto local = env->convertProxyToObject(proxy); replyArgs["local"] = local; } else if (action == "~RemoteProxyHandle") { removeObjectAtId(reqArgs.at("handleID")); } else if (action == "call") { auto proxy = getObjectAtId(reqArgs.at("handleID")).extract<Pothos::Proxy>(); //load the args std::vector<Pothos::Proxy> args; size_t argNo = 0; while (true) { auto it = reqArgs.find(std::to_string(argNo++)); if (it == reqArgs.end()) break; args.push_back(getObjectAtId(it->second).extract<Pothos::Proxy>()); } //make the call try { const auto &name = reqArgs.at("name").extract<std::string>(); auto result = proxy.getHandle()->call(name, args.data(), args.size()); replyArgs["handleID"] = getNewObjectId(Pothos::Object(result)); } catch (const Pothos::ProxyExceptionMessage &ex) { replyArgs["message"] = Pothos::Object(ex.message()); } } else if (action == "compareTo") { auto proxy = getObjectAtId(reqArgs.at("handleID")).extract<Pothos::Proxy>(); auto other = getObjectAtId(reqArgs.at("otherID")).extract<Pothos::Proxy>(); replyArgs["result"] = Pothos::Object(proxy.compareTo(other)); } else if (action == "hashCode") { auto proxy = getObjectAtId(reqArgs.at("handleID")).extract<Pothos::Proxy>(); replyArgs["result"] = Pothos::Object(proxy.hashCode()); } else if (action == "toString") { auto proxy = getObjectAtId(reqArgs.at("handleID")).extract<Pothos::Proxy>(); replyArgs["result"] = Pothos::Object(proxy.toString()); } else if (action == "getClassName") { auto proxy = getObjectAtId(reqArgs.at("handleID")).extract<Pothos::Proxy>(); replyArgs["result"] = Pothos::Object(proxy.getClassName()); } else { poco_bugcheck_msg(action.c_str()); } } POTHOS_EXCEPTION_CATCH(const Pothos::Exception &ex) { replyArgs["errorMsg"] = Pothos::Object(ex.displayText()); }
void RenderWidget::mouseMoveEvent(QMouseEvent* event) { he::io::IMouse* mouse(CONTROLS->getMouse(getHandle())); mouse->MouseMoved(he::vec2(event->x(), event->y())); QWidget::mouseMoveEvent(event); }
bool mxRadioButton::isChecked () const { return (SendMessage ((HWND) getHandle (), BM_GETCHECK, 0, 0L) == BST_CHECKED); }
void RenderWidget::wheelEvent(QWheelEvent* event) { he::io::IMouse* mouse(CONTROLS->getMouse(getHandle())); mouse->MouseWheelMoved(event->delta()); QWidget::wheelEvent(event); }
void mxLineEdit::getText( char *buf, size_t bufsize ) { buf[ 0 ] = 0; SendMessage( (HWND) getHandle (), WM_GETTEXT, (WPARAM)bufsize, (LPARAM)buf ); }
void RenderWidget::destroy() { CONTROLS->unregisterInputForWindow(getHandle()); Window::destroy(); GRAPHICS->unregisterWindow(this); }
int mxLineEdit::getMaxLength () const { return (int) SendMessage ((HWND) getHandle (), EM_GETLIMITTEXT, 0, 0L); }
bool MouseCursor::operator!= (const MouseCursor& other) const noexcept { return getHandle() != other.getHandle(); }
/*--------------------------------------------------------------------------*/ int sci_drawaxis(char *fname, void* pvApiCtx) { /** XXXXX : un point en suspens c'est le "S" ou une adresse est * stockees ds un unsigned long : est ce sufisant ? */ static rhs_opts opts[] = { { -1, "dir", -1, 0, 0, NULL}, { -1, "fontsize", -1, 0, 0, NULL}, { -1, "format_n", -1, 0, 0, NULL}, { -1, "seg", -1, 0, 0, NULL}, { -1, "sub_int", -1, 0, 0, NULL}, { -1, "textcolor", -1, 0, 0, NULL}, { -1, "tics", -1, 0, 0, NULL}, { -1, "ticscolor", -1, 0, 0, NULL}, { -1, "val", -1, 0, 0, NULL}, { -1, "x", -1, 0, 0, NULL}, { -1, "y", -1, 0, 0, NULL}, { -1, NULL, -1, 0, 0, NULL} }; int iSubwinUID = 0; int minrhs = -1, maxrhs = 0, minlhs = 0, maxlhs = 1, nopt = 0; char dir = 'l', *format = NULL, tics = 'v', **val = NULL; int fontsize = -1, sub_int = 2, seg_flag = 1, textcolor = -1, ticscolor = -1; double *x = NULL, *y = NULL; int nx = 0, ny = 0, ntics; int nb_tics_labels = -1; int iRhs = nbInputArgument(pvApiCtx); nopt = NumOpt(pvApiCtx); CheckInputArgument(pvApiCtx, minrhs, maxrhs + nopt); CheckOutputArgument(pvApiCtx, minlhs, maxlhs); if (getOptionals(pvApiCtx, fname, opts) == 0) { /* error */ return 0; } iSubwinUID = getOrCreateDefaultSubwin(); if (opts[0].iPos != -1) { char* pstDir = NULL; //CheckLength if (opts[0].iRows != 1 || opts[0].iCols != 1) { Scierror(999, _("%s: Wrong size for input argument #%d: %d expected.\n"), fname, opts[0].iPos, opts[0].iRows); return 1; } if (getAllocatedSingleString(pvApiCtx, opts[0].piAddr, &pstDir)) { return 1; } dir = pstDir[0]; freeAllocatedSingleString(pstDir); } if (opts[1].iPos != -1) { double dblSize = 0; //CheckScalar if (opts[1].iRows != 1 || opts[1].iCols != 1) { Scierror(999, _("%s: Wrong size for input argument #%d: A real scalar expected.\n"), fname, opts[1].iPos); return 1; } getScalarDouble(pvApiCtx, opts[1].piAddr, &dblSize); fontsize = (int)dblSize; } if (opts[2].iPos != -1) { /* verfier ce que l'on recoit avec "" XXX */ if (getAllocatedSingleString(pvApiCtx, opts[2].piAddr, &format)) { return 1; } } if (opts[3].iPos != -1) { double dblSeq = 0; //CheckScalar if (opts[3].iRows != 1 || opts[3].iCols != 1) { Scierror(999, _("%s: Wrong size for input argument #%d: A real scalar expected.\n"), fname, opts[3].iPos); freeAllocatedSingleString(format); return 1; } getScalarDouble(pvApiCtx, opts[3].piAddr, &dblSeq); seg_flag = (int)dblSeq; } if (opts[4].iPos != -1) { double dblSub = 0; //CheckScalar if (opts[4].iRows != 1 || opts[4].iCols != 1) { Scierror(999, _("%s: Wrong size for input argument #%d: A real scalar expected.\n"), fname, opts[4].iPos); freeAllocatedSingleString(format); return 1; } getScalarDouble(pvApiCtx, opts[4].piAddr, &dblSub); sub_int = (int)dblSub; } if (opts[5].iPos != -1) { double dblColor = 0; //CheckScalar if (opts[5].iRows != 1 || opts[5].iCols != 1) { Scierror(999, _("%s: Wrong size for input argument #%d: A real scalar expected.\n"), fname, opts[5].iPos); freeAllocatedSingleString(format); return 1; } getScalarDouble(pvApiCtx, opts[5].piAddr, &dblColor); textcolor = (int)dblColor; } if (opts[6].iPos != -1) { char* pstTics = NULL; //CheckLength if (opts[6].iRows != 1 || opts[6].iCols != 1) { Scierror(999, _("%s: Wrong size for input argument #%d: %d expected.\n"), fname, opts[6].iPos, opts[6].iRows); freeAllocatedSingleString(format); return 1; } if (getAllocatedSingleString(pvApiCtx, opts[6].piAddr, &pstTics)) { freeAllocatedSingleString(format); return 1; } tics = pstTics[0]; freeAllocatedSingleString(pstTics); } if (opts[7].iPos != -1) { double dblColor = 0; //CheckScalar if (opts[7].iRows != 1 || opts[7].iCols != 1) { Scierror(999, _("%s: Wrong size for input argument #%d: A real scalar expected.\n"), fname, opts[7].iPos); freeAllocatedSingleString(format); return 1; } getScalarDouble(pvApiCtx, opts[7].piAddr, &dblColor); ticscolor = (int)dblColor; } if (opts[8].iPos != -1) { if (getAllocatedMatrixOfString(pvApiCtx, opts[8].piAddr, &opts[8].iRows, &opts[8].iCols, &val)) { freeAllocatedSingleString(format); return 1; } } if (opts[9].iPos != -1) { getMatrixOfDouble(pvApiCtx, opts[9].piAddr, &opts[9].iRows, &opts[9].iCols, &x); nx = opts[9].iRows * opts[9].iCols; /* F.Leray OK here opts[9].iRows and opts[9].iCols are integers. */ } else { static double x_def[1]; double *bounds; int iCurrentSubwinUID = getCurrentSubWin(); getGraphicObjectProperty(iCurrentSubwinUID, __GO_DATA_BOUNDS__, jni_double_vector, (void **)&bounds); nx = 1; x = x_def; if (dir == 'l') { x_def[0] = bounds[0]; /* xMin */ } else if (dir == 'r') { x_def[0] = bounds[1]; /* xMax */ } } if (opts[10].iPos != -1) { getMatrixOfDouble(pvApiCtx, opts[10].piAddr, &opts[10].iRows, &opts[10].iCols, &y); ny = opts[10].iRows * opts[10].iCols; } else { static double y_def[1]; double *bounds; int iCurrentSubwinUID = getCurrentSubWin(); getGraphicObjectProperty(iCurrentSubwinUID, __GO_DATA_BOUNDS__, jni_double_vector, (void **)&bounds); ny = 1; y = y_def; if (dir == 'd') { y_def[0] = bounds[2]; /* yMin */ } else if (dir == 'u') { y_def[0] = bounds[3]; /* yMax */ } } /* compatibility test */ switch (tics) { case 'r': if (check_xy(fname, dir, 3, opts[9].iPos, opts[9].iRows, opts[9].iCols, x, opts[10].iPos, opts[10].iRows, opts[10].iCols, y, &ntics) == 0) { ReturnArguments(pvApiCtx); freeAllocatedSingleString(format); freeAllocatedMatrixOfString(opts[8].iRows, opts[8].iCols, val); return 0; } break; case 'i': if (check_xy(fname, dir, 4, opts[9].iPos, opts[9].iRows, opts[9].iCols, x, opts[10].iPos, opts[10].iRows, opts[10].iCols, y, &ntics) == 0) { ReturnArguments(pvApiCtx); freeAllocatedSingleString(format); freeAllocatedMatrixOfString(opts[8].iRows, opts[8].iCols, val); return 0; } break; case 'v': if (check_xy(fname, dir, -1, opts[9].iPos, opts[9].iRows, opts[9].iCols, x, opts[10].iPos, opts[10].iRows, opts[10].iCols, y, &ntics) == 0) { ReturnArguments(pvApiCtx); freeAllocatedSingleString(format); freeAllocatedMatrixOfString(opts[8].iRows, opts[8].iCols, val); return 0; } break; default: Scierror(999, _("%: Wrong value for %s '%c': '%s', '%s' and '%s' expected.\n"), fname, "tics", dir, "r", "v", "i"); freeAllocatedSingleString(format); freeAllocatedMatrixOfString(opts[8].iRows, opts[8].iCols, val); return 0; } if (val != NULL) { //CheckLength if (opts[8].iRows * opts[8].iCols != ntics) { Scierror(999, _("%s: Wrong size for input argument #%d: %d expected.\n"), fname, opts[8].iPos, opts[8].iRows * opts[8].iCols); freeAllocatedSingleString(format); freeAllocatedMatrixOfString(opts[8].iRows, opts[8].iCols, val); return 1; } nb_tics_labels = opts[8].iRows * opts[8].iCols; } Objdrawaxis(dir, tics, x, &nx, y, &ny, val, sub_int, format, fontsize, textcolor, ticscolor, 'n', seg_flag, nb_tics_labels); freeAllocatedSingleString(format); if (val != NULL) { freeAllocatedMatrixOfString(opts[8].iRows, opts[8].iCols, val); } createScalarHandle(pvApiCtx, iRhs + 1, getHandle(getCurrentObject())); AssignOutputVariable(pvApiCtx, 1) = iRhs + 1; ReturnArguments(pvApiCtx); return 0; }
u32 TabControl::GetCurSel() { return u32(SendMessage(getHandle(), TCM_GETCURSEL, 0, 0)); }