为什么这些甚至存在?这似乎很荒谬。与大多数动态语言一样,AppleScript 类型似乎是不可变的原始类型(如integer
s 和real
s),它们将按值传递,与 一起使用没有任何意义a reference to
,或者是类似对象的类型(如application
s、script
s 或record
s,它们已经通过引用传递。怎样才算a reference to
不完全多余呢?以下是摘自 Apple 的 AppleScript 语言指南 ( https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/introduction/ASLR_intro.html )的示例:
tell app "Finder" to set diskRef to a ref to startup disk
--result: startup disk of application "Finder"
Run Code Online (Sandbox Code Playgroud)
那么你的意思是告诉我如果我这样做的话
tell app "Finder" to set diskObj to startup disk
--result: startup disk of application "Finder"
Run Code Online (Sandbox Code Playgroud)
applescript 运行时将向 Finder 进程发送一个 apple 事件,告诉它,“嘿 - 有人刚刚要求你将 /dev/disks01 的八位字节流返回给我!哈哈!我想他应该问一下为了a reference to
它!让我们开始吧!这需要一段时间!”
我正在用 …
我在基于scons重构构建系统时遇到了一些问题.我们有一个C/C++源代码树,它包含几个不同的输出对象(dll,可执行文件,测试可执行文件),以及我们的源文件的某种异构布局(尽管它大多数位于带有src/
和inc/
目录的'module' 目录中).
当前设置的一个最大问题是我们真的希望所有这些构建产品默认使用一致的编译器选项构建.我们当前的布局有一个主SConstruct文件,在子目录中调用许多子SConscript文件,然后构建更大的构建产品(.a
例如).默认情况下,SConscript()
scons中的函数不会将当前构造环境对象传递或继承到被调用的SConstruct文件.这意味着目前所有这些子SConstript文件都使用自己不同的构造环境.
我正在尝试组合的新布局有一个主构建环境,它在源树根处放在一起,包含我们需要的所有必需的CFLAGS和构建定义.我想这样的施工环境要传递到子SConscript文件,使我知道,每一个.c
和.cpp
我们构建树文件正在建有相同的命令行.
不过,我不确定如何在scons中这样做.有Import()
和Export()
函数,但那些基本上是丑陋的全局变量 - 调用SConstruct文件没有很多控制子SConstruct文件使用全局变量做什么Export()
.是否有任何干净的方法基本上将子SConscript文件作为参数处理当前构造环境,而不必让它必须修改它?有点像:
master_env = Environment()
master_env.Append( CXXFLAGS=['-Wall', '-Werror', '-g', '-fPIC', ... ] )
### add other stuff that we want everything to use
SConscript( 'somelibrary/SConstruct', inherited_environment=master_env.Clone() )
### master_env has now been used to build a
### .dll in somelibrary/, but any variations
### made to somelibrary/SConstruct's inherited
### env haven't contaminated master_env
Run Code Online (Sandbox Code Playgroud)
我知道我可以做一些笨拙的事情,有点像这样:
clobber_env = Environment() …
Run Code Online (Sandbox Code Playgroud) 我在OS X检测按键时遇到问题。每当按下键盘键时,我都需要检测按键按下,释放或按键释放。当使用拦截应用程序的事件处理链时,这非常简单[ NSEvent addLocalMonitorForEventsMatchingMask: handler: ]
。这样,您可以截取和修改NSEvent
s的各种事件类型,包括NSKeyUp
和NSKeyDown
常规打印键,以及NSFlagsChanged
可用于检测shift,ctrl,alt和cmd键的s 。事实上,由于修正标志更改两个关键起来为Shift,Ctrl,Alt和CMD键按下按键,NSFlagsChanged
可以用来作为检查的重要上升,键按下事件对于那些键[NSEvent modifierFlags]
与一起[NSEvent keyCode]
。
但Capslock是不同的。因为capslock修饰符实际上仅作用于向下按下键,所以当您按下capslock时,只会获得NSFlagsChanged
带有capslock的按下,而不是在释放时按下。并且NSKeyUp
和NSKeyDown
不会与Capslock和shift和ctrl等修饰键一起发出。
任何人都可以建议一种方法,甚至可以使用较低级别的界面来获取capslock键启动事件吗?我是否将不得不使用kqueues或其他东西?
有没有一种安全的方法可以在不调用QApplication :: exec()的情况下使用Qt?
我有许多不同的对象在多个资源上执行长期存在的进程(其中至少有一个与Web应用程序服务器通信).我正在制作一个GUI应用程序,提示用户在适当的时间输入这些不同的进程.我想让我的'流'逻辑 - 决定下一步做什么的逻辑 - 在一个地方而不是像对话类这样的GUI对象.我以为我可以这样做:
...
wait_dialog dlg;
dlg.setModal( false );
dlg.show(); // Should return...
netobject.start_long_lived_process_that_happens_on_other_thread( &completion_callback );
while ( !completion_callback_called() )
{
qApp->processEvents();
netobject.pump_callbacks();
magically_avoid_busywait_while_still_servicing_qt_somehow();
}
dlg.hide();
...
Run Code Online (Sandbox Code Playgroud)
从Qt的角度来看,这样安全吗?有一种"好"的实施方式magically_avoid_busywait_while_still_servicing_qt_somehow()
吗?
我在这里要完成的是以最明确的方式编写我们的处理流程.我想要一个这样做的功能:
show_a_non_modal_wait_dialog()
start_some_processing_1()
wait_for_processing_1_to_finish()
dismiss_non_modal_wait_dialog()
show_modal_input_dialog()
if ( cancelled ) return
show_a_non_modal_wait_dialog()
start_some_processing_2()
wait_for_processing_2_to_finish()
dismiss_non_modal_wait_dialog()
show_modal_input_dialog()
if ( cancelled ) return
...
Run Code Online (Sandbox Code Playgroud)
我真正想要避免的是开始等待Qt小部件和窗口内的处理.此外,处理对象本身完全独立于Qt.我想我要做的是在单个函数中创建一个带有一些辅助回调和状态变量的控制器.
如果我有一个X509*
openssl提供给我的,那么在证书中找出RSA公钥的位数的最佳方法是什么?我无法弄清楚这一点.我很确定如果我在SSL证书验证回调中,我可以使用X509 ptr
X509 * cert = X509_STORE_CTX_get_current_cert(the_x509_store_ctx);
Run Code Online (Sandbox Code Playgroud)
我猜测我得到这样的公钥
EVP_PKEY *public_key = X509_get_pubkey(cert);
Run Code Online (Sandbox Code Playgroud)
然后我需要检查它是否是RSA,大概是?
if (public_key && (EVP_PKEY_RSA == public_key->type))
Run Code Online (Sandbox Code Playgroud)
一旦我知道我拿回公钥并且它是RSA,我想这样做:
int key_length = BN_num_bits(public_key->pkey.rsa->n);
Run Code Online (Sandbox Code Playgroud)
但我发现虽然这在openssl 0.9.8上非常好用,但在1.0.1h它在Windows上是段错误.BIGNUM'n'似乎没有效果 - 它中的数据ptr有一个垃圾指针.
知道什么是错的吗?
我一直在使用http://doc.qt.digia.com/4.7/qdeclarativemodels.html中的示例,这是关于QML声明性数据模型的Qt页面.特别是,我正在使用objectlistmodel
Qt SDK附带的示例(在examples/declarative/modelviews/objectlistmodel中).这一切似乎都运行得相当好,直到我尝试将它与http://www.developer.nokia.com/Community/Wiki/How_to_create_a_Page_Control_component_in_QML上的QMLPageControl示例结合起来.
当我尝试使用QML ListView显示基于QML的ListModel(使用QML ListElements填充)时,如下所示:
import QtQuick 1.0
Rectangle {
width: 200; height: 200
ListModel {
id: qmlModel
ListElement { name: "qml entry1 (red)"; colour: "red" }
ListElement { name: "qml entry2 (orange)"; colour: "orange" }
ListElement { name: "qml entry3 (yellow)"; colour: "yellow" }
ListElement { name: "qml entry4 (green)"; colour: "green" }
ListElement { name: "qml entry5 (blue)"; colour: "blue" }
ListElement { name: "qml entry6 (purple)"; colour: "purple" }
}
ListView …
Run Code Online (Sandbox Code Playgroud) I'm apparently not the only one who wants to know (How can I change modifier keys in "System Preferences > Keyboard > Modifier Keys..."). I've tried watching the System Preferences app with dtruss, but that doesn't seem to be possible on 10.10.3 (which is what I'm on right now), and I'm not even sure that that would be at all useful if System Preferences is just getting settings from cfprefsd. Watching cfprefsd with dtruss doesn't seem to catch …
谁能告诉我boost::asio
的io_service::run()
方法在什么条件下会返回?的io_service::run()
文档似乎表明,只要有工作要做或需要派遣处理程序,run()
就不会返回。
我问这个问题的原因是我们有一个旧的 https 客户端,它联系服务器并执行 http POST。客户端中的关注点分离与我们想要的有点不同,因此我们正在更改一些内容,但我们遇到了问题。
现在,客户端基本上有一个命名错误的connect()
调用,它有效地驱动了与服务器的整个协议对话。调用connect()
首先创建一个boost::asio::ip::tcp::resolver
对象并调用::async_resolve()
它。这将启动一个链,其中asio
从 asio 回调中进行新的调用。
void connect()
{
m_resolver.async_resolve( query, bind( &clientclass::resolve_callback, this ) );
thread = new boost::thread( bind( &boost::asio::io_service::run, m_io_service ) );
}
void resolve_callback( error_code & e, resolver::iterator i )
{
if (!e)
{
tcp::endpoint = *i;
m_socket.lowest_layer().async_connect(endpoint, bind(&clientclass::connect_callback,this,_1,++i));
}
}
void connect_callback( error_code & e, resolve::iterator i )
{
if (!e)
{
m_socket.lowest_layer().async_handshake(boost::asio::ssl::stream_base::client, …
Run Code Online (Sandbox Code Playgroud) 我正在使用Visual C++ 2008将C++程序从Windows构建转换为使用gcc 4.6.1在Linux上构建.有一个使用的模块<unordered_map>
.在VC++中,似乎完全没问题
#include <unordered_map>
...
std::tr1::unordered_map<mystruct, int> my_map;
Run Code Online (Sandbox Code Playgroud)
我们实际上支持的编译器不仅仅是gcc 4.6和VC++ 2008,因此使用纯C++ 2011代码是不可行的.gcc很生气#include <unordered_map>
,抱怨这是真正的蓝色c ++ 2011包含文件,因此我必须做的一件事就是将include更改为
#include <tr1/unordered_map>
...
std::tr1::unordered_map<mystruct, int> my_map;
Run Code Online (Sandbox Code Playgroud)
这有效.很公平.不过现在我还有另外一个问题.这是mystruct的定义:
struct mystruct
{
#ifdef __cplusplus
inline operator size_t() const
{
return m_val;
}
#endif
unsigned int m_val;
};
Run Code Online (Sandbox Code Playgroud)
在VC++ 2008中,这似乎与std::hash
需要专注的一样多mystruct
.std::tr1::hash
另一方面,不喜欢这个,至少在gcc 4.6.1上没有.它拒绝链接,抱怨std::tr1::hash<mystruct>::operator()( mystruct ) const
未定义.当我做正确的tr1
包含时,我不确定VC++是否会发生这种情况- 也许它会抱怨同样的事情?我明天会试试,但是现在我所有的都是带有gcc的linux盒子.现在,我必须这样做才能让它工作:
namespace std {
namespace tr1 {
std::size_t hash<mystruct>::operator()( mystruct & c ) const
{
return c.m_val;
} …
Run Code Online (Sandbox Code Playgroud) 有谁知道如何检测用户何时更改 OSX 中的当前输入源?
我可以调用TISCopyCurrentKeyboardInputSource()
来找出正在使用哪个输入源 ID,如下所示:
TISInputSourceRef isource = TISCopyCurrentKeyboardInputSource();
if ( isource == NULL )
{
cerr << "Couldn't get the current input source\n.";
return -1;
}
CFStringRef id = (CFStringRef)TISGetInputSourceProperty(
isource,
kTISPropertyInputSourceID);
CFRelease(isource);
Run Code Online (Sandbox Code Playgroud)
如果我的输入源是“德语”,那么 id 最终会是“com.apple.keylayout.German”,这主要是我想要的。除了:
TISCopyCurrentKeyboardInputSource()
不会改变吗?特别是,我可以TISCopyCurrentKeyboardInputSource()
循环调用并切换输入源,但TISCopyCurrentKeyboardInputSource()
不断返回进程开始时的输入源。在Rust中,有没有一种方法可以将时区缩写(如EST
或MDT
)解析为时区偏移量(例如-5小时或-7小时)?该chrono_tz箱子看起来几乎要做到这一点,但并不完全。
c++ ×5
keyboard ×3
macos ×3
c ×2
cocoa ×2
qt ×2
appkit ×1
appleevents ×1
applescript ×1
boost ×1
boost-asio ×1
build ×1
c++11 ×1
capslock ×1
chrono-tz ×1
datamodel ×1
events ×1
gcc ×1
macos-carbon ×1
nsevent ×1
openssl ×1
preferences ×1
python ×1
qml ×1
reference ×1
rsa ×1
rust ×1
scons ×1
ssl ×1
timezone ×1
tr1 ×1
visual-c++ ×1
x509 ×1