Re: problem creating a berkeley db binding

2009-08-30 Thread Sergey Gromov
Sun, 30 Aug 2009 11:28:16 -0400, JT wrote: > i'm trying to create a binding for berkeley db dll and quickly ran > into some problems, how do i translate statement below. > > int DB->open(DB *db, DB_TXN *txnid, const char *file, > const char *database, DBTYPE type, u_int32_t flags, int mode);

Re: D2 Singleton / Thread Local Storage issue

2009-08-30 Thread Sergey Gromov
Sat, 29 Aug 2009 22:03:47 -0400, sybrandy wrote: > Hello, > > I've been learning D for some time now and I recently was trying to do > some work with threads, but I'm having a problem getting it to work. > I'm trying to create a singleton that can be accessed between threads, > however I get a

Re: Export static data

2009-08-22 Thread Sergey Gromov
Fri, 21 Aug 2009 12:01:48 -0400, Jarrett Billingsley wrote: > On Fri, Aug 21, 2009 at 11:10 AM, Dan wrote: >> Another issue I had was with the name decoration. I need to be able >> to export an "InitProc". The closest I was able to get was >> "_InitProc" and "INITPROC". Is there a way to drop the

Re: deleting items from 2d arrays

2009-08-15 Thread Sergey Gromov
Fri, 14 Aug 2009 13:55:18 +1000, Daniel Keep wrote: > void dropElement(T)(ref T[] arr, size_t i) > { > assert( i < arr.length ); > arr[i] = arr[$-1]; > arr = arr[0..$-1]; > } I think it's important to erase the last element after the move to make sure no dangling references to unused

Re: deleting items from 2d arrays

