Cè¨èªããJavaã¸ã®ç§»æ¤æ¹æ³ã¾ã¨ã
XPCEã¨ããCè¨èªã§çµã¾ããPCã¨ã³ã¸ã³ã¨ãã¥ã¬ã¼ã¿ããiã¢ããªã®Javaã¸ç§»æ¤ãã¦ãã¾ãã
ãã£ã¦ãããã¡ã«ã移æ¤æé ã®ã¡ãã£ã¨ããã³ãã«æ°ãã¤ãã¾ããã
ãããªããã§ãCè¨èªã®ã½ã¼ã¹ãããJavaã¸ç§»æ¤ããå ´åã®ä½æ¥ã«ã¤ãã¦ãã¾ã¨ãã¦ããã¾ãã
常ã«åä½ãã¹ãã§ããããã«ãã
Cã®ã½ã¼ã¹ãããããªãJavaã«æ¡å¼µåå¤æ´ãã¦ãä¸èº«ãæ¸ãæãã¦ããã¨ããæ¹æ³ãã¨ãã¨ã
ãã¹ã¦ãJavaã³ã¼ãã«ä¿®æ£ããã¾ã§ãåä½ç¢ºèªãããã¨ãã§ããªããªã£ã¦ãã¾ãã¾ãã
Javaã«æ¡å¼µåå¤æ´ããã®ã¯ãã§ããã ãå¾ã«ãã¾ãã
Cã®ã½ã¼ã¹ã®ã¾ã¾ããã«ããã¦åãããç¶æ
ãä¿ã£ãã¾ã¾ã§ãJavaã«ç¡ãæ©è½ãç½®æãã¦ããã¾ãã
Javaã«ç¡ãæ©è½ãç½®ãæãã
Javaã«ç¡ãæ©è½ã¨ããã¨ã
- ãã¤ã³ã¿æ¼ç®å
- å ±ç¨ä½
- unsignedå
- ãã¯ã
ãªã©ã§ãã
ããããã使ããªãå½¢ã®Cã½ã¼ã¹ã«ä¿®æ£ãã¦ããããã§ãã
ãã¤ã³ã¿æ¼ç®ã®ç½®ãæã
ãã¤ã³ã¿ã¯é å+ã¤ã³ããã¯ã¹ã«ç½®ãæãã¾ãã
ã->ããã.ãã«ç½®ãæã
éæ¥ã¡ã³ãåç
§æ¼ç®åã->ãããç´æ¥ã¡ã³ãåç
§æ¼ç®åã.ãã«ç½®ãæãã¾ãã
Javaã«ã¯ã->ããåå¨ããªãããã§ãã
ããã¯ç°¡åã«ç½®ãæããæ¹æ³ããããæ§é ä½ãåç
§æ¸¡ãã«ããã°OKã§ãã
void func(HOGE *hoge) { hoge->aaa = 10; hoge->bbb = 10; }
ã ã£ããã
void func(HOGE& hoge) { hoge.aaa = 10; hoge.bbb = 10; }
ãã®ããã«æ¸ãæãã¾ãã
å ±ç¨ä½ï¼unionï¼ã®ç½®ãæã
å
±ç¨ä½ãã¯ã©ã¹ã«ç½®ãæãã¦ãã¡ã³ãã¸ã®åç
§ããã²ãã¿ã¼ãã»ãã¿ã¼ãä»ãã¦è¡ãããã«ãããã¨ã§
å
±ç¨ä½ã使ç¨ããªãããã«ã§ãã¾ãã
unsignedåã®ç½®ãæã
Javaã§ç¬¦å·ãªãã®åã¯ãcharï¼16bit符å·ç¡ï¼ã ãã§ãã
unsigned charçã¯ãintã«ç½®ãæãã¾ãã
unsigned charã®å ´åã255ã«1ãå ããã¨0ã«æ»ãã¾ãããããã¯ANDæ¼ç®ã®ãã¹ã¯ã§ä»£ç¨ãã¾ãã
æ¼ç®ã«& 0xFFãã¤ããã°OKã§ãã
ãã¯ã
ãã¯ãã¯ã¡ã½ããã«ç½®ãæãã¾ãã
ãããå¤ãã¨ãããªãã«é¢åã§ãã
ãã¯ãããã¾ãã«ãå¤ç¨ããã¦ããã½ã¼ã¹ã®å ´åãCã³ã³ãã¤ã©ã®ããªããã»ããµãä¸åº¦éãã¦
ãã¯ããå±éãã¦ãã¾ãæãããã¾ãã
Visual C++ã®å ´åã
cl.exe /EP in.c > out.c
ã§ããã¯ããå±éããã½ã¼ã¹ãå¾ããã¨ãã§ãã¾ãã
ifæã¯æ¯è¼æ¼ç®åãå¿ ãä»ãã
Cã®å ´åãifã®æ¡ä»¶å¼ãæ°å¤åã§ãOKãªã®ã§ã以ä¸ã®ãããªæ¸ãæ¹ããããã¾ãã
int var = getVer(); if (var) { varãéã¼ãã®å ´åã®å¦ç }
ãããæ¯è¼æ¼ç®åã使ãããã«æ¸ãæãã¾ãã
int var = getVer(); if (var != 0) { varãéã¼ãã®å ´åã®å¦ç }
Javaã§ã¯ãifã®æ¡ä»¶å¼ã¯booleanåãã使ããªãããã§ãã
ã¨ã«ãããã¡ãã£ã¨ã¥ã¤ãã£ã¦ããã®ããã¤ã³ã
ããç¨åº¦ã®è¦æ¨¡ã¨è¤éããããã½ã¼ã¹ã®å ´åã移æ¤æã«ãã°ãå ¥ãã¦ãã¾ãã¨å¾ã§è¦ã¤ããã®ã¯å°é£ã§ãã
ãããç´ãã¦ã¯ãã«ãï¼åä½ç¢ºèªããã¡ãã£ã¨ã¥ã¤ãã£ã¦ããã®ãè¯ãã§ãã
ç¶æ³
æ¨æ¥ã¯R-TYPEããã°ã£ã¦ãã¾ãã¾ããããæ¡ä»¶ä»ããã¬ã¼ã¯ãã¤ã³ãã§ãã°ã®åå ãçªãæ¢ãããã¨ãã§ãã¾ããã
ãã£ããããæãã«ä½æ¥ãé²ãã§ãã¾ãã