/*! Notifies the system that a wake() operation has completed. The \c{wakeDone()} message is sent on the QCop channel \c{QPE/ModemSuspend}. \sa wake(), suspend() */ void QModemService::wakeDone() { QtopiaIpcEnvelope env( "QPE/ModemSuspend", "wakeDone()" ); }
jobject SunJVMDLL::invokeObject(jobject& obj, jmethodID& methodid, jvalue arguments[]) { return env()->CallObjectMethodA(obj, methodid, arguments); }
int luaopen_gbm(lua_State* const state) { lua::thread env(state); /** Format of the allocated buffer */ env["GBM_BO_FORMAT_XRGB8888"] = GBM_BO_FORMAT_XRGB8888; env["GBM_BO_FORMAT_ARGB8888"] = GBM_BO_FORMAT_ARGB8888; env["GBM_FORMAT_BIG_ENDIAN"] = GBM_FORMAT_BIG_ENDIAN; /* color index */ env["GBM_FORMAT_C8"] = GBM_FORMAT_C8; /* 8 bpp RGB */ env["GBM_FORMAT_RGB332"] = GBM_FORMAT_RGB332; env["GBM_FORMAT_BGR233"] = GBM_FORMAT_BGR233; /* 16 bpp RGB */ env["GBM_FORMAT_XRGB4444"] = GBM_FORMAT_XRGB4444; env["GBM_FORMAT_XBGR4444"] = GBM_FORMAT_XBGR4444; env["GBM_FORMAT_RGBX4444"] = GBM_FORMAT_RGBX4444; env["GBM_FORMAT_BGRX4444"] = GBM_FORMAT_BGRX4444; env["GBM_FORMAT_ARGB4444"] = GBM_FORMAT_ARGB4444; env["GBM_FORMAT_ABGR4444"] = GBM_FORMAT_ABGR4444; env["GBM_FORMAT_RGBA4444"] = GBM_FORMAT_RGBA4444; env["GBM_FORMAT_BGRA4444"] = GBM_FORMAT_BGRA4444; env["GBM_FORMAT_XRGB1555"] = GBM_FORMAT_XRGB1555; env["GBM_FORMAT_XBGR1555"] = GBM_FORMAT_XBGR1555; env["GBM_FORMAT_RGBX5551"] = GBM_FORMAT_RGBX5551; env["GBM_FORMAT_BGRX5551"] = GBM_FORMAT_BGRX5551; env["GBM_FORMAT_ARGB1555"] = GBM_FORMAT_ARGB1555; env["GBM_FORMAT_ABGR1555"] = GBM_FORMAT_ABGR1555; env["GBM_FORMAT_RGBA5551"] = GBM_FORMAT_RGBA5551; env["GBM_FORMAT_BGRA5551"] = GBM_FORMAT_BGRA5551; env["GBM_FORMAT_RGB565"] = GBM_FORMAT_RGB565; env["GBM_FORMAT_BGR565"] = GBM_FORMAT_BGR565; /* 24 bpp RGB */ env["GBM_FORMAT_RGB888"] = GBM_FORMAT_RGB888; env["GBM_FORMAT_BGR888"] = GBM_FORMAT_BGR888; /* 32 bpp RGB */ env["GBM_FORMAT_XRGB8888"] = GBM_FORMAT_XRGB8888; env["GBM_FORMAT_XBGR8888"] = GBM_FORMAT_XBGR8888; env["GBM_FORMAT_RGBX8888"] = GBM_FORMAT_RGBX8888; env["GBM_FORMAT_BGRX8888"] = GBM_FORMAT_BGRX8888; env["GBM_FORMAT_ARGB8888"] = GBM_FORMAT_ARGB8888; env["GBM_FORMAT_ABGR8888"] = GBM_FORMAT_ABGR8888; env["GBM_FORMAT_RGBA8888"] = GBM_FORMAT_RGBA8888; env["GBM_FORMAT_BGRA8888"] = GBM_FORMAT_BGRA8888; env["GBM_FORMAT_XRGB2101010"] = GBM_FORMAT_XRGB2101010; env["GBM_FORMAT_XBGR2101010"] = GBM_FORMAT_XBGR2101010; env["GBM_FORMAT_RGBX1010102"] = GBM_FORMAT_RGBX1010102; env["GBM_FORMAT_BGRX1010102"] = GBM_FORMAT_BGRX1010102; env["GBM_FORMAT_ARGB2101010"] = GBM_FORMAT_ARGB2101010; env["GBM_FORMAT_ABGR2101010"] = GBM_FORMAT_ABGR2101010; env["GBM_FORMAT_RGBA1010102"] = GBM_FORMAT_RGBA1010102; env["GBM_FORMAT_BGRA1010102"] = GBM_FORMAT_BGRA1010102; /* packed YCbCr */ env["GBM_FORMAT_YUYV"] = GBM_FORMAT_YUYV; env["GBM_FORMAT_YVYU"] = GBM_FORMAT_YVYU; env["GBM_FORMAT_UYVY"] = GBM_FORMAT_UYVY; env["GBM_FORMAT_VYUY"] = GBM_FORMAT_VYUY; env["GBM_FORMAT_AYUV"] = GBM_FORMAT_AYUV; /* * 2 plane YCbCr * index 0 = Y plane, [7:0] Y * index 1 = Cr:Cb plane, [15:0] Cr:Cb little endian * or * index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian */ env["GBM_FORMAT_NV12"] = GBM_FORMAT_NV12; env["GBM_FORMAT_NV21"] = GBM_FORMAT_NV21; env["GBM_FORMAT_NV16"] = GBM_FORMAT_NV16; env["GBM_FORMAT_NV61"] = GBM_FORMAT_NV61; /* * 3 plane YCbCr * index 0: Y plane, [7:0] Y * index 1: Cb plane, [7:0] Cb * index 2: Cr plane, [7:0] Cr * or * index 1: Cr plane, [7:0] Cr * index 2: Cb plane, [7:0] Cb */ env["GBM_FORMAT_YUV410"] = GBM_FORMAT_YUV410; env["GBM_FORMAT_YVU410"] = GBM_FORMAT_YVU410; env["GBM_FORMAT_YUV411"] = GBM_FORMAT_YUV411; env["GBM_FORMAT_YVU411"] = GBM_FORMAT_YVU411; env["GBM_FORMAT_YUV420"] = GBM_FORMAT_YUV420; env["GBM_FORMAT_YVU420"] = GBM_FORMAT_YVU420; env["GBM_FORMAT_YUV422"] = GBM_FORMAT_YUV422; env["GBM_FORMAT_YVU422"] = GBM_FORMAT_YVU422; env["GBM_FORMAT_YUV444"] = GBM_FORMAT_YUV444; env["GBM_FORMAT_YVU444"] = GBM_FORMAT_YVU444; // enum gbm_bo_flags env["GBM_BO_USE_SCANOUT"] = GBM_BO_USE_SCANOUT; env["GBM_BO_USE_CURSOR_64X64"] = GBM_BO_USE_CURSOR_64X64; env["GBM_BO_USE_RENDERING"] = GBM_BO_USE_RENDERING; env["GBM_BO_USE_WRITE"] = GBM_BO_USE_WRITE; env["gbm_device_get_fd"] = gbm_device_get_fd; env["gbm_device_get_backend_name"] = gbm_device_get_backend_name; env["gbm_device_is_format_supported"] = gbm_device_is_format_supported; env["gbm_device_destroy"] = gbm_device_destroy; env["gbm_create_device"] = gbm_create_device; env["gbm_bo_create"] = gbm_bo_create; env["GBM_BO_IMPORT_WL_BUFFER"] = GBM_BO_IMPORT_WL_BUFFER; env["GBM_BO_IMPORT_EGL_IMAGE"] = GBM_BO_IMPORT_EGL_IMAGE; env["gbm_bo_import"] = gbm_bo_import; env["gbm_bo_get_width"] = gbm_bo_get_width; env["gbm_bo_get_height"] = gbm_bo_get_height; env["gbm_bo_get_stride"] = gbm_bo_get_stride; env["gbm_bo_get_format"] = gbm_bo_get_format; env["gbm_bo_get_device"] = gbm_bo_get_device; env["gbm_bo_get_handle"] = gbm_bo_get_handle; env["gbm_bo_write"] = _gbm_bo_write; env["gbm_bo_set_user_data"] = _gbm_bo_set_user_data; env["gbm_bo_get_user_data"] = _gbm_bo_get_user_data; env["gbm_bo_destroy"] = gbm_bo_destroy; // FIXME Determine the status of gbm_surface; where is it defined? //env["gbm_surface_create"] = gbm_surface_create; //env["gbm_surface_lock_front_buffer"] = gbm_surface_lock_front_buffer; //env["gbm_surface_release_buffer"] = gbm_surface_release_buffer; //env["gbm_surface_has_free_buffers"] = gbm_surface_has_free_buffers; //env["gbm_surface_destroy"] = gbm_surface_destroy; return 0; }
jbyte SunJVMDLL::invokeByte(jobject& obj, jmethodID& methodid, jvalue arguments[]) { return env()->CallByteMethodA(obj, methodid, arguments); }
jlong SunJVMDLL::invokeLong(jobject& obj, jmethodID& methodid, jvalue arguments[]) { return env()->CallLongMethodA(obj, methodid, arguments); }
jdouble SunJVMDLL::invokeDoubleStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]) { return env()->CallStaticDoubleMethodA(clazz, methodid, arguments); }
void SunJVMDLL::invokeVoid(jobject& obj, jmethodID& methodid, jvalue arguments[]) { env()->CallVoidMethodA(obj, methodid, arguments); }
void root::advance(float delta_time) { // Lock gameswf engine. Video is running in separate thread and // it calls gameswf functions from separate thread to set // status of netstream object gameswf_engine_mutex().lock(); // Handle mouse dragging do_mouse_drag(); // Handle the mouse. character *te; m_movie->get_topmost_mouse_entity(te, PIXELS_TO_TWIPS(m_mouse_x), PIXELS_TO_TWIPS(m_mouse_y)); m_mouse_button_state.m_topmost_entity = te; m_mouse_button_state.m_mouse_button_state_current = (m_mouse_buttons & 1); generate_mouse_button_events(&m_mouse_button_state); // advance Action script objects (interval timers, xmlsocket, ...) m_listener.advance(delta_time); m_time_remainder += delta_time; if (m_time_remainder >= m_frame_time) { // mark all as garbage m_player->set_as_garbage(); // this should be called infinitely to not repeat // the game situation after restart tu_random::next_random(); if (m_on_event_load_called == false) { set_flash_vars(m_player->m_flash_vars); if (m_def->m_is_avm2) { const abc_def* adef = m_def->get_abc(); if (adef) { as_environment env(m_player.get_ptr()); gameswf::call_method(adef->get_script_function(), &env, as_value(m_movie.get_ptr()), 0, 0); } } } if (m_player->get_force_realtime_framerate() == true) { while (m_time_remainder >= m_frame_time) { m_movie->advance(m_frame_time); m_time_remainder -= m_frame_time; } } else { m_movie->advance(delta_time); m_time_remainder = fmod(m_time_remainder - m_frame_time, m_frame_time); } if (m_on_event_load_called == false) { // Must do loading events. For child sprites this is // done by the dlist, but root movies don't get added // to a dlist, so we do it here. m_on_event_load_called = true; m_movie->on_event(event_id::LOAD); } m_player->clear_garbage(); } gameswf_engine_mutex().unlock(); }
void SunJVMDLL::setIntField(jclass cls, jobject obj, const std::string& fieldName, int value) { jfieldID binding = env()->GetFieldID(cls, fieldName.c_str(), "I"); env()->SetIntField(obj, binding, (jint)value); }
void es::MainGame::update() { const float deltaTime = 8.0f; // TIPS: プレイヤーの処理 // 重力を先に与えてから高さの補正を行うことで、 // 一瞬地面にめり込むような表示が無くなる { // 重力をかける前の Y 座標 const auto prevPosY = player.getPos().y(); // 重力 player.gravity(); // 重力をかけた後の座標 const auto currentPos = player.getPos(); const auto size = player.isInvincible ? player.getRealScale() : player.getDotScale(); // 落下中の判定 const auto isGravity = prevPosY > currentPos.y(); // 足場に乗ったかどうか const auto onGround = [&](const Vec2f& gPos, const Vec2f& gSize) { // 落下中でなければ無視する if (!isGravity) { return false; } const auto inL = currentPos.x() > gPos.x(); const auto inR = currentPos.x() < gPos.x() + gSize.x(); const auto inT = currentPos.y() < gPos.y() + gSize.y(); return inL && inR && inT; }; inGroundFlag = false; // 足場との当たり判定 for (auto& block : blocks) { // プレイヤーが足場よりも下にいるかどうか const auto isLowPos = currentPos.y() < block.getPos().y(); if (isLowPos) { continue; } if (onGround(block.getPos(), block.getSize())) { const auto y = block.getPos().y() + block.getSize().y(); player.landing(y); inGroundFlag = !inGroundFlag; } } if (!inGroundFlag) { player.setJumpState(); } // 地面との当たり判定 if (currentPos.y() < StageGround) { player.landing(StageGround); } // ジャンプ判定 player.jump(); // 敵に当たったかどうか const auto isHitEnemy = [&](const Vec2f& ePos, const Vec2f& eSize) { const auto inL = currentPos.x() >= ePos.x(); const auto inR = currentPos.x() <= ePos.x() + eSize.x(); const auto inB = currentPos.y() >= ePos.y(); const auto inT = currentPos.y() <= ePos.y() + eSize.y(); return inL && inR && inT && inB; }; // 敵との当たり判定 // 当たっていたらノックバック処理 for (auto& enemy : enemies) { // 当たっていなければ、スキップ if (!isHitEnemy(enemy->getPos(), enemy->getScale())) { continue; } // 無敵状態でなければダメージを受ける if (!player.isInvincible) { player.HP() -= enemy->getAttack(); } enemy->damage(player.Attack()); //player.hp <= 0; if (player.HP() <= 0) { //シーン遷移 data.isGameOver = true; next_ = SceneName::Result; isFinish_ = true; } // 敵のHPが0であれば if (enemy->isDead()) { // 更にプレイヤーの必殺技ゲージを加算 player.Gauge() += enemy->getGaugePower(); } else { // 吹っ飛ばす backForce = constantForce * deltaTime; player.setJumpState(); player.resetJumpPower(); } // プレイヤーが無敵状態であればゲージを減らす if (player.isInvincible == true) { player.countTimer -= 1.0f; if (player.countTimer < 0) { player.cancelInvincible(); } } // プレイヤーの必殺技ゲージがMAXであれば if (player.IsGaugeMax()) { player.Invincible(); } break; } // 死んでる敵を消す deadEnemyRemove(); // ノックバック処理 force(); // プレイヤーの移動距離から、次の背景を表示するか判定 const auto isMoved = bg.checkPoint(player.getPos().x()); // 背景が移動したら敵キャラと足場を新しく生成する if (isMoved) { LoadData(); } // 移動 player.move(deltaTime); } // カメラ更新 camera.Update(&player); // デバッグ用 #ifdef _DEBUG isFinish_ = env().isPushButton(Mouse::RIGHT); #endif }
int main() { AppEnv env(3000, 2048, false, true); //ゲームの素材(主人公) Texture anb_top("res/anb1.png");//正面 Texture anb_side("res/anb2.png");//横 Texture anb_back("res/anb3.png");//後ろ //素材その他 Texture title("res/title_top.png"); Texture title2("res/title2.png"); Texture owari("res/owari.png"); Texture door("res/door.png"); Texture door2("res/door2.png"); Texture titledoorhan("res/titledoorhan.png"); Texture akari("res/akari.png"); Texture hp("res/heart.png"); Texture open("res/open.png"); Texture closed("res/closed.png"); Texture end("res/endcard.png"); //音源 Media nock("res/nock.wav"); Media keyclose("res/keyclose.wav"); //キャラの移動x,y int x = -1500; int y = -1024; // int stage_count = 0; int life = 3; int stage_clear=0; int block_x = 200; int block_y = 200; int akari_count = 0; int atari_count = 0; //stage_clear = 1; //**************************************おおもと************************************** while (true){ env.begin(); //::::::::::::::::::::::タイトル画面:::::::::::::::::::::::: while (env.isOpen()) { env.begin(); drawTextureBox(-1500, -1024, 3000, 2048, 0, 0, 4096, 2048, title); drawTextureBox(-1050, -600, 200, 200, 0, 0, 512, 512, open); drawTextureBox(100, -600, 200, 200, 0, 0, 512, 512, closed); if (!(-330 < x || -830 > x + 300 || -174 < y || -1024 > y + 600)){ drawTextureBox(-828, -1010, 510, 840, 0, 0, 512, 512, titledoorhan); if (env.isPressKey(GLFW_KEY_SPACE)){ x = -40; y = -1024; nock.play(); break; } } //右ドア if (stage_clear == 1){ drawTextureBox(100, -600, 200, 200, 0, 0, 512, 512, open); if (!(835 < x || 325 > x + 300 || -184 < y || -1024 > y + 600)){ drawTextureBox(320, -1010, 510, 840, 0, 0, 512, 512, titledoorhan); if (env.isPressKey(GLFW_KEY_SPACE)){ x = -40; y = -1024; nock.play(); stage_count = 11; break; } } } else { if (env.isPushKey(GLFW_KEY_SPACE)){ if (!(835 < x || 325 > x + 300 || -184 < y || -1024 > y + 600)){ keyclose.play(); } } } if (env.isPressKey(GLFW_KEY_LEFT)){ x -= 5; drawTextureBox(x, y, 300, 600, 0, 0, -256, 512, anb_side, Color(1, 1, 1, 1)); if (x <-1500){ x = -1500; } } else if (env.isPressKey(GLFW_KEY_RIGHT)){ x += 5; drawTextureBox(x, y, 300, 600, 0, 0, 256, 512, anb_side, Color(1, 1, 1, 1)); if (x > 1200){ x = 1200; } } else { drawTextureBox(x, y, 300, 600, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); } //if(!( □+x<x || □x >x+300 || □+y <y || □y > y+600)) env.end(); } //:::::::::::::::::::::::ゲーム本編::::::::::::::::::::::::::: while (env.isOpen()) { Vec2f pos = env.mousePosition(); env.begin(); //--------------------チュートリアル--------------------- //背景 if (stage_count == 0){ drawFillBox(-1024, -1024, 2048, 2048, Color(1, 1, 1, 1)); //ドア drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door); if (!(60 < x || -40 > x + 80 || 1024 < y || 824 > y + 160)){ drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door2); if (env.isPressKey(GLFW_KEY_SPACE)){ stage_count++; x = -40; y = -1024; nock.play(); } } //drawTextureBox(-40, 30, 80, 160, 0, 0, 256, 512, door2); // キャラの移動&移動制限 if (env.isPressKey(GLFW_KEY_UP)){ y += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_back, Color(1, 1, 1, 1)); if (y > 864.0f){ y = 864.0f; } } else if (env.isPressKey(GLFW_KEY_LEFT)){ x -= 5; drawTextureBox(x, y, 80, 160, 0, 0, -256, 512, anb_side, Color(1, 1, 1, 1)); } else if (env.isPressKey(GLFW_KEY_DOWN)){ y -= 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); if(y< -1024.0f){ y = -1024.0f; } } else if (env.isPressKey(GLFW_KEY_RIGHT)){ x += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_side, Color(1, 1, 1, 1)); } else { drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); } //マップ&当たり判定 //if(!( □+x<x || □x >x+80 || □+y <y || □y > y+160)) drawFillBox(500, -1024, 600, 2048, Color(0, 0, 0, 1)); if (!(1100 < x || 500 > x + 80 || 1024 < y || -1024 > y + 100)){ x = -40; y = -1024; } drawFillBox(-1100, -1024, 600, 2048, Color(0,0,0, 1));//0.02 if (!(-500 < x || -1100 > x + 80 || 1024 < y || -1024 > y + 160)){ x = -40; y = -1024; } drawFillBox(-300, 0, 500, 200, Color(0,0,0,1)); if (!(200 < x || -300 > x + 80 || 200 < y || 0 > y + 160)){ x = -40; y = -1024; } } //----------------------ステージ1-------------------------------------------------------------- if (stage_count == 1){ drawFillBox(-1024, -1024, 2048, 2048, Color(40 / 255, 34 / 255, 42 / 255, 1)); drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door); if (!(60 < x || -40 > x + 80 || 1024 < y || 824 > y + 160)){ drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door2); if (env.isPressKey(GLFW_KEY_SPACE)){ stage_count++; x = -40; y = -1024; nock.play(); } } // キャラの移動&移動制限 if (env.isPressKey(GLFW_KEY_UP)){ y += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_back, Color(1, 1, 1, 0.4)); if (y > 864.0f){ y = 864.0f; } } else if (env.isPressKey(GLFW_KEY_LEFT)){ x -= 5; drawTextureBox(x, y, 80, 160, 0, 0, -256, 512, anb_side, Color(1, 1, 1, 0.4)); if (x < -1024.0f){ x = -1024.0f; } } else if (env.isPressKey(GLFW_KEY_DOWN)){ y -= 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 0.4)); if (y < -1024.0f){ y = -1024.0f; } } else if (env.isPressKey(GLFW_KEY_RIGHT)){ x += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_side, Color(1, 1, 1, 0.4)); if (x > 1024.0f){ x = 1024.0f; } } else { drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 0.4)); } //マップ&当たり判定 //if(!( <x || >x+80 || <y ||> y+160)) //if(!(ax2 < bx1 || ax1 > bx2 || ay1< by2 || ay2 >by1)) drawFillBox(500, -1024, 100, 2048, Color(1, 1, 1, 0.02)); if (!(600 < x || 500 > x + 80 || 1024 < y || -1024 > y + 100)){ x = -40; y = -1024; } drawFillBox(-500, -1024, 100, 2048, Color(1, 1, 1, 0.02));//0.02 if (!(-400 < x || -500 > x + 80 || 1024 < y || -1024 > y + 160)){ x = -40; y = -1024; } drawFillBox(-400, 0, 500, 200, Color(1, 1, 1, 0.02)); if (!(100 < x || -400 > x + 80 || 200 < y || 0 > y + 160)){ x = -40; y = -1024; } drawFillBox(0, -500, 500, 200, Color(1, 1, 1, 0.02)); if (!(500 < x || 0 > x + 80 || -300 < y || -500 > y + 160)){ x = -40; y = -1024; } drawFillBox(-150, 500, 400, 200, Color(1, 1, 1, 0.02)); if (!(250 < x || -150 > x + 80 || 700 < y || 500 > y + 160)){ x = -40; y = -1024; } //キャラの明かり drawFillCircle(x + 40, y + 80, 130, 130, 100, Color(1, 1, 1, 0.13)); } //--------------------2ステージ------------------------------------------------------------ if (stage_count == 2){ drawFillBox(-1024, -1024, 2048, 2048, Color(1, 1, 1, 1)); drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door); if (!(60 < x || -40 > x + 80 || 1024 < y || 824 > y + 160)){ drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door2); if (env.isPressKey(GLFW_KEY_SPACE)){ stage_count++; x = -40; y = -1024; nock.play(); } } // キャラの移動&移動制限 if (env.isPressKey(GLFW_KEY_UP)){ y += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_back, Color(1, 1, 1, 1)); if (y > 864.0f){ y = 864.0f; } } else if (env.isPressKey(GLFW_KEY_LEFT)){ x -= 5; drawTextureBox(x, y, 80, 160, 0, 0, -256, 512, anb_side, Color(1, 1, 1, 1)); if (x < -1024.0f){ x = -1024.0f; } } else if (env.isPressKey(GLFW_KEY_DOWN)){ y -= 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); if (y < -1024.0f){ y = -1024.0f; } } else if (env.isPressKey(GLFW_KEY_RIGHT)){ x += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_side, Color(1, 1, 1, 1)); if (x > 1024.0f){ x = 1024.0f; } } else { drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); } //明かり的な? drawFillCircle(x + 40, y + 80, 130, 130, 100, Color(0, 0, 0, 0.1)); //マップ&当たり判定 //if(!( <x || >x+80 || <y ||> y+160)) //if(!(ax2 < bx1 || ax1 > bx2 || ay1< by2 || ay2 >by1)) drawFillBox(500, -1024, 100, 2048, Color(1, 1, 1)); if (!(600 < x || 500 > x + 80 || 1024 < y || -1024 > y + 100)){ x = -40; y = -1024; } drawFillBox(-500, -1024, 100, 2048, Color(1, 1, 1));//0.02 if (!(-400 < x || -500 > x + 80 || 1024 < y || -1024 > y + 160)){ x = -40; y = -1024; } drawFillBox(-400, 0, 500, 200, Color(1, 1, 1)); if (!(100 < x || -400 > x + 80 || 200 < y || 0 > y + 160)){ x = -40; y = -1024; } drawFillBox(0, -500, 500, 200, Color(1, 1, 1)); if (!(500 < x || 0 > x + 80 || -300 < y || -500 > y + 160)){ x = -40; y = -1024; } drawFillBox(-150, 500, 400, 200, Color(1, 1, 1)); if (!(250 < x || -150 > x + 80 || 700 < y || 500 > y + 160)){ x = -40; y = -1024; } } //---------------------ステージ3------------------------------------------------------------------------- if (stage_count == 3){ drawFillBox(-1024, -1024, 2048, 2048, Color(1, 1, 1, 1)); drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door); if (!(60 < x || -40 > x + 80 || 1024 < y || 824 > y + 160)){ drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door2); if (env.isPressKey(GLFW_KEY_SPACE)){ x = -1500; y = -1024; stage_count = 0; stage_clear = 1; nock.play(); break; } } if (env.isPressKey(GLFW_KEY_UP)){ y += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_back, Color(1, 1, 1, 1)); if (y > 864.0f){ y = 864.0f; } } else if (env.isPressKey(GLFW_KEY_LEFT)){ x -= 5; drawTextureBox(x, y, 80, 160, 0, 0, -256, 512, anb_side, Color(1, 1, 1, 1)); if (x < -1024.0f){ x = -40; y = -1024; } } else if (env.isPressKey(GLFW_KEY_DOWN)){ y -= 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); if (y < -1024.0f){ y = -1024.0f; } } else if (env.isPressKey(GLFW_KEY_RIGHT)){ x += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_side, Color(1, 1, 1, 1)); if (x > 944.0f){ x = -40; y = -1024; } } else { drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); } drawFillBox(block_x, block_y, 200, 200, Color::black); if (!(block_x + 200 < x || block_x > x + 80 || block_y + 200 < y || block_y > y + 160)){ x = -40; y = -1024; } if (!(200 < x || 0 > x + 80 || 400 < y || 200 > y + 160)){ block_x = 0; } } //--------------------------------------------すてーじ1-------------------------------------------- if (stage_count == 11){ if (life == 3){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1218, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1376, -1024, 128, 128, 0, 0, 128, 128, hp); } else if (life == 2){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1218, -1024, 128, 128, 0, 0, 128, 128, hp); } else if (life == 1){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); } else { stage_count = 0; life = 3; x = -1500; y = -1024; break; } drawFillBox(-1024, -1024, 2048, 2048, Color(1, 1, 1, 1)); drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door); if (!(60 < x || -40 > x + 80 || 1024 < y || 824 > y + 160)){ drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door2); if (env.isPressKey(GLFW_KEY_SPACE)){ x = -40; y = -1024; stage_count++; nock.play(); } } if (env.isPressKey(GLFW_KEY_UP)){ y += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_back, Color(1,1,1, 1)); if (y > 864.0f){ y = 864.0f; } } else if (env.isPressKey(GLFW_KEY_LEFT)){ x -= 5; drawTextureBox(x, y, 80, 160, 0, 0, -256, 512, anb_side, Color(1, 1, 1, 1)); if (x < -1024.0f){ x = -40; y = -1024; } } else if (env.isPressKey(GLFW_KEY_DOWN)){ y -= 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); if (y < -1024.0f){ y = -1024.0f; } } else if (env.isPressKey(GLFW_KEY_RIGHT)){ x += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_side, Color(1, 1, 1, 1)); if (x > 944.0f){ x = -40; y = -1024; } } else { drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); } drawFillCircle(x + 40, y + 80, 130, 130, 100, Color(0, 0, 0, 0.1)); drawFillBox(100, -1024, 300, 500, Color::white); if (!(400 < x || 100 > x + 80 || -524 < y || -1024 > y + 160)){ x = -40; y = -1024; life--; } drawFillBox(-1024, -1024, 800, 400, Color::white); if (!(-224 < x || -1024 > x + 80 || -624 < y || -1024 > y + 160)){ x = -40; y = -1024; life--; } drawFillBox(-600, -224, 1000, 300, Color::white); if (!(400 < x || -600 > x + 80 || -124 < y || -224 > y + 160)){ x = -40; y = -1024; life--; } drawFillBox(400, 70, 600, 300, Color::white); if (!(1100 < x || 400 > x + 80 || 370 < y || 70 > y + 160)){ x = -40; y = -1024; life--; } drawFillBox(-600, 24, 300, 300, Color::white); if (!(-300 < x || -600 > x + 80 || 324 < y || 300 > y + 160)){ x = -40; y = -1024; life--; } drawFillBox(-600, 524, 300, 200, Color::white); if (!(-300 < x || -600 > x + 80 || 724 < y || 524 > y + 160)){ x = -40; y = -1024; life--; } drawFillBox(-300, 524, 300, 100, Color::white); if (!(0 < x || -300 > x + 80 || 624 < y || 524 > y + 160)){ x = -40; y = -1024; life--; } drawFillBox(0, 350, 400, 276, Color::white); if (!(400 < x || 0 > x + 80 || 626 < y || 350 > y + 160)){ x = -40; y = -1024; life--; } } //-------------------------------------すてーじ2---------------------------------------- if (stage_count == 12){ if (life == 3){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1218, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1376, -1024, 128, 128, 0, 0, 128, 128, hp); } else if (life == 2){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1218, -1024, 128, 128, 0, 0, 128, 128, hp); } else if (life == 1){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); } else { stage_count = 0; life = 3; x = -1500; y = -1024; akari_count = 0; break; } drawFillBox(-1024, -1024, 2048, 2048, Color(0, 0, 0, 1)); drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door); if (!(60 < x || -40 > x + 80 || 1024 < y || 824 > y + 160)){ drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door2); if (env.isPressKey(GLFW_KEY_SPACE)){ x = -40; y = -1024; stage_count++; akari_count = 0; nock.play(); } } if (env.isPressKey(GLFW_KEY_UP)){ y += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_back, Color(1, 1, 1, 1)); if (y > 864.0f){ y = 864.0f; } } else if (env.isPressKey(GLFW_KEY_LEFT)){ x -= 5; drawTextureBox(x, y, 80, 160, 0, 0, -256, 512, anb_side, Color(1, 1, 1, 1)); if (x < -1024.0f){ x = -40; y = -1024; } } else if (env.isPressKey(GLFW_KEY_DOWN)){ y -= 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); if (y < -1024.0f){ y = -1024.0f; } } else if (env.isPressKey(GLFW_KEY_RIGHT)){ x += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_side, Color(1, 1, 1, 1)); if (x > 944.0f){ x = -40; y = -1024; } } else { drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); } drawFillBox(-1024, -1024, 800, 600, Color::black); if (!(-224<x ||-1024 >x + 80 ||-424 <y ||-1024 > y + 160)){ x = -40; y = -1024; life--; } drawFillBox(200, -1024, 500, 800, Color::black); if (!(700<x ||200 >x + 80 ||-224 <y || -1024> y + 160)){ x = -40; y = -1024; life--; } drawFillBox(-724, -250, 2000, 300, Color::black); if (!(1276<x || -724 >x + 80 || 50<y || -250> y + 160)){ x = -40; y = -1024; life--; } drawFillBox(-1024, 300, 1748, 200, Color::black); if (!(724<x ||-1024 >x + 80 ||500 <y ||300 > y + 160)){ x = -40; y = -1024; life--; } drawFillBox(60, 700, 1000, 424, Color::black); if (!(1060<x ||60 >x + 80 || 1124<y ||700 > y + 160)){ x = -40; y = -1024; life--; } akari_count++; if (akari_count < 90){ drawTextureBox(-50, -350, 64, 64, 0, 0, 64, 64, akari); } if (akari_count > 90 && akari_count < 180){ drawTextureBox(-900, -350, 64, 64, 0, 0, 64, 64, akari); } if (akari_count>180 && akari_count < 270){ drawTextureBox(-900, 150, 64, 64, 0, 0, 64, 64, akari); } if (akari_count>270 && akari_count < 360){ drawTextureBox(850, 150, 64, 64, 0, 0, 64, 64, akari); } if (akari_count>360 && akari_count < 450){ drawTextureBox(850, 550, 64, 64, 0, 0, 64, 64, akari); } if (akari_count>450 && akari_count < 540){ drawTextureBox(-40, 600, 64, 64, 0, 0, 64, 64, akari); } if (akari_count > 630){ akari_count = 0; } } //------------------------------------------すてーじ3---------------------------- if (stage_count == 13){ if (life == 3){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1218, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1376, -1024, 128, 128, 0, 0, 128, 128, hp); } else if (life == 2){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1218, -1024, 128, 128, 0, 0, 128, 128, hp); } else if (life == 1){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); } else { stage_count = 0; life = 3; x = -40; y = -1024; akari_count = 0; break; } atari_count++; drawFillBox(-1024, -1024, 2048, 2048, Color(0, 0, 0, 1)); if (atari_count == 600){ if (!(1024 < x || -1024 > x + 80 || 1024 < y || -1024 > y + 160)){ x = -40; y = -1024; life--; } } if(atari_count > 600){ atari_count = 0; } drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door); if (!(60 < x || -40 > x + 80 || 1024 < y || 824 > y + 160)){ drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door2); if (env.isPressKey(GLFW_KEY_SPACE)){ x = -40; y = -1024; stage_count++; akari_count = 0; nock.play(); } } if (env.isPressKey(GLFW_KEY_UP)){ y += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_back, Color(1, 1, 1, 1)); if (y > 864.0f){ y = 864.0f; } } else if (env.isPressKey(GLFW_KEY_LEFT)){ x -= 5; drawTextureBox(x, y, 80, 160, 0, 0, -256, 512, anb_side, Color(1, 1, 1, 1)); if (x < -1024.0f){ x = -40; y = -1024; } } else if (env.isPressKey(GLFW_KEY_DOWN)){ y -= 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); if (y < -1024.0f){ y = -1024.0f; } } else if (env.isPressKey(GLFW_KEY_RIGHT)){ x += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_side, Color(1, 1, 1, 1)); if (x > 944.0f){ x = -40; y = -1024; } } else { drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); } //----------------------------------------すてーじ14------------------------------- } if (stage_count == 14){ if (life == 3){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1218, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1376, -1024, 128, 128, 0, 0, 128, 128, hp); } else if (life == 2){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); drawTextureBox(1218, -1024, 128, 128, 0, 0, 128, 128, hp); } else if (life == 1){ drawTextureBox(1050, -1024, 128, 128, 0, 0, 128, 128, hp); } else { stage_count = 0; life = 3; x = -1500; y = -1024; akari_count = 0; break; } drawFillBox(-1024, -1024, 2048, 2048, Color(1, 1, 1, 1)); drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door); if (!(60 < x || -40 > x + 80 || 1024 < y || 824 > y + 160)){ drawTextureBox(-40, 824, 100, 200, 0, 0, 256, 512, door2); if (env.isPressKey(GLFW_KEY_SPACE)){ x = -40; y = -1024; stage_count++; akari_count = 0; nock.play(); } } drawFillBox(-200, -300, 100, 100, Color::white); if (!(-100<x || -300 >x + 80 || -200 <y || -300 > y + 160)){ x = 100; y = -700; } drawFillBox(100, 0, 100, 100, Color::white); if (!(200<x || 100>x + 80 || 100<y || 0> y + 160)){ x = 300; y = -50; } drawFillBox(-500, -300, 100, 100, Color::white); if (!(-400<x || -500>x + 80 || -400 <y || -300 > y + 160)){ x = 200; y = -100; } drawFillBox(-700, -400, 100, 100, Color::white); if (!(-600<x || -700>x + 80 || -300<y || -400> y + 160)){ x = 700; y = -200; } drawFillBox(-500, -300, 100, 100, Color::white); if (!(-400<x || -500 >x + 80 || -400 <y || -300 > y + 160)){ x = 400; y = 500; } drawFillBox(300, 0, 100, 100, Color::white); if (!(400<x || 300>x + 80 || 100 <y || 0 > y + 160)){ x = -200; y = -900; } drawFillBox(-800, -300, 100, 100, Color::white); if (!(-700<x || -800 >x + 80 || -200 <y || -300> y + 160)){ x = -600; y = 300; } drawFillBox(-300, -400, 100, 100, Color::white); if (!(-200<x || -300 >x + 80 || -300 <y || -400> y + 160)){ x = -500; y = 800; } drawFillBox(300, 300, 100, 100, Color::white); if (!(400<x || 300>x + 80 || 400 <y || 300> y + 160)){ x = 900; y = -300; } drawFillBox(0, 600, 100, 100, Color::white); if (!(100<x || 0>x + 80 || 700 <y || 600> y + 160)){ x = 800; y = 700; } drawFillBox(700, 0, 100, 100, Color::white); if (!(800<x || 700 >x + 80 || 100 <y || 0> y + 160)){ x = -700; y = 800; } drawFillBox(500, -200, 100, 100, Color::white); if (!(600<x || 500 >x + 80 || -100 <y || -200 > y + 160)){ x = -400; y = 400; } drawFillBox(900, -400, 100, 100, Color::white); if (!(1000<x || 900 >x + 80 || 900<y || -400 > y + 160)){ x = -1000; y = 800; } drawFillBox(400, -600, 100, 100, Color::white); if (!(500<x || 400 >x + 80 || -500 <y || -600> y + 160)){ x = -200; y = -800; } drawFillBox(300, -800, 100, 100, Color::white); drawFillBox(500, -900, 100, 100, Color::white); if (!(600<x || 500 >x + 80 || -800 <y || -900> y + 160)){ x = 300; y = -50; } if (env.isPressKey(GLFW_KEY_UP)){ y += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_back, Color(1, 1, 1, 1)); if (y > 864.0f){ y = 864.0f; } } else if (env.isPressKey(GLFW_KEY_LEFT)){ x -= 5; drawTextureBox(x, y, 80, 160, 0, 0, -256, 512, anb_side, Color(1, 1, 1, 1)); if (x < -1024.0f){ x = -40; y = -1024; } } else if (env.isPressKey(GLFW_KEY_DOWN)){ y -= 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); if (y < -1024.0f){ y = -1024.0f; } } else if (env.isPressKey(GLFW_KEY_RIGHT)){ x += 5; drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_side, Color(1, 1, 1, 1)); if (x > 944.0f){ x = -40; y = -1024; } } else { drawTextureBox(x, y, 80, 160, 0, 0, 256, 512, anb_top, Color(1, 1, 1, 1)); } drawFillBox(-400, 400, 200, 824, Color::black); if (!(-200<x ||-400 >x + 80 ||600 <y ||400 > y + 160)){ x = -40; y = -1024; life--; } drawFillBox(200, 400, 200, 824, Color::black); if (!(400<x || 200>x + 80 ||1224 <y ||400 > y + 160)){ x = -40; y = -1024; life--; } drawFillBox(-100, 0, 200, 200, Color::black); if (!(100 < x || -100 > x + 80 || 200 < y || 0 > y + 160)) { x = -40; y = -1024; life--; } } //-------------------------------エンド画面------------------------------------------ if (stage_count == 15){ drawTextureBox(-1500, -1024, 3000, 2048, 0, 0, 4096, 2048, end); if (env.isPushButton(Mouse::LEFT)){ x = -1500; y = -1024; break; } } if (env.isPushKey(GLFW_KEY_CAPS_LOCK)){ stage_count++; } env.end(); } //ここまでが本編while if (!env.isOpen()){ return 0; } env.end(); } //*********************************************ここまで************************************** }
PyObject *_PyCodec_Lookup(const char *encoding) { env(NULL); jstring s = (*env)->NewStringUTF(env, encoding); return JyNI_PyObject_FromJythonPyObject( (*env)->CallStaticObjectMethod(env, pyCodecsClass, pyCodecsLookup, s)); // PyInterpreterState *interp; // PyObject *result, *args = NULL, *v; // Py_ssize_t i, len; // // if (encoding == NULL) { // PyErr_BadArgument(); // goto onError; // } // // interp = PyThreadState_GET()->interp; // if (interp->codec_search_path == NULL && _PyCodecRegistry_Init()) // goto onError; // // /* Convert the encoding to a normalized Python string: all // characters are converted to lower case, spaces and hyphens are // replaced with underscores. */ // v = normalizestring(encoding); // if (v == NULL) // goto onError; // PyString_InternInPlace(&v); // // /* First, try to lookup the name in the registry dictionary */ // result = PyDict_GetItem(interp->codec_search_cache, v); // if (result != NULL) { // Py_INCREF(result); // Py_DECREF(v); // return result; // } // // /* Next, scan the search functions in order of registration */ // args = PyTuple_New(1); // if (args == NULL) // goto onError; // PyTuple_SET_ITEM(args,0,v); // // len = PyList_Size(interp->codec_search_path); // if (len < 0) // goto onError; // if (len == 0) { // PyErr_SetString(PyExc_LookupError, // "no codec search functions registered: " // "can't find encoding"); // goto onError; // } // // for (i = 0; i < len; i++) { // PyObject *func; // // func = PyList_GetItem(interp->codec_search_path, i); // if (func == NULL) // goto onError; // result = PyEval_CallObject(func, args); // if (result == NULL) // goto onError; // if (result == Py_None) { // Py_DECREF(result); // continue; // } // if (!PyTuple_Check(result) || PyTuple_GET_SIZE(result) != 4) { // PyErr_SetString(PyExc_TypeError, // "codec search functions must return 4-tuples"); // Py_DECREF(result); // goto onError; // } // break; // } // if (i == len) { // /* XXX Perhaps we should cache misses too ? */ // PyErr_Format(PyExc_LookupError, // "unknown encoding: %s", encoding); // goto onError; // } // // /* Cache and return the result */ // PyDict_SetItem(interp->codec_search_cache, v, result); // Py_DECREF(args); // return result; // // onError: // Py_XDECREF(args); // return NULL; }
bool has_only_one_constructor(name const & I_name) const { if (auto r = inductive::get_num_intro_rules(env(), I_name)) return *r == 1; else return false; }
int Groupsock::outputToAllMembersExcept(DirectedNetInterface* exceptInterface, u_int8_t ttlToFwd, unsigned char* data, unsigned size, netAddressBits sourceAddr) { // Don't forward TTL-0 packets if (ttlToFwd == 0) return 0; DirectedNetInterfaceSet::Iterator iter(members()); unsigned numMembers = 0; DirectedNetInterface* interf; while ((interf = iter.next()) != NULL) { // Check whether we've asked to exclude this interface: if (interf == exceptInterface) continue; // Check that the packet's source address makes it OK to // be relayed across this interface: UsageEnvironment& saveEnv = env(); // because the following call may delete "this" if (!interf->SourceAddrOKForRelaying(saveEnv, sourceAddr)) { if (strcmp(saveEnv.getResultMsg(), "") != 0) { // Treat this as a fatal error return -1; } else { continue; } } if (numMembers == 0) { // We know that we're going to forward to at least one // member, so fill in the tunnel encapsulation trailer. // (Note: Allow for it not being 4-byte-aligned.) TunnelEncapsulationTrailer* trailerInPacket = (TunnelEncapsulationTrailer*)&data[size]; TunnelEncapsulationTrailer* trailer; Boolean misaligned = ((uintptr_t)trailerInPacket & 3) != 0; unsigned trailerOffset; u_int8_t tunnelCmd; if (isSSM()) { // add an 'auxilliary address' before the trailer trailerOffset = TunnelEncapsulationTrailerAuxSize; tunnelCmd = TunnelDataAuxCmd; } else { trailerOffset = 0; tunnelCmd = TunnelDataCmd; } unsigned trailerSize = TunnelEncapsulationTrailerSize + trailerOffset; unsigned tmpTr[TunnelEncapsulationTrailerMaxSize]; if (misaligned) { trailer = (TunnelEncapsulationTrailer*)&tmpTr; } else { trailer = trailerInPacket; } trailer += trailerOffset; if (fDests != NULL) { trailer->address() = fDests->fGroupEId.groupAddress().s_addr; Port destPort(ntohs(fDests->fGroupEId.portNum())); trailer->port() = destPort; // structure copy } trailer->ttl() = ttlToFwd; trailer->command() = tunnelCmd; if (isSSM()) { trailer->auxAddress() = sourceFilterAddress().s_addr; } if (misaligned) { memmove(trailerInPacket, trailer-trailerOffset, trailerSize); } size += trailerSize; } interf->write(data, size); ++numMembers; } return numMembers; }
jchar SunJVMDLL::invokeCharStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]) { return env()->CallStaticCharMethodA(clazz, methodid, arguments); }
void SunJVMDLL::setLongField(jclass cls, jobject obj, const std::string& fieldName, jlong value) { jfieldID binding = env()->GetFieldID(cls, fieldName.c_str(), "J"); env()->SetLongField(obj, binding, (jlong)value); }
jlong SunJVMDLL::invokeLongStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]) { return env()->CallStaticLongMethodA(clazz, methodid, arguments); }
void SunJVMDLL::setObjectField(jclass cls, jobject obj, const std::string& fieldName, const std::string& fieldclass, jobject value) { std::string fc = "L" + StringUtils::replace(fieldclass, "." , "/") + ";"; jfieldID binding = env()->GetFieldID(cls, fieldName.c_str(), fc.c_str()); env()->SetObjectField(obj, binding, value); }
jobject SunJVMDLL::invokeObjectStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]) { return env()->CallStaticObjectMethodA(clazz, methodid, arguments); }
jstring SunJVMDLL::newUTFString(const std::string& str) { return env()->NewStringUTF(str.c_str()); }
jboolean SunJVMDLL::invokeBoolean(jobject& obj, jmethodID& methodid, jvalue arguments[]) { return env()->CallBooleanMethodA(obj, methodid, arguments); }
jobject SunJVMDLL::newObject(jclass clazz, jmethodID& methodid, jvalue arguments[]) { return env()->NewObjectA(clazz, methodid, arguments); }
jchar SunJVMDLL::invokeChar(jobject& obj, jmethodID& methodid, jvalue arguments[]) { return env()->CallCharMethodA(obj, methodid, arguments); }
jobjectArray SunJVMDLL::newObjectArray(int size, jclass clazz, jobject initialValue) { return env()->NewObjectArray((jsize)size, clazz, initialValue); }
jdouble SunJVMDLL::invokeDouble(jobject& obj, jmethodID& methodid, jvalue arguments[]) { return env()->CallDoubleMethodA(obj, methodid, arguments); }
void SunJVMDLL::invokeVoidStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]) { env()->CallStaticVoidMethodA(clazz, methodid, arguments); }
int main(int argc, char ** argv) { MPI_Init(&argc, &argv); QUESO::FullEnvironment env(MPI_COMM_WORLD, argv[1], "", NULL); QUESO::VectorSpace<QUESO::GslVector, QUESO::GslMatrix> paramSpace(env, "param_", 1, NULL); double min_val = 0.0; double max_val = 1.0; QUESO::GslVector paramMins(paramSpace.zeroVector()); paramMins.cwSet(min_val); QUESO::GslVector paramMaxs(paramSpace.zeroVector()); paramMaxs.cwSet(max_val); QUESO::BoxSubset<QUESO::GslVector, QUESO::GslMatrix> paramDomain("param_", paramSpace, paramMins, paramMaxs); QUESO::UniformVectorRV<QUESO::GslVector, QUESO::GslMatrix> priorRv("prior_", paramDomain); // Set up observation space QUESO::VectorSpace<QUESO::GslVector, QUESO::GslMatrix> obsSpace(env, "obs_", 2, NULL); // Fill up observation vector QUESO::GslVector observations(obsSpace.zeroVector()); observations[0] = 1.0; observations[1] = 1.0; // Fill up covariance 'matrix' QUESO::GslVector covariance(obsSpace.zeroVector()); covariance[0] = 1.0; covariance[1] = 1.0; // Pass in observations to Gaussian likelihood object Likelihood<QUESO::GslVector, QUESO::GslMatrix> lhood("llhd_", paramDomain, observations, covariance); QUESO::GenericVectorRV<QUESO::GslVector, QUESO::GslMatrix> postRv("post_", paramSpace); QUESO::StatisticalInverseProblem<QUESO::GslVector, QUESO::GslMatrix> ip("", NULL, priorRv, lhood, postRv); QUESO::GslVector paramInitials(paramSpace.zeroVector()); paramInitials[0] = 0.0; QUESO::GslMatrix proposalCovMatrix(paramSpace.zeroVector()); for (unsigned int i = 0; i < 1; i++) { proposalCovMatrix(i, i) = 0.1; } ip.solveWithBayesMetropolisHastings(NULL, paramInitials, &proposalCovMatrix); MPI_Finalize(); return 0; }
jboolean SunJVMDLL::invokeBooleanStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]) { return env()->CallStaticBooleanMethodA(clazz, methodid, arguments); }
void testSkipList() { beast::Journal const j; std::vector<std::shared_ptr<Ledger>> history; { jtx::Env env(*this); Config config; auto prev = std::make_shared<Ledger>(create_genesis, config, env.app().family()); history.push_back(prev); for (auto i = 0; i < 1023; ++i) { auto next = std::make_shared<Ledger>( *prev, env.app().timeKeeper().closeTime()); next->updateSkipList(); history.push_back(next); prev = next; } } { auto l = *(std::next(std::begin(history))); expect((*std::begin(history))->info().seq < l->info().seq); expect(hashOfSeq(*l, l->info().seq + 1, j) == boost::none); expect(hashOfSeq(*l, l->info().seq, j) == l->info().hash); expect(hashOfSeq(*l, l->info().seq - 1, j) == l->info().parentHash); expect(hashOfSeq(*history.back(), l->info().seq, j) == boost::none); } // ledger skip lists store up to the previous 256 hashes for (auto i = history.crbegin(); i != history.crend(); i += 256) { for (auto n = i; n != std::next(i, (*i)->info().seq - 256 > 1 ? 257 : 256); ++n) { expect(hashOfSeq(**i, (*n)->info().seq, j) == (*n)->info().hash); } // edge case accessing beyond 256 expect(hashOfSeq(**i, (*i)->info().seq - 258, j) == boost::none); } // every 256th hash beyond the first 256 is stored for (auto i = history.crbegin(); i != std::next(history.crend(), -512); i += 256) { for (auto n = std::next(i, 512); n != history.crend(); n += 256) { expect(hashOfSeq(**i, (*n)->info().seq, j) == (*n)->info().hash); } } }
jobject _PyImport_LoadDynamicModuleJy(char *name, char *pathname, FILE *fp) { //PyObject *m; jobject m; char *lastdot, *shortname, *packagecontext, *oldcontext; dl_funcptr p; //The following case is covered on Java-side now: /*if ((m = _PyImport_FindExtension(name, pathname)) != NULL) { Py_INCREF(m); return m; }*/ lastdot = strrchr(name, '.'); if (lastdot == NULL) { packagecontext = NULL; shortname = name; } else { packagecontext = name; shortname = lastdot+1; } //PyErr_Clear(); //added temporarily by JyNI to focus on further development until the exception thing is solved. p = _PyImport_GetDynLoadFunc(name, shortname, pathname, fp); //jputs("got dyn load func"); if (PyErr_Occurred()) { jputs("PyErrOccured00"); return NULL; } //jputs("error check done"); if (p == NULL) { //jputs("no init function"); //JyNI_JyErr_Format((*env)->GetStaticObjectField(env, pyPyClass, pyPyImportError), PyErr_Format(PyExc_ImportError, "dynamic module does not define init function (init%.200s)", shortname); return NULL; } //jputs("dyn load func is not NULL"); oldcontext = _Py_PackageContext; _Py_PackageContext = packagecontext; //jputs("run dyn load func..."); (*p)(); //jputs("run dyn load func done"); _Py_PackageContext = oldcontext; if (PyErr_Occurred()) { //puts("return NULL because PyErr_Occurred"); return NULL; } //m = PyDict_GetItemString(PyImport_GetModuleDict(), name); //jputs("retrieving module..."); //jputs(name); //the following somehow goes wrong, probaby because we didn't call String.intern... /*jobject mName = (*env)->CallStaticObjectMethod(env, pyPyClass, pyPyNewString, (*env)->NewStringUTF(env, name)); m = (*env)->CallObjectMethod(env, (*env)->CallStaticObjectMethod(env, JyNIClass, JyNIPyImport_GetModuleDict), pyDictGet_PyObject, mName );*/ env(NULL); m = (*env)->CallStaticObjectMethod(env, JyNIClass, JyNIJyNI_GetModule, (*env)->NewStringUTF(env, name)); //puts("retrieved module"); if (m == NULL) { //puts("m = NULL"); PyErr_SetString(PyExc_SystemError, "dynamic module not initialized properly"); return NULL; } //puts("name:"); //puts(PyModule_GetName(JyNI_PyObject_FromJythonPyObject(m))); // Remember the filename as the __file__ attribute //if (PyModule_AddStringConstant(m, "__file__", pathname) < 0) //puts("adding filename..."); // Todo: If pathname is NULL set __file__ to PyNone or something. if (pathname && PyModule_AddStringConstantJy(m, "__file__", pathname) < 0) PyErr_Clear(); // Not important enough to report //puts("filename added:"); //puts(PyModule_GetFilename(JyNI_PyObject_FromJythonPyObject(m))); //provide FixupExtension later... //if (_PyImport_FixupExtension(name, pathname) == NULL) // return NULL; //if (Py_VerboseFlag) if ((*env)->CallStaticIntMethod(env, JyNIClass, JyNIGetDLVerbose)) PySys_WriteStderr( "import %s # dynamically loaded from %s\n", name, pathname); //Py_INCREF(m); //jputs("module loaded:"); //jputs(name); //jputsLong(m); return m; }