Re: WindowProc in a class - function and pointer problem
On 5/22/2013 8:49 PM, evilrat wrote: On Wednesday, 22 May 2013 at 21:42:32 UTC, D-sturbed wrote: Yes I'm in the "multiple Window case", every window is wraped in a class and has its own message handler. I know that Win, in its callback system, often lets you retrieve a pointer to something, and I haven't get it was possible in this case...(which is you seem to describe). I will try this tomorrow. you can't really make it without static wndproc. if you don't know how to do it just go google some wndproc in a class tutors for c++, i can even recommend you one(i had used my own port of this in D before i switched to crossplatform lib for my needs) - http://blogs.msdn.com/b/oldnewthing/archive/2005/04/22/410773.aspx I had a partial port of WTL over to D which worked well enough for what I needed, the core of the WndProc handling is down below. Each HWND is owned by the thread it was created on, so assigning it into D associative array (which is thread local) can do the trick. It involved a hack, before any call to the Win32 CreateWindow/CreateWindowEx APIs, to capture the association with the new HWND and to remove them when they get cleaned up. There is probably a better way but this worked enough to get started, and should work with multiple windows reasonably well. CWindowInterface g_CreatingWindow; CWindowInterface[HWND] g_HWNDtoObject; extern (Windows) int CWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { int WindowProcReturnValue = 0; /* auto EventMsg = appender!string(); formattedWrite(EventMsg, "EventMsg (hWnd=%1$s) (uMsg=%2$s) (wParam=%3$s) (lParam=%4$s)\n", cast(DWORD)hWnd, cast(DWORD)uMsg, cast(DWORD)wParam, cast(DWORD)lParam); OutputDebugString(toUTFz!(const(wchar)*)(EventMsg.data)); */ if (g_CreatingWindow) { g_HWNDtoObject[hWnd] = g_CreatingWindow; g_CreatingWindow = null; } auto Window = g_HWNDtoObject[cast(HANDLE)hWnd]; if (Window is null) { WindowProcReturnValue = DefWindowProc(hWnd, uMsg, wParam, lParam); } else { WindowProcReturnValue = Window.WindowProc(hWnd, uMsg, wParam, lParam); } if (uMsg == WM_NCDESTROY) { g_HWNDtoObject.remove(hWnd); } return WindowProcReturnValue; }
Re: equivalent of __attribute__((constructor))
On 2013-05-23 06:27, Ellery Newcomer wrote: In the context of shared libraries, with gcc __attribute__((constructor)) void myfunc() { .. } is used to make myfunc be called upon loading of the shared library (you can tell I know what I am talking about here) via some field in the ELF headers, apparently. Is there any way to get our trusty d compilers to do the equivalent? Sure, Ellery, we have this awesome feature called module constructors. Check em out. Ehh, I would be using this to initialize druntime... You could just define _init, couldn't you? Yes, but there is only one _init, while the above can be used with multiple functions and thus wouldn't inadvertently cause important code to not run. If I don't have to, I'd rather not. Wait, why are you initializing druntime? Because druntime isn't set up to do it yet for c main calling d shared lib. You'd think it would need the same sort of functionality when it does implement it, though. I don't know if it's automatically linked but here you go: https://github.com/D-Programming-Language/druntime/blob/master/src/rt/dylib_fixes.c -- /Jacob Carlborg
equivalent of __attribute__((constructor))
In the context of shared libraries, with gcc __attribute__((constructor)) void myfunc() { .. } is used to make myfunc be called upon loading of the shared library (you can tell I know what I am talking about here) via some field in the ELF headers, apparently. Is there any way to get our trusty d compilers to do the equivalent? Sure, Ellery, we have this awesome feature called module constructors. Check em out. Ehh, I would be using this to initialize druntime... You could just define _init, couldn't you? Yes, but there is only one _init, while the above can be used with multiple functions and thus wouldn't inadvertently cause important code to not run. If I don't have to, I'd rather not. Wait, why are you initializing druntime? Because druntime isn't set up to do it yet for c main calling d shared lib. You'd think it would need the same sort of functionality when it does implement it, though.
Re: Templated Function can't deduce function arguments
On Wednesday, May 22, 2013 21:31:53 Steven Schveighoffer wrote: > On Wed, 22 May 2013 21:16:44 -0400, Jonathan Crapuchettes > > wrote: > > Can anyone tell me why this doesn't compile? Dmd 2.062 says that it > > cannot deduce the template function from arguments types. > > > > import std.stdio; > > > > void main() > > { > > > > test!(dchar, int)('b', 6, 'a', 54); > > > > } > > > > template test(Types...) > > { > > > > void test(T...)(const Types v, const T values...) > > Do you need that last elipsis? I thought you didn't, but not sure. You don't, and I'm surprised that it compiles, since I don't think that the elipsis is actually legal there. AFAIK, the only time that an elipsis is legal in the function arguments is with array variadics; e.g. auto foo(int[] bar...) {...} - Jonathan M Davis
Re: WindowProc in a class - function and pointer problem
On Wednesday, 22 May 2013 at 21:42:32 UTC, D-sturbed wrote: Yes I'm in the "multiple Window case", every window is wraped in a class and has its own message handler. I know that Win, in its callback system, often lets you retrieve a pointer to something, and I haven't get it was possible in this case...(which is you seem to describe). I will try this tomorrow. you can't really make it without static wndproc. if you don't know how to do it just go google some wndproc in a class tutors for c++, i can even recommend you one(i had used my own port of this in D before i switched to crossplatform lib for my needs) - http://blogs.msdn.com/b/oldnewthing/archive/2005/04/22/410773.aspx
Re: Templated Function can't deduce function arguments
On Wed, 22 May 2013 21:16:44 -0400, Jonathan Crapuchettes wrote: Can anyone tell me why this doesn't compile? Dmd 2.062 says that it cannot deduce the template function from arguments types. import std.stdio; void main() { test!(dchar, int)('b', 6, 'a', 54); } template test(Types...) { void test(T...)(const Types v, const T values...) Do you need that last elipsis? I thought you didn't, but not sure. -Steve
Templated Function can't deduce function arguments
Can anyone tell me why this doesn't compile? Dmd 2.062 says that it cannot deduce the template function from arguments types. import std.stdio; void main() { test!(dchar, int)('b', 6, 'a', 54); } template test(Types...) { void test(T...)(const Types v, const T values...) { writefln("%s,%s", v); foreach (s; values) writefln("%s,%s", s); } } Thank you, Jonathan
Re: WindowProc in a class - function and pointer problem
On Wednesday, 22 May 2013 at 21:22:52 UTC, Diggory wrote: On Wednesday, 22 May 2013 at 20:25:40 UTC, Simen Kjaeraas wrote: On 2013-05-22, 21:30, D-sturbed wrote: Hello, is there a way to wrap a WindowProc (so "LRESULT WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) nothrow") in a class and to link it to a WindowClass without puting it as "static" ? Because defacto every datum used in the WindowProc must also be static. The problem technically is that if "static" is not specified, the compiler won't allow this: "MyWinClass.lpfnWndProc = &TheWindowProcInMyClass". I've also tried this: "MyWinClass.lpfnWndProc = (&TheWindowProcInMyClass).funcptr" but, while it compiles, it drastically fails at the run-time... Not possible, no. What you *can* do is have some way to translate from hwnd to class instance, and fetch the right instance inside the static wndProc to call a member function on that. If you are only going to have one window you can store the "this" pointer in a global variable. If you want to have multiple windows each with messages going to an instance of a class, you need to do the following: - Specify the "this" pointer as the lpParam argument to CreateWindow - Hook up a static WndProc function - Have the static function handle a WM_NCCREATE message as follows: - Cast the "lParam" parameter to a CREATESTRUCT* and retrieve the "this" pointer from the "lpCreateParams" member. - Use "SetWindowLongPtr" to set the GWLP_USERDATA property of the window "hwnd" to the "this" pointer - Have the static function handle all messages as follows: - Use "GetWindowLongPtr" to get the GWLP_USERDATA property of the window "hwnd" to get the "this" pointer - Pass the message on to a non-static WndProc in the class using the discovered "this" pointer You also need to make sure that there is a separate reference to the class instance for as long as the window exists, because the garbage collector will not scan the window properties and so may think the object is garbage otherwise. Yes I'm in the "multiple Window case", every window is wraped in a class and has its own message handler. I know that Win, in its callback system, often lets you retrieve a pointer to something, and I haven't get it was possible in this case...(which is you seem to describe). I will try this tomorrow.
Re: open a range of files - segfault
On Wednesday, 22 May 2013 at 11:09:49 UTC, John Colvin wrote: On Wednesday, 22 May 2013 at 11:07:39 UTC, bearophile wrote: Stephan Schiffels: this code crashes with a segfault. I need help to understand what might be wrong with it. import std.array; import std.algorithm; void main() { auto names = ["file1.txt", "file2.txt", "file3.txt"]; // let these files exist auto files = names.map!(f => File(f, "r"))().array(); } If I use the latest 2.063beta5 compiler, and I also import std.stdio, then I see no crash on Windows32. Bye, bearophile With git master on linux x64 I get a segfault, see my other comment. OK, thanks for confirming. I updated to the latest git master and still get a segfault. I'll file a bug report. Stephan
Re: WindowProc in a class - function and pointer problem
On Wednesday, 22 May 2013 at 20:25:40 UTC, Simen Kjaeraas wrote: On 2013-05-22, 21:30, D-sturbed wrote: Hello, is there a way to wrap a WindowProc (so "LRESULT WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) nothrow") in a class and to link it to a WindowClass without puting it as "static" ? Because defacto every datum used in the WindowProc must also be static. The problem technically is that if "static" is not specified, the compiler won't allow this: "MyWinClass.lpfnWndProc = &TheWindowProcInMyClass". I've also tried this: "MyWinClass.lpfnWndProc = (&TheWindowProcInMyClass).funcptr" but, while it compiles, it drastically fails at the run-time... Not possible, no. What you *can* do is have some way to translate from hwnd to class instance, and fetch the right instance inside the static wndProc to call a member function on that. If you are only going to have one window you can store the "this" pointer in a global variable. If you want to have multiple windows each with messages going to an instance of a class, you need to do the following: - Specify the "this" pointer as the lpParam argument to CreateWindow - Hook up a static WndProc function - Have the static function handle a WM_NCCREATE message as follows: - Cast the "lParam" parameter to a CREATESTRUCT* and retrieve the "this" pointer from the "lpCreateParams" member. - Use "SetWindowLongPtr" to set the GWLP_USERDATA property of the window "hwnd" to the "this" pointer - Have the static function handle all messages as follows: - Use "GetWindowLongPtr" to get the GWLP_USERDATA property of the window "hwnd" to get the "this" pointer - Pass the message on to a non-static WndProc in the class using the discovered "this" pointer You also need to make sure that there is a separate reference to the class instance for as long as the window exists, because the garbage collector will not scan the window properties and so may think the object is garbage otherwise.
Re: how to have alias this with an unaccessible member?
at least 'delete' is in the deprecated table (marked as will be deprecated some time in the future) so should opDot then. On Wed, May 22, 2013 at 11:34 AM, Jonathan M Davis wrote: > On Wednesday, May 22, 2013 18:18:34 timotheecour wrote: > > On Sunday, 19 May 2013 at 14:33:32 UTC, Ali Çehreli wrote: > > > On 05/19/2013 05:34 AM, Simen Kjaeraas wrote: > > >> Well, there is also opDot: > > > What is the state of opDot? According to the change log, it has > > > been introduced as a part of "Version D 2.013 Apr 22, 2008" > > > with the note "Added opDot, which is experimental only." > > > > > > I will keep assuming that opDot does not exist. :) (However, it > > > is being used by Unique an Ref in std.typecons.) > > > > > > Ali > > > > is there anything you can do with opDot that you can't with alias > > this? > > > > (aside from the ability to hide the member as being private, as > > raised in the OP; its a bit broken as mentioned 1 post above) > > > > if not, it should deprecate. > > opDot is definitely supposed to be deprecated: > > http://d.puremagic.com/issues/show_bug.cgi?id=2327 > > but Daniel Murphy seems to have missed it on his list > (http://dlang.org/deprecate.html), and it hasn't actually been deprecated > yet > (but then again, even delet hasn't been deprecated yet, so that just goes > to > show how slow we are to deprecate language features that are definitely > supposed to get the axe). > > - Jonathan M Davis >
Re: WindowProc in a class - function and pointer problem
On 2013-05-22, 21:30, D-sturbed wrote: Hello, is there a way to wrap a WindowProc (so "LRESULT WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) nothrow") in a class and to link it to a WindowClass without puting it as "static" ? Because defacto every datum used in the WindowProc must also be static. The problem technically is that if "static" is not specified, the compiler won't allow this: "MyWinClass.lpfnWndProc = &TheWindowProcInMyClass". I've also tried this: "MyWinClass.lpfnWndProc = (&TheWindowProcInMyClass).funcptr" but, while it compiles, it drastically fails at the run-time... Not possible, no. What you *can* do is have some way to translate from hwnd to class instance, and fetch the right instance inside the static wndProc to call a member function on that. -- Simen
WindowProc in a class - function and pointer problem
Hello, is there a way to wrap a WindowProc (so "LRESULT WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) nothrow") in a class and to link it to a WindowClass without puting it as "static" ? Because defacto every datum used in the WindowProc must also be static. The problem technically is that if "static" is not specified, the compiler won't allow this: "MyWinClass.lpfnWndProc = &TheWindowProcInMyClass". I've also tried this: "MyWinClass.lpfnWndProc = (&TheWindowProcInMyClass).funcptr" but, while it compiles, it drastically fails at the run-time...
Re: how to have alias this with an unaccessible member?
On Wednesday, May 22, 2013 18:18:34 timotheecour wrote: > On Sunday, 19 May 2013 at 14:33:32 UTC, Ali Çehreli wrote: > > On 05/19/2013 05:34 AM, Simen Kjaeraas wrote: > >> Well, there is also opDot: > > What is the state of opDot? According to the change log, it has > > been introduced as a part of "Version D 2.013 Apr 22, 2008" > > with the note "Added opDot, which is experimental only." > > > > I will keep assuming that opDot does not exist. :) (However, it > > is being used by Unique an Ref in std.typecons.) > > > > Ali > > is there anything you can do with opDot that you can't with alias > this? > > (aside from the ability to hide the member as being private, as > raised in the OP; its a bit broken as mentioned 1 post above) > > if not, it should deprecate. opDot is definitely supposed to be deprecated: http://d.puremagic.com/issues/show_bug.cgi?id=2327 but Daniel Murphy seems to have missed it on his list (http://dlang.org/deprecate.html), and it hasn't actually been deprecated yet (but then again, even delet hasn't been deprecated yet, so that just goes to show how slow we are to deprecate language features that are definitely supposed to get the axe). - Jonathan M Davis
Re: how to have alias this with an unaccessible member?
On Sunday, 19 May 2013 at 14:33:32 UTC, Ali Çehreli wrote: On 05/19/2013 05:34 AM, Simen Kjaeraas wrote: Well, there is also opDot: What is the state of opDot? According to the change log, it has been introduced as a part of "Version D 2.013 Apr 22, 2008" with the note "Added opDot, which is experimental only." I will keep assuming that opDot does not exist. :) (However, it is being used by Unique an Ref in std.typecons.) Ali is there anything you can do with opDot that you can't with alias this? (aside from the ability to hide the member as being private, as raised in the OP; its a bit broken as mentioned 1 post above) if not, it should deprecate.
Re: Nesting Variants
what about this class? https://bitbucket.org/szabo_bogdan/cmsushid/raw/e2e4d2195bf48df586887768d2d800d21227c80d/src/base/Value.d
Re: casting with preserving attributes
Jack Applegame: Finally http://dpaste.1azy.net/fc503331 I suggest to use indents composed by 4 spaces. Generally in D we use template constraints, instead of static ifs with a nice error message... In such complex situations I also suggest to add braces. Something like this: auto castElementType(T = byte, F)(ref F from) if (isArray!F) { alias E = typeof(from[0]); static if(is(E == const)) { return cast(const(Unqual!T)[])from; } else static if(is(E == immutable)) { return cast(immutable(Unqual!T)[])from; } else static if(is(E == shared)) { return cast(shared(Unqual!T)[])from; } else { return cast(Unqual!T[])from; } } Bye, bearophile
Re: casting with preserving attributes
On Wednesday, 22 May 2013 at 13:01:26 UTC, bearophile wrote: I think that's essentially the right solution. I suggest to generalize it a bit, removing the byte from its insides, and making it a template argument. I think "shared" is missing. Yes. Finally http://dpaste.1azy.net/fc503331
Re: casting with preserving attributes
I found awkward solution: template ByteType(alias t) { alias typeof(t) T; static if(is(ElementType!T == const)) alias const(byte)[] ByteType; else static if(is(ElementType!T == immutable)) alias immutable(byte)[] ByteType; else alias byte[] ByteType; }
Re: casting with preserving attributes
Jack Applegame: I found awkward solution: template ByteType(alias t) { alias typeof(t) T; static if(is(ElementType!T == const)) alias const(byte)[] ByteType; else static if(is(ElementType!T == immutable)) alias immutable(byte)[] ByteType; else alias byte[] ByteType; } I think that's essentially the right solution. I suggest to generalize it a bit, removing the byte from its insides, and making it a template argument. I think "shared" is missing. Bye, bearophile
casting with preserving attributes
Hello. I need a template for casting arrays to another type without changing const and immutable attributes: template ByteType(T) { // some magic } const(int)[] ca; immutable(short)[] is; long[] ml; static assert(is(ByteType!ca == const(byte)[])); static assert(is(ByteType!is == immutable(byte)[])); static assert(is(ByteType!ml == byte[])); What kind of template magic I should use?
Re: open a range of files - segfault
On Wednesday, 22 May 2013 at 11:07:39 UTC, bearophile wrote: Stephan Schiffels: this code crashes with a segfault. I need help to understand what might be wrong with it. import std.array; import std.algorithm; void main() { auto names = ["file1.txt", "file2.txt", "file3.txt"]; // let these files exist auto files = names.map!(f => File(f, "r"))().array(); } If I use the latest 2.063beta5 compiler, and I also import std.stdio, then I see no crash on Windows32. Bye, bearophile With git master on linux x64 I get a segfault, see my other comment.
Re: open a range of files - segfault
On Wednesday, 22 May 2013 at 08:38:14 UTC, Stephan Schiffels wrote: Hi, this code crashes with a segfault. I need help to understand what might be wrong with it. import std.array; import std.algorithm; void main() { auto names = ["file1.txt", "file2.txt", "file3.txt"]; // let these files exist auto files = names.map!(f => File(f, "r"))().array(); } Thanks, Stephan A quick gdb run shows that it's segfaulting at the exit of the program, when the GC runs its final full collection.
Re: open a range of files - segfault
Stephan Schiffels: this code crashes with a segfault. I need help to understand what might be wrong with it. import std.array; import std.algorithm; void main() { auto names = ["file1.txt", "file2.txt", "file3.txt"]; // let these files exist auto files = names.map!(f => File(f, "r"))().array(); } If I use the latest 2.063beta5 compiler, and I also import std.stdio, then I see no crash on Windows32. Bye, bearophile
open a range of files - segfault
Hi, this code crashes with a segfault. I need help to understand what might be wrong with it. import std.array; import std.algorithm; void main() { auto names = ["file1.txt", "file2.txt", "file3.txt"]; // let these files exist auto files = names.map!(f => File(f, "r"))().array(); } Thanks, Stephan
[Video to MP4]playing VOB, MXF, AVCHD, MKV videos on Samsung Galaxy S 3
Watch movies on Samsung Galaxy S III with the best Samsung Galaxy S 3 video converter [Video to MP4]playing VOB, MXF, AVCHD, MKV videos on Samsung Galaxy S 3 As the users of Samsung Galaxy S III, what will you do with it? Listen Music, or download top 10 Android games? Anyway, whether you do anything on Galaxy S3, don’t forget to watch movies on Samsung Galaxy S III. It’s pleasant to play videos on such a wide-screen with HD quality. Galaxy S III is said to support videos in MP4, 3GP, MPEG4, Divx, Xvid formats, but if we have videos in FLV, MOV, WMV, AVI, VOB, etc, we need convert FLV, MOV, WMV, AVI, VOB, MXF, AVCHD, MKV, etc to Samsung Galaxy S3 supported formats. The following paragraphs will guide you how to effectively transfer/convert any movies to Samsung Galaxy S III so that we can freely enjoy videos on Galaxy S III. Step 1: Add Videos to Aunsoft Samsung Galaxy S3 Video Converter With this powerful Samsung Galaxy S3 Video Converter, we can load as many as videos at one time, so we can import any FLV/MOV/WMV/AVI/VOB/MXF/AVCHD/MKV videos to Samsung Galaxy S3 Video Converter. Step 2: Convert Videos to Samsung Galaxy S III by the best video to Samsung Galaxy S3 Converter No matter what formats videos are, Samsung Galaxy Video Converter is able to transcode FLV/MOV/WMV/AVI/VOB/MXF/AVCHD/MKV to Samsung Galaxy S3 compatible MP4 format. Pull down format list to select Samsung>>Samsung Galaxy S II (I9100) (*.mp4). Also, we can adjust size, bit rates, as well as frame rate to create the best profile for Samsung Galaxy S III videos. Step 3: Export MP4 videos for Galaxy S3 Conversion from videos to MP4 will be done so quickly that we can easily transfer exported MP4 videos to Galaxy S III. In conclusion, we can copy any videos on Samsung Galaxy S3. Watch movies on Samsung Galaxy S III with the best Samsung Galaxy S 3 video converter [Video to MP4]playing VOB, MXF, AVCHD, MKV videos on Samsung Galaxy S 3 As the users of Samsung Galaxy S III, what will you do with it? Listen Music, or download top 10 Android games? Anyway, whether you do anything on Galaxy S3, don’t forget to watch movies on Samsung Galaxy S III. It’s pleasant to play videos on such a wide-screen with HD quality. Galaxy S III is said to support videos in MP4, 3GP, MPEG4, Divx, Xvid formats, but if we have videos in FLV, MOV, WMV, AVI, VOB, etc, we need convert FLV, MOV, WMV, AVI, VOB, MXF, AVCHD, MKV, etc to Samsung Galaxy S3 supported formats. The following paragraphs will guide you how to effectively transfer/convert any movies to Samsung Galaxy S III so that we can freely enjoy videos on Galaxy S III. Step 1: Add Videos to Aunsoft Samsung Galaxy S3 Video Converter With this powerful Samsung Galaxy S3 Video Converter, we can load as many as videos at one time, so we can import any FLV/MOV/WMV/AVI/VOB/MXF/AVCHD/MKV videos to Samsung Galaxy S3 Video Converter. Step 2: Convert Videos to Samsung Galaxy S III by the best video to Samsung Galaxy S3 Converter No matter what formats videos are, Samsung Galaxy Video Converter is able to transcode FLV/MOV/WMV/AVI/VOB/MXF/AVCHD/MKV to Samsung Galaxy S3 compatible MP4 format. Pull down format list to select Samsung>>Samsung Galaxy S II (I9100) (*.mp4). Also, we can adjust size, bit rates, as well as frame rate to create the best profile for Samsung Galaxy S III videos. Step 3: Export MP4 videos for Galaxy S3 Conversion from videos to MP4 will be done so quickly that we can easily transfer exported MP4 videos to Galaxy S III. In conclusion, we can copy any videos on Samsung Galaxy S3.
Re: Import Canon Camcorder AVCHD/MOV files to FCP with Mac Camcorder video converter
On Wednesday, 22 May 2013 at 07:10:38 UTC, daisy520 wrote: Import Canon Camcorder AVCHD/MOV files to FCP with Mac Camcorder video converter As a great non-linear video editing application, Final Cut Pro has gained the favor of different people, from video hobbyists, independent filmmakers to film and television editors. Final Cut Pro provides non-linear, non-destructive editing of any QuickTime compatible video format including DV, HDV, P2 MXF (DVCProHD), XDCAM, and 2K film formats. Seems powerful enough? Even so, users always encounter troubles when importing clips shot by different cameras or camcorders, like Canon Vixia AVCHD, etc. In that way, you have to consider transferring Canon Camcorder videos to FCP compatible file types before importing, such as Apple ProRes , Apple ProRes 422 (HQ), Apple ProRes 422,Apple ProRes 422 (LT), and Apple ProRes 422 (Proxy). Now that we’ve talked about importing, I’d like to say something different between Final Cut Pro 7 and the newest Final Cut Pro X. Three ways are available for importing. 1. Importing from File-Based Cameras 2. Importing from FireWire Cameras and Decks 3. Importing Files - You can import files into Final Cut Pro X by choosing Import > Files or by dragging files directly into the Event Library. You don’t need to specify whether you’re importing an individual file or a folder, as you do in Final Cut Pro 7. Understanding the similarities and differences between Final Cut Pro 7 and Final Cut Pro X will allow you to work faster than ever with this new breakthrough application. Back to the point, if you have troubles while importing different Canon Camcorder videos to FCP, what to do? As we’ve mentioned at the beginning, you have to consider converting Canon avchd/mov footage to FCP workable format before importing. Indeed, there are numbers of Canon video converter software in the market. Choosing a good converter or a bad one will decide the quality of your editing material, so it’s serious. Aunsoft Canon Camcorder video converter for Mac will never let you down. It not only provides expert format preset for Final Cut Pro, but also offers profiles for other commonly-used video editing programs running on Mac OS X, including iMovie, Final Cut Express, Avid Media Composer, Adobe Premiere, and Sony Vegas. More than that, if you wanna cut some Canon footage for watching on iPad, iPhone, Apple TV, iTouch, Aunsoft Canon footage converter will also help you realize the goal. To encode Canon recordings to FCP for editing, three steps are enough. Step 1: Import Canon footage to Aunsoft Canon video converter for Mac software. Step 2: Select output format for FCP (X). Step 3: Convert Canon footage to FCP compatible format. Additional Tips - with Aunsoft Mac Canon AVCHD/MOV to FCP Converter , you can do more: - convert Canon AVCHD files to FCP editable format - transfer Canon EOS DSLR H.264 MOV for Final Cut Pro - transcode Canon MXF to QT MOV, Apple ProRes, AIC, DNxHD, etc. - downsize 1080p Canon footage to 720p This information has changed my life! ... Or not...
Import Canon Camcorder AVCHD/MOV files to FCP with Mac Camcorder video converter
Import Canon Camcorder AVCHD/MOV files to FCP with Mac Camcorder video converter As a great non-linear video editing application, Final Cut Pro has gained the favor of different people, from video hobbyists, independent filmmakers to film and television editors. Final Cut Pro provides non-linear, non-destructive editing of any QuickTime compatible video format including DV, HDV, P2 MXF (DVCProHD), XDCAM, and 2K film formats. Seems powerful enough? Even so, users always encounter troubles when importing clips shot by different cameras or camcorders, like Canon Vixia AVCHD, etc. In that way, you have to consider transferring Canon Camcorder videos to FCP compatible file types before importing, such as Apple ProRes , Apple ProRes 422 (HQ), Apple ProRes 422,Apple ProRes 422 (LT), and Apple ProRes 422 (Proxy). Now that we’ve talked about importing, I’d like to say something different between Final Cut Pro 7 and the newest Final Cut Pro X. Three ways are available for importing. 1. Importing from File-Based Cameras 2. Importing from FireWire Cameras and Decks 3. Importing Files - You can import files into Final Cut Pro X by choosing Import > Files or by dragging files directly into the Event Library. You don’t need to specify whether you’re importing an individual file or a folder, as you do in Final Cut Pro 7. Understanding the similarities and differences between Final Cut Pro 7 and Final Cut Pro X will allow you to work faster than ever with this new breakthrough application. Back to the point, if you have troubles while importing different Canon Camcorder videos to FCP, what to do? As we’ve mentioned at the beginning, you have to consider converting Canon avchd/mov footage to FCP workable format before importing. Indeed, there are numbers of Canon video converter software in the market. Choosing a good converter or a bad one will decide the quality of your editing material, so it’s serious. Aunsoft Canon Camcorder video converter for Mac will never let you down. It not only provides expert format preset for Final Cut Pro, but also offers profiles for other commonly-used video editing programs running on Mac OS X, including iMovie, Final Cut Express, Avid Media Composer, Adobe Premiere, and Sony Vegas. More than that, if you wanna cut some Canon footage for watching on iPad, iPhone, Apple TV, iTouch, Aunsoft Canon footage converter will also help you realize the goal. To encode Canon recordings to FCP for editing, three steps are enough. Step 1: Import Canon footage to Aunsoft Canon video converter for Mac software. Step 2: Select output format for FCP (X). Step 3: Convert Canon footage to FCP compatible format. Additional Tips - with Aunsoft Mac Canon AVCHD/MOV to FCP Converter , you can do more: - convert Canon AVCHD files to FCP editable format - transfer Canon EOS DSLR H.264 MOV for Final Cut Pro - transcode Canon MXF to QT MOV, Apple ProRes, AIC, DNxHD, etc. - downsize 1080p Canon footage to 720p
Re: Nesting Variants
On Wednesday, 22 May 2013 at 01:04:35 UTC, Wyatt wrote: I was trying to do this as a way to obtain a concise syntax for manipulating a tree of elements deserialized at runtime, ex: data["foo"]["bar"] = "baz"; assert( data["foo"]["bar"] == "baz" ); foreach( subtree; data["foo"] ) doSubtreeOp( subtree ); Having to place .get!(Variant[]) between each dereference will defeat my use case. Associative arrays fail in the same way, btw. I'm using integers in the first example because it should be simpler to get those right. I expected this to work because the value of 'ender[0]' will be a variant that contains an array, and such a variant should be able to index the contained array because of its opIndex overload. if this is a tree anyway better use custom node types. so why not do this and overload opindex? unlike c++ u can put anything as key. i can't say from this example what types you are going to use but if it's only strings this should be very easy to implement.
Re: Nesting Variants
On Monday, 20 May 2013 at 08:55:24 UTC, evilrat wrote: yes, you forgot to take exact value, it doesn't know anything about array you put it in, so if you take that array explicitly and put value on array element it would work ender[0] = one; ender[0].get!(Variant[])[0] = key; writeln(ender[0][0]); // writes 1 also you can check whats inside by doing just this "writeln(ender);" in case you are not sure what's going on. I was trying to do this as a way to obtain a concise syntax for manipulating a tree of elements deserialized at runtime, ex: data["foo"]["bar"] = "baz"; assert( data["foo"]["bar"] == "baz" ); foreach( subtree; data["foo"] ) doSubtreeOp( subtree ); Having to place .get!(Variant[]) between each dereference will defeat my use case. Associative arrays fail in the same way, btw. I'm using integers in the first example because it should be simpler to get those right. I expected this to work because the value of 'ender[0]' will be a variant that contains an array, and such a variant should be able to index the contained array because of its opIndex overload.
Regarding a vector op
Currently this code doesn't compile: void main() { int[2] data = [10, 20]; double[2] result; result[] = data[] * 0.5; } It gives the error: test.d(4): Error: incompatible types for ((data[]) * (0.5)): 'int[]' and 'double' Is code like this meant to work? Bye, bearophile
Re: Remove duplicates
Steven Schveighoffer: This seems to work for ASCII strings, but the conversion to array is required (I think because writeln may re-evaluate the range's front more than once): Thank you, I have opened an ER: http://d.puremagic.com/issues/show_bug.cgi?id=10131 Bye, bearophile
Re: Remove duplicates
On Tue, 21 May 2013 18:00:07 -0400, bearophile wrote: Sometimes I have need a simple function like this, related to std.string.squeeze: // Must keep the original order of the items. // Slow implementation that shows the semantics. T[] noDupes(T)(in T[] s) { import std.algorithm: canFind; T[] result; foreach (T c; s) if (!result.canFind(c)) result ~= c; return result; } void main() { import std.string: squeeze; assert("".noDupes == "A"); assert("".squeeze == "A"); assert("ABAC".noDupes == "ABC"); assert("ABAC".squeeze == "ABAC"); } Do you know if this function (or a simple way to implement it) already in Phobos? This seems to work for ASCII strings, but the conversion to array is required (I think because writeln may re-evaluate the range's front more than once): Should be O(n), but doesn't really get around the memory allocation. You could probably write a custom range that does this properly (doesn't set present until popFront is called): import std.algorithm; import std.array; import std.stdio; void main() { bool present[256]; // writes "ABC" writeln(array("ABAC".filter!((a){scope(exit) present[a] = true; return !present[a];}))); } Kind of a violation of how a range should work, front should be the same across multiple calls! But it does the trick :) -Steve
Re: Remove duplicates
On Tuesday, 21 May 2013 at 22:51:26 UTC, bearophile wrote: Namespace: // Slow implementation that shows the semantics. ... I do not know if this solution would be much faster. But if I should make a statement, I would tend to yes. (The point of my code was to show the semantics as much clearly as possible, it was not to show fast code.) If no similar function is in Phobos, and there is no trivial way to implement it efficiently, then maybe it's worth writing a Phobos enhancement request. Bye, bearophile http://dlang.org/phobos/std_algorithm.html#uniq
Re: Remove duplicates
Namespace: http://dlang.org/phobos/std_algorithm.html#uniq Just like squeeze, uniq requires the items to be sorted, to remove the duplicates. The function I am discussing here must keep the order of the not removed items. Bye, bearophile
Re: Remove duplicates
Namespace: // Slow implementation that shows the semantics. ... I do not know if this solution would be much faster. But if I should make a statement, I would tend to yes. (The point of my code was to show the semantics as much clearly as possible, it was not to show fast code.) If no similar function is in Phobos, and there is no trivial way to implement it efficiently, then maybe it's worth writing a Phobos enhancement request. Bye, bearophile
Re: Remove duplicates
On Tuesday, 21 May 2013 at 22:00:09 UTC, bearophile wrote: Sometimes I have need a simple function like this, related to std.string.squeeze: // Must keep the original order of the items. // Slow implementation that shows the semantics. T[] noDupes(T)(in T[] s) { import std.algorithm: canFind; T[] result; foreach (T c; s) if (!result.canFind(c)) result ~= c; return result; } void main() { import std.string: squeeze; assert("".noDupes == "A"); assert("".squeeze == "A"); assert("ABAC".noDupes == "ABC"); assert("ABAC".squeeze == "ABAC"); } Do you know if this function (or a simple way to implement it) already in Phobos? Bye, bearophile I would prefer a map solution like this: @property T[] noDupes(T)(const T[] arr) { bool[T] map; foreach (T item; arr) { if (item !in map) map[item] = true; } return map.keys; } I do not know if this solution would be much faster. But if I should make a statement, I would tend to yes.
Re: static analysis: how to test code reachability at compile time
On 05/21/2013 11:31 PM, Diggory wrote: ... It would be very easy to introduce paradoxes This is the case already. if this were possible, simply use a static if to call something only if it is unreachable. I don't think this would be possible because function-local symbols are not accessible from outside.
Remove duplicates
Sometimes I have need a simple function like this, related to std.string.squeeze: // Must keep the original order of the items. // Slow implementation that shows the semantics. T[] noDupes(T)(in T[] s) { import std.algorithm: canFind; T[] result; foreach (T c; s) if (!result.canFind(c)) result ~= c; return result; } void main() { import std.string: squeeze; assert("".noDupes == "A"); assert("".squeeze == "A"); assert("ABAC".noDupes == "ABC"); assert("ABAC".squeeze == "ABAC"); } Do you know if this function (or a simple way to implement it) already in Phobos? Bye, bearophile
static analysis: how to test code reachability at compile time
I'd like to have the following tools to help with static analysis & code coverage: 1) test whether code is reachable or not. Of course it only works for executables and may have some caveats (eg: goto), but its still useful diagnostic tool. __traits(isReachable): true when the current context can be reached via at least one code path starting from main(): void fun1(){ //__traits(isReachable) would be false here because even though fun1 is called by fun2, it can never be called starting from main(). } void fun2(){fun1;} void fun3(){} // would also be false, because of static if(temp); with temp being known to be 0 at compile time. void fun4(){ return; //__traits(isReachable) would be false here because all code paths return above this point. } void main(){enum temp=0; static if(temp) fun3; fun4;} When a pointer to a function is taken, we may want to assume by convention that __traits(isReachable) is true. This would enable for example to make sure a given code is never called. Note, static assert(0) is not the same. 2) static code call graph: know caller/calling functions for a given function. 3) static code coverage this would allow us to tell at compile time the code coverage of a module; it is larger than runtime coverage, but still useful to find dead code.
Re: static analysis: how to test code reachability at compile time
On Tuesday, 21 May 2013 at 21:15:58 UTC, Timothee Cour wrote: I'd like to have the following tools to help with static analysis & code coverage: 1) test whether code is reachable or not. Of course it only works for executables and may have some caveats (eg: goto), but its still useful diagnostic tool. __traits(isReachable): true when the current context can be reached via at least one code path starting from main(): void fun1(){ //__traits(isReachable) would be false here because even though fun1 is called by fun2, it can never be called starting from main(). } void fun2(){fun1;} void fun3(){} // would also be false, because of static if(temp); with temp being known to be 0 at compile time. void fun4(){ return; //__traits(isReachable) would be false here because all code paths return above this point. } void main(){enum temp=0; static if(temp) fun3; fun4;} When a pointer to a function is taken, we may want to assume by convention that __traits(isReachable) is true. This would enable for example to make sure a given code is never called. Note, static assert(0) is not the same. 2) static code call graph: know caller/calling functions for a given function. 3) static code coverage this would allow us to tell at compile time the code coverage of a module; it is larger than runtime coverage, but still useful to find dead code. It would be very easy to introduce paradoxes if this were possible, simply use a static if to call something only if it is unreachable.