2009-08-14 Thread Sergey Gromov
Thu, 13 Aug 2009 22:59:37 -0400, Michael P. wrote: > foreach( Block[] ba; level ) > { > foreach( Block b; ba ) > { > if( checkCollision( ball, b.p ) ) > { > //remove the block?? > } > } > } I like Daniel's answer be

Re: setIntersection of struct range

2009-08-12 Thread Sergey Gromov
Tue, 11 Aug 2009 19:35:40 -0400, Jesse Phillips wrote: > I am trying to obtain a rang that is the intersection of two other ranges. To > do this I am using the _setIntersection()_ function. > > import std.algorithm; > import std.stdio; > > struct S { > string label; > } >

Re: noob question

2009-08-06 Thread Sergey Gromov
Thu, 06 Aug 2009 10:56:33 -0400, lllTattoolll wrote: > hi Lars and thx for help. I fix a little the first problem, now I paste a > verion in english whit coment because i´m lost here. > the example is the same only this is in english for your compresion of my > problem. > >

Re: Shared Object with DMD v2.031

2009-08-05 Thread Sergey Gromov
Wed, 5 Aug 2009 20:46:53 + (UTC), teo wrote: > On Tue, 04 Aug 2009 18:41:50 +0400, Sergey Gromov wrote: > >> Sun, 2 Aug 2009 11:18:24 + (UTC), teo wrote: >> >>> On Sun, 02 Aug 2009 02:18:28 +0400, Sergey Gromov wrote: >>> >>>> My gue

Re: At compile time

2009-08-05 Thread Sergey Gromov
Tue, 04 Aug 2009 19:57:19 -0400, bearophile wrote: > D2 is now able to execute math functions (sin, cos, sqrt, etc) at compile > time. > > [snip] > > But similar D2 program produces, with DMD v.2.031: > test.d(12): Error: non-constant expression (V3(1,2,3)).norm() > > // D2 code > import std.m

Re: Shared Object with DMD v2.031

2009-08-04 Thread Sergey Gromov
Sun, 2 Aug 2009 11:18:24 + (UTC), teo wrote: > On Sun, 02 Aug 2009 02:18:28 +0400, Sergey Gromov wrote: > >> My guess is that test.di is exactly the same as test.d because all the >> functions are small. Therefore compiling 'dmd prog.d test.di' resolves >>

Re: byte to char safe?

2009-08-02 Thread Sergey Gromov
Mon, 3 Aug 2009 04:11:31 +0400, Sergey Gromov wrote: > If you want consistent output you should those > special characters to some printable form. Sorry, this sentence has a typo: If you want consistent output you should *convert* those special characters to some printable form.

Re: byte to char safe?

2009-08-02 Thread Sergey Gromov
Sat, 01 Aug 2009 19:58:20 -0400, Harry wrote: > Sergey Gromov Wrote: > >> Thu, 30 Jul 2009 19:14:56 -0400, Harry wrote: >> >>> Ary Borenszweig Wrote: >>> >>>> Harry escribi��> > Again hello, >>>>> >>>>> ch

Re: Shared Object with DMD v2.031

2009-08-01 Thread Sergey Gromov
Fri, 31 Jul 2009 18:50:28 + (UTC), teo wrote: > On Fri, 31 Jul 2009 18:47:29 +0400, Sergey Gromov wrote: > >> Thu, 30 Jul 2009 06:52:14 + (UTC), teo wrote: >> >>> I have difficulties creating a Shared Object (.so) with D. Is it >>> possible? Can I use

Re: Shared Object with DMD v2.031

2009-07-31 Thread Sergey Gromov
Thu, 30 Jul 2009 06:52:14 + (UTC), teo wrote: > I have difficulties creating a Shared Object (.so) with D. Is it > possible? Can I use classes defined in the library from the executable? > > Here is my library file: > module test; // file "test.d" > export int testMe() { return 1; } > export

Re: byte to char safe?

2009-07-31 Thread Sergey Gromov
Thu, 30 Jul 2009 19:14:56 -0400, Harry wrote: > Ary Borenszweig Wrote: > >> Harry escribi��> > Again hello, >>> >>> char[6] t = r"again" ~ cast(char)7 ~ r"hello"; >> >> If you want the result to be "again7hello", then no. You must do: >> >> char[6] t = r"again" ~ '7' ~ r"hello"; >> >> or: >>

Re: byte to char safe?

2009-07-31 Thread Sergey Gromov
Thu, 30 Jul 2009 18:29:09 -0400, Harry wrote: > BCS Wrote: > >> Reply to Harry, >> >>> Again hello, >>> >>> char[6] t = r"again" ~ cast(char)7 ~ r"hello"; >>> >>> use only own write functions >>> is ok? >>> thank you! >>> >> >> I think this will also work and you can be shure it's safe. >>

Re: Pointer to method C++ style

2009-07-24 Thread Sergey Gromov
Fri, 24 Jul 2009 02:51:45 +0400, Sergey Gromov wrote: > Thu, 23 Jul 2009 19:07:43 +0200, BLS wrote: > >> Sergey Gromov wrote: >>> Sorry, I'm not a guru at all, so ActiveX was a misnomer. What I'm >>> writing is a simple in-process server DLL whi

Re: Pointer to method C++ style

2009-07-24 Thread Sergey Gromov
Fri, 24 Jul 2009 09:07:30 -0400, Steven Schveighoffer wrote: > On Thu, 23 Jul 2009 22:09:12 -0400, Sergey Gromov > wrote: > >> Thu, 23 Jul 2009 11:54:40 -0400, Steven Schveighoffer wrote: >> >>> LOOKUP_TABLE[0] = Method("method1", &Com

Re: Pointer to method C++ style

2009-07-23 Thread Sergey Gromov
Thu, 23 Jul 2009 11:54:40 -0400, Steven Schveighoffer wrote: > On Wed, 22 Jul 2009 23:47:30 -0400, Sergey Gromov > wrote: > >> Is there a way to declare and statically initialize some sort of pointer >> to method, and later call it for an actual object instance? > >

Re: Pointer to method C++ style

2009-07-23 Thread Sergey Gromov
Thu, 23 Jul 2009 19:07:43 +0200, BLS wrote: > Sergey Gromov wrote: >> Sorry, I'm not a guru at all, so ActiveX was a misnomer. What I'm >> writing is a simple in-process server DLL which implements a couple of >> interfaces. > > Oh, that's sad. :(

Re: Pointer to method C++ style

2009-07-23 Thread Sergey Gromov
Thu, 23 Jul 2009 04:11:14 + (UTC), BCS wrote: > Hello Sergey, > >> Is there a way to declare and statically initialize some sort of >> pointer to method, and later call it for an actual object instance? >> > > dosn't work but might point you in the right direction: > > template Pn2Fn(R, ch

Re: Pointer to method C++ style

2009-07-23 Thread Sergey Gromov
Thu, 23 Jul 2009 12:37:42 +0200, BLS wrote: >Sergey Gromov wrote: >> Use case: I'm writing an ActiveX plug-in for a dynamic language. The > > However, I am _very_ interested in having/seeing the source of a very > basic ActiveX control. Any chance that you share the core

Pointer to method C++ style

2009-07-22 Thread Sergey Gromov
Is there a way to declare and statically initialize some sort of pointer to method, and later call it for an actual object instance? Use case: I'm writing an ActiveX plug-in for a dynamic language. The language queries the component for implemented methods, then it requests these methods to be ex

Re: Bit operator conversions

2009-04-08 Thread Sergey Gromov
Wed, 08 Apr 2009 12:06:48 -0400, Kagamin wrote: > Sergey Gromov Wrote: > >> Mon, 06 Apr 2009 08:53:41 -0400, Kagamin wrote: >> >>> Is it valid for this to compile: >>> --- >>> ushort a(ushort b) pure nothrow >>> { return b

Re: Bit operator conversions

2009-04-07 Thread Sergey Gromov
Mon, 06 Apr 2009 08:53:41 -0400, Kagamin wrote: > Is it valid for this to compile: > --- > ushort a(ushort b) pure nothrow > { return b<<10|b; } > --- > > And for this to not compile: > --- > ushort a(ushort b) pure nothrow > { return b<<10; } > --- > ? They both compile with 2.026.

Re: wchar[] and wchar*

2009-04-07 Thread Sergey Gromov
Tue, 07 Apr 2009 01:32:59 -0400, novice2 wrote: > hi! > could you advice me, please, what techniques should be used > while working with D wchar[] and C wchar* (e.g. Windows unicode API named > ...W()). > > how to pass wchar[] to FuncW(wchar*) and back? Since most of FuncW require not only the

Re: No segfault -> null == ""

2009-03-31 Thread Sergey Gromov
Tue, 31 Mar 2009 16:29:30 +0200, Qian Xu wrote: > When I was trying to learn how char-array works, I found something > unexpected. > > -- code -- > module string_test; > > void main() > { > // test 1 > assert(null == "", "null is empty"); /

Re: synchronized / cond.wait

2009-03-31 Thread Sergey Gromov
Tue, 31 Mar 2009 15:37:33 +0200, Stefan Rohe wrote: > could someone explain us this "synchronize" behaviour? We do not understand > it. > > Two Threads. > First Thread should wait for a condition. This we do in a > synchronized(mutex) block. > The second Thread broadcasts then a notify. This also

Re: dwt2 help

2009-03-25 Thread Sergey Gromov
Thu, 26 Mar 2009 01:40:25 +0100, Saaa wrote: >>> [...] >>> >>> catch(Object e){ // ConvError or ConvOverflowError >>> //Is this the correct translation? >>> throw new NumberFormatException( e ); >>> } >> >> It depends on what NumberFormatException can accep

Re: dwt2 help

2009-03-25 Thread Sergey Gromov
Thu, 26 Mar 2009 00:29:44 +0100, Saaa wrote: > I filled in the Phobos implementation, but I'm not sure if it is all correct > as I don't fully understand the exception handling. > > [...] > > catch( IllegalArgumentException e ){ > //How does this work? It catches e and gives it as an

Re: convert javah headers to D

2009-03-16 Thread Sergey Gromov
Mon, 16 Mar 2009 15:46:46 + (UTC), Nicholas Jordan wrote: > import placed in source file, will do a build later today as I am > swamped with simple survival stuff today. > > What I don't get is, given that javap pulls headers, I tried to use > the headers so that the JVM could call the dll. S

Re: convert javah headers to D

2009-03-15 Thread Sergey Gromov
Sun, 15 Mar 2009 21:37:48 + (UTC), Nicholas Jordan wrote: > I got this far, compiler is stating I should: > "semicolon expected, not 'TWAIN_AcquireNative'" You use lots of undefined symbols in this module: HANDLE, EZTAPI, HWND, unsigned etc. The compiler can't read your mind so you must

Re: recognizing asciiz, utf ...

2009-03-15 Thread Sergey Gromov
Sun, 15 Mar 2009 05:20:08 -0400, newbee wrote: > Sergey Gromov Wrote: > >> Fri, 13 Mar 2009 15:04:12 -0400, newbee wrote: >> >>> How does one check for asciiz, utf ...? >>> I do get a buffer with characters as parameter in a function, but i >>> don�

Re: # operator under C implementation in D1

2009-03-14 Thread Sergey Gromov
Thu, 12 Mar 2009 21:19:11 -0400, Sam Hu wrote: > I know a little that in C there is a # operator which under a macro > can return any type's value in character format.Just wanna know > whether there is an equivelent implementation in D1.Say,in C using > a/m macro can easily output enum's character

Re: # operator under C implementation in D1

2009-03-14 Thread Sergey Gromov
Thu, 12 Mar 2009 23:44:40 -0400, Sam Hu wrote: > Here I found an example form tango.io.Console class Output: > class Output > { > private Buffer buffer; > private boolredirect; > > public alias append opCall; > public

Re: recognizing asciiz, utf ...

2009-03-14 Thread Sergey Gromov
Fri, 13 Mar 2009 15:04:12 -0400, newbee wrote: > How does one check for asciiz, utf ...? > I do get a buffer with characters as parameter in a function, but i > don’t know if it is asciiz or utf or wchar. Is it possible to find > out in dmd1 and dmd2? There is some redundancy in UTF-8 format so

Re: Dear toolchain...

2009-03-12 Thread Sergey Gromov
Tue, 10 Mar 2009 18:45:26 +0100, Simen Haugen wrote: > I've spent at least 8 hours so far trying to locate the error with no luck. > Does anyone have any good ideas how I can proceed? > Or perhaps a pointer in the direction for narrowing down my search? You're using tango, so you may want to try

Re: Newbie question: COM programming and linking to Windows libraries

2009-03-12 Thread Sergey Gromov
Thu, 12 Mar 2009 17:12:41 -0400, Patrick Kristiansen wrote: > The compiler fails with the following error: > > setwallp.obj(setwallp) > Error 42: Symbol Undefined _coinitial...@4 > --- errorlevel 1 The implib doesn't produce acceptable results for Windows system DLLs. It does cre

Re: my first link error: Error 42: Symbol Undefined __moduleUnitTests

2009-03-02 Thread Sergey Gromov
Fri, 27 Feb 2009 20:37:56 -0500, Fei wrote: > I'm trying to compile my first d sample, winsamp.d, using dmd 2.025 for > windows. > > dmd winsamp.d gdi32.lib > > everything seem ok but I got a link error : > Error 42: Symbol Undefined __moduleUnitTests > > what lib should I include for moduleUn

Re: Deleting an element from an array

2009-02-21 Thread Sergey Gromov
Tue, 3 Feb 2009 18:11:35 +0100, nobody wrote: > "Jarrett Billingsley" wrote in message > news:mailman.637.1233680615.22690.digitalmars-d-le...@puremagic.com... >> On Tue, Feb 3, 2009 at 11:51 AM, nobody wrote: >>> Would you also happen to know why the following gives an error? >>> >>> arr[1] =

Re: Batch files for running multiple DMD versions?

2009-02-19 Thread Sergey Gromov
Wed, 18 Feb 2009 15:41:34 -0800, Lawrence Hemsley wrote: > This link will go to the download page of the junction > utility. Has usage on it also. > > http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx > > Lawrence Hemsley wrote: >> I use batch files to switch between dmd 1 versions

Re: loop through specific class members

2009-01-26 Thread Sergey Gromov
Mon, 26 Jan 2009 04:50:10 + (UTC), BCS wrote: > Hello Sergey, > >> foreach() is a runtime construct. It may be *interpreted* at >> compile-time, but it's interpreted as if it were run time >> nevertheless. It dynamically changes the value of 'member' variable. > > OTOH a foreach on a tuple

Re: loop through specific class members

2009-01-25 Thread Sergey Gromov
Wed, 21 Jan 2009 12:48:07 +0100, Trass3r wrote: > Christopher Wright schrieb: >> On the other hand, you can get the non-final, non-private methods of a >> class with something like: >> foreach (member; __traits (allMembers, Class)) >> { >> foreach (overload; __traits (getVirtualFunctions, Cla

Re: Is there a way to remove the requirement for parenthesis?

2009-01-25 Thread Sergey Gromov
Wed, 21 Jan 2009 09:24:01 -0800, Charles Hixson wrote: > In this test I'm trying to emulate how I want a typedef to act, but I > run into a problem: > > import std.stdio; > > struct BlockNum > { uint value; > > uint opCast() { return value; } > void opAssign (uint va

Re: how to use dll

2009-01-25 Thread Sergey Gromov
Wed, 21 Jan 2009 23:19:48 -0500, reimi gibbons wrote: > I'm currently developing a software with D and Tango. I don't have > much knowledge on DLL, but i do know when linking to static lib you > need a .h header file, but do i need .h for linking with DLL as well? > > > also can anybody please p

Re: compile time output

2009-01-20 Thread Sergey Gromov
Tue, 20 Jan 2009 21:12:18 + (UTC), BCS wrote: > Reply to Trass3r, > >> Sergey Gromov schrieb: >> >>> auto members = __traits(allMembers, Cls); >> >> Seeing this really simple example crashing makes me think that this >> has to be a bug. >&g

Re: compile time output

2009-01-20 Thread Sergey Gromov
Tue, 20 Jan 2009 16:36:09 +0100, Trass3r wrote: > Is there any way to output information at compile time other than > pragma(msg? > pragma is driving me crazy, the following doesn't work: > > auto members = __traits(allMembers, typeof(this)); > foreach(m; members) > { > pragma(msg, m); > }

Re: D_Version2 problem

2009-01-18 Thread Sergey Gromov
Sun, 18 Jan 2009 22:28:12 +0100, Hoenir wrote: > The D_Version2 version identifier doesn't work properly for me. > Tried compiling with dmd 1.039. D_Version2 is set even if I pass -v1 to it. > > Is this a bug or am I doing something wrong? Works for me. It's hard to tell if you're doing somethi

Re: Getting line number where error occured?

2009-01-15 Thread Sergey Gromov
Thu, 15 Jan 2009 13:08:35 -0500, Kagamin wrote: > Bill Baxter Wrote: > >> Nothing built-in for this, >> but there are the backtrace hacks: >> http://team0xf.com/index.php?n=Site.Download >> Never tried those myself though. >> >> I use a debugger when I need a stack trace. >> http://ddbg.mainia.

Re: Getting line number where error occured?

2009-01-14 Thread Sergey Gromov
Thu, 15 Jan 2009 02:47:07 +0100, Hoenir wrote: > Might be a dumb question, but is it possible in any way to get the line > number where an error occured? > Don't think so, but maybe I'm missing something. assert gives a line number. There's also a keyword, __LINE__, which is an expression evalu

Re: timezone problem

2009-01-13 Thread Sergey Gromov
Tue, 13 Jan 2009 11:27:40 +0100, Qian Xu wrote: > Hi All, > > I am fighting with date time conversion and have a problem right now: > I want to convert a local timestamp to UTC timestamp. > So I have to get the time zone information. > However in some countries (ie. German, US), the offset is not

Re: using a typedefed variable with library classes

2009-01-12 Thread Sergey Gromov
Tue, 13 Jan 2009 05:59:58 +0900, Bill Baxter wrote: > On Tue, Jan 13, 2009 at 1:48 AM, Sergey Gromov wrote: > >> However, with a typedef, LocalType is a distinct type. Yes it casts to >> int implicitly, but likewise it casts implicitly to char, short and >> long. So co

Re: using a typedefed variable with library classes

2009-01-12 Thread Sergey Gromov
Sun, 11 Jan 2009 18:09:15 -0800, Charles Hixson wrote: > Well, my use case just involves being able to use library function with > the proper base type. (I.e., int instead of long or byte when I do > typedef int LocalType; > LocalType t; > File f; > f.write(t); > > I'll grant that I *can* use a

Re: array questions

2009-01-11 Thread Sergey Gromov
Sun, 11 Jan 2009 17:17:54 -0500, yes wrote: > Hello again > > is it possible to make a dynamic array less dynamic? > > int[][] array; > > array[0].length = 10; //has to be set at runtime Um, if that's your code, everything should crash at this point (or throw in debug mode): array is null, tha

Re: struct inheritance need?

2008-12-22 Thread Sergey Gromov
Sun, 21 Dec 2008 12:04:42 -0500, Kagamin wrote: > Sergey Gromov Wrote: > >> C++ static object constructors execute at run time except for trivial >> cases. > > Although I think it's not guaranteed to work this way and compiler > decides when to execute construc

Re: struct inheritance need?

2008-12-19 Thread Sergey Gromov
Thu, 18 Dec 2008 18:36:07 -0500, Christopher Wright wrote: > Weed wrote: >> Compile-time creation an object of class or (most likely wrong) struct >> inheritance. >> >> I have prepared a distinct feature request and send it later > > You aren't providing a use case, though. Why not show an exam

Re: struct inheritance need?

2008-12-19 Thread Sergey Gromov
Fri, 19 Dec 2008 04:07:40 -0500, Kagamin wrote: > Derek Parnell Wrote: > >> A static constructor (also known as the Module constructor) executes at >> program run-time and not at program compile-time. > > So do C++ static object constructors. Though C++ has syntax sugar, > which helps writing de

Re: DSSS problem

2008-12-19 Thread Sergey Gromov
Fri, 19 Dec 2008 22:01:09 +1300, Tim M wrote: > Hi I am using dsss and I'm not sure if I'm not using it right or there is > a bug in it. I have 2 projects using the same dsss.conf and sharing a lot > of common code. The linking of a large resource file makes the .exe I > expect to be a lot l

Re: confusing (buggy?) closure behaviour

2008-12-13 Thread Sergey Gromov
Sat, 13 Dec 2008 06:59:51 -0500, Zoran Isailovski wrote: > Anyway, following the latter pattern, you don't need global analysis. > You can determine if n is on the stack (it is - it's an argument), > you can determine if it's referenced from within the closure (it is), > and you can determine if t

Re: Freeing of memory (garbage collection)

2008-12-13 Thread Sergey Gromov
Tue, 9 Dec 2008 03:25:07 + (UTC), Dan W wrote: > 1: Even though D has an automatic garbage collector, is one still > allowed to free the memory of a malloced array manually (using free > () ), to avoid pauses in the program? Just to clarify. There are 3 types of allocation: 1. std.c.stdlib

Re: confusing (buggy?) closure behaviour

2008-12-12 Thread Sergey Gromov
Fri, 12 Dec 2008 15:24:39 -0500, Zoran Isailovski wrote: > Denis Koroskin Wrote: > On Fri, 12 Dec 2008 19:32:03 +0300, Zoran Isailovski wrote: > I'm an experienced C#, Java and Python programmer, and have employed > closures (and C# delegates) upon numerous occasions. Wh

Re: why the array bounds array

2008-12-08 Thread Sergey Gromov
Mon, 8 Dec 2008 06:59:40 + (UTC), BCS wrote: > Reply to Bill, > >> On Mon, Dec 8, 2008 at 2:57 PM, BCS <[EMAIL PROTECTED]> wrote: >> >>> Reply to Michael P., >>> >>> rand() & TYPES_OF_TILES >>> >>> never use rand like that (the low order bit on many rands toggles >>> every >>> single time)

Re: Classes in scopes

2008-10-24 Thread Sergey Gromov
Fri, 24 Oct 2008 04:02:31 -0400, bearophile wrote: > I think I may have found another bug (n. 41) in DMD: > > void main() { > { class Foo {} } > { class Foo {} } > } > > It produces: > t.o:(.rodata+0x34): multiple definition of `_Dmain3Foo6__initZ' > t.o:(.rodata+0x0): first defined here