我继承了一个Delphi应用程序,我对object pascal一无所知.
这是我需要编译到新版本的C++ Builder XE中的BPL.
当我运行make时,我得到错误:
E2064左侧无法分配.
我已经学会了足够多的obj pascal知道我有一个试图被赋值的常量.
但是,显然,你可以克服这种行为; 通过进入Delphi编译器下的Build选项并打开"Assignable Typed constants",实质上将常量转换为vars.
我这样做了,我继续得到同样的错误.
我尝试用{$ J +}和{$ J-}包围我的代码,但仍然无法编译.
procedure TChunkIDAT.CopyInterlacedRGB8(const Pass: Byte;
Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar );
var
Col: Integer;
begin
{Get first column and enter in loop}
Col := ColumnStart[Pass];
Dest := pChar(Longint(Dest) + Col * 3);
repeat
{Copy this row}
Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest);
Run Code Online (Sandbox Code Playgroud)
在最后一行获取错误.如果我将const更改为var,那么我会得到声明与前一个声明不同但我不知道前一个声明在哪里的错误....
是否有任何可以在GAE/J上运行的免费实现?
我正在阅读有关控制器http://www.playframework.org/documentation/1.1/controllers的文档,我知道如何在控制器端定义它们.
public static void show(Long[] id) {
...
}
or:
public static void show(List<Long> id) {
...
}
or:
public static void show(Set<Long> id) {
...
}
Run Code Online (Sandbox Code Playgroud)
现在,我如何调用控制器并传递数组?我试过了
Application/show?id=1,2,3,4
Run Code Online (Sandbox Code Playgroud)
它不起作用
使用Python可以实现以下功能:
$ apt-get install python
$ easy_install Flask
$ cat > hello.py
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run()
$ python hello.py
Run Code Online (Sandbox Code Playgroud)
用于运行Web服务器的4个命令和7行代码确实非常令人印象深刻.
什么是Scala等价物?
在Perl中,通过使用Template Toolkit,我就是这么做的
Perl的
my $vars = {
name => 'Count Edward van Halen',
};
$tt->process('letters/overdrawn', $vars)
|| die $tt->error(), "\n";
Run Code Online (Sandbox Code Playgroud)
HTML
Dear [% name %],
Run Code Online (Sandbox Code Playgroud)
在Mako模板中,我该怎么办?通过他们的render功能检查,没有得到太多提示.
如果有人能为css问题建议比stackoverflow更好的地方,请告诉我.
我有一个带背景和边框的外部div,然后我需要在彩色框内有两列.有些原因,当我将浮动div放在外部div中时,外部div不会增长.
这是我的HTML:
<div class="tip_box">
<h3>Send</h3>
<hr />
<form id="email_form">
<div class="three-columns">
<div class="contact_form_input">
<h6>Your Name</h6>
<input type="text" name="name_text_box" class="form_input" id="name_text_box" />
</div>
<div class="contact_form_input">
<h6>Your Email</h6>
<input type="text" name="email_text_box" class="form_input" id="email_text_box" />
</div>
</div>
<div class="three-columns">
<div class="contact_form_input">
<h6>Recipient Name</h6>
<input type="text" name="name_text_box" class="form_input" id="Text1" />
</div>
<div class="contact_form_input">
<h6>Recipient Email</h6>
<input type="text" name="email_text_box" class="form_input" id="Text2" />
</div>
</div>
</form>
</div>
<p>This is where your message will go. Anything you want, as long as you want. Make it personal; …Run Code Online (Sandbox Code Playgroud) 我需要一些关于如何编写Python程序的建议,它给出了列表格式中前n个完美正方形的列表.输出应如下所示:
How many squares?: 5 [1, 4, 9, 16, 25]
这是我到目前为止:
n = int(raw_input("How many squares? "))
Run Code Online (Sandbox Code Playgroud)
现在,对于下一部分,我需要创建前n个方块的列表.有关如何的任何建议?感谢您的时间和建议.
我必须要有一个时刻,因为这应该很容易,但我似乎无法让它正常工作.
什么是在GCC中实施原子计数器的正确方法?
即我想要一个从0到4运行的计数器并且是线程安全的.
我这样做(这是进一步包装在一个类,但不是在这里)
static volatile int _count = 0;
const int limit = 4;
int get_count(){
// Create a local copy of diskid
int save_count = __sync_fetch_and_add(&_count, 1);
if (save_count >= limit){
__sync_fetch_and_and(&_count, 0); // Set it back to zero
}
return save_count;
}
Run Code Online (Sandbox Code Playgroud)
但它从1到4(包括1和4),然后从大约到零.
它应该从0到3.通常我会使用mod运算符进行计数器,但我不知道如何安全地执行此操作.
也许这个版本更好.你能看到它的任何问题,或提供更好的解决方案.
int get_count(){
// Create a local copy of diskid
int save_count = _count;
if (save_count >= limit){
__sync_fetch_and_and(&_count, 0); // Set it back to zero
return 0;
}
return save_count;
}
Run Code Online (Sandbox Code Playgroud)
实际上,我应该指出,每个线程获得不同的值并不是绝对关键的.如果两个线程碰巧同时读取相同的值,则不会出现问题.但他们随时都不能超过限制.
这是我的"targetMethod"的方法签名:
-(void)targetMethod: (id)arg;
Run Code Online (Sandbox Code Playgroud)
这有效:
[myObject targetMethod:@"called the regular way"];
Run Code Online (Sandbox Code Playgroud)
事实并非如此
[myObject performSelector:@selector(targetMethod) withObject:@"called using selector"];
Run Code Online (Sandbox Code Playgroud)
它会导致以下错误:
- [SelectorTest targetMethod]:无法识别的选择器发送到实例0x4e075d0
我究竟做错了什么?