本文整理汇总了C++中env函数的典型用法代码示例。如果您正苦于以下问题:C++ env函数的具体用法?C++ env怎么用?C++ env使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了env函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: env
jobject SunJVMDLL::invokeObject(jobject& obj, jmethodID& methodid, jvalue arguments[])
{
return env()->CallObjectMethodA(obj, methodid, arguments);
}
开发者ID:zach-m,项目名称:davmail,代码行数:4,代码来源:SunJVMDLL.cpp
示例2: luaopen_gbm
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;
//.........这里部分代码省略.........
开发者ID:dafrito,项目名称:luacxx,代码行数:101,代码来源:gbm.cpp
示例3: gameswf_engine_mutex
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();
}
开发者ID:85964596,项目名称:cocos2dx-swf,代码行数:75,代码来源:gameswf_root.cpp
示例4: deadEnemyRemove
//.........这里部分代码省略.........
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
}
开发者ID:yutatanaka,项目名称:GameJam2015_11,代码行数:101,代码来源:mainGame.cpp
示例5: main
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));
//.........这里部分代码省略.........
开发者ID:nkyrk,项目名称:test1,代码行数:101,代码来源:main.cpp
示例6: env
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;
}
开发者ID:cristipp,项目名称:JyNI,代码行数:88,代码来源:codecs.c
示例7: has_only_one_constructor
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;
}
开发者ID:soonhokong,项目名称:lean-osx,代码行数:6,代码来源:simp_inductive.cpp
示例8: iter
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;
}
开发者ID:MediaPortal,项目名称:MediaPortal-1,代码行数:81,代码来源:Groupsock.cpp
示例9: main
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;
}
开发者ID:EricDoug,项目名称:queso,代码行数:62,代码来源:diagonalCovariance.C
示例10: testSkipList
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);
}
}
}
开发者ID:bachase,项目名称:rippled,代码行数:71,代码来源:SkipList_test.cpp
示例11: _PyImport_LoadDynamicModuleJy
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;
}
开发者ID:Stewori,项目名称:JyNI-unstable,代码行数:94,代码来源:importdl.c
注:本文中的env函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论