Skip to content

Commit a4e4436

Browse files
committed
Convert CefCommandLine class to use scoped helpers (see issue chromiumembedded#167)
1 parent f16fc8e commit a4e4436

4 files changed

Lines changed: 156 additions & 125 deletions

File tree

java/org/cef/callback/CefCommandLine.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,60 +22,71 @@ public interface CefCommandLine {
2222
* component unchanged.
2323
*/
2424
public void reset();
25+
2526
/**
2627
* Get the program part of the command line string (the first item).
2728
*/
2829
public String getProgram();
30+
2931
/**
3032
* Set the program part of the command line string (the first item).
3133
* @param program Name of the program.
3234
*/
3335
public void setProgram(String program);
36+
3437
/**
3538
* Checks if the command line has switches.
3639
* @return true if the command line has switches.
3740
*/
3841
public boolean hasSwitches();
42+
3943
/**
4044
* Checks if the command line has a specific switches.
4145
* @param name A switch name to test for.
4246
* @return true if the command line contains the given switch.
4347
*/
4448
public boolean hasSwitch(String name);
49+
4550
/**
4651
* Returns the value associated with the given switch. If the switch has no
4752
* value or isn't present this method returns the empty string.
4853
* @param name the name of the switch.
4954
* @return the value of the switch.
5055
*/
5156
public String getSwitchValue(String name);
57+
5258
/**
5359
* Returns the map of switch names and values. If a switch has no value an
5460
* empty string is returned.
5561
* @return Map of switches and each value.
5662
*/
5763
public Map<String, String> getSwitches();
64+
5865
/**
5966
* Add a switch with an empty value to the end of the command line.
6067
* @param name name of the switch.
6168
*/
6269
public void appendSwitch(String name);
70+
6371
/**
6472
* Add a switch with the specified value to the end of the command line.
6573
* @param name name of the switch.
6674
* @param value value for the switch.
6775
*/
6876
public void appendSwitchWithValue(String name, String value);
77+
6978
/**
7079
* Tests if there are remaining command line arguments.
7180
* @return True if there are remaining command line arguments.
7281
*/
7382
public boolean hasArguments();
83+
7484
/**
7585
* Get the remaining command line arguments.
7686
* @return Vector of command line arguments.
7787
*/
7888
public Vector<String> getArguments();
89+
7990
/**
8091
* Add an argument to the end of the command line.
8192
* @param argument name of the argument.

java/org/cef/callback/CefCommandLine_N.java

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
import java.util.Vector;
99

1010
class CefCommandLine_N extends CefNativeAdapter implements CefCommandLine {
11+
CefCommandLine_N() {}
12+
1113
@Override
1214
public void reset() {
1315
try {
14-
N_reset();
16+
N_Reset(getNativeRef(null));
1517
} catch (UnsatisfiedLinkError err) {
1618
err.printStackTrace();
1719
}
@@ -20,7 +22,7 @@ public void reset() {
2022
@Override
2123
public String getProgram() {
2224
try {
23-
return N_getProgram();
25+
return N_GetProgram(getNativeRef(null));
2426
} catch (UnsatisfiedLinkError err) {
2527
err.printStackTrace();
2628
}
@@ -30,7 +32,7 @@ public String getProgram() {
3032
@Override
3133
public void setProgram(String program) {
3234
try {
33-
N_setProgram(program);
35+
N_SetProgram(getNativeRef(null), program);
3436
} catch (UnsatisfiedLinkError err) {
3537
err.printStackTrace();
3638
}
@@ -39,7 +41,7 @@ public void setProgram(String program) {
3941
@Override
4042
public boolean hasSwitches() {
4143
try {
42-
return N_hasSwitches();
44+
return N_HasSwitches(getNativeRef(null));
4345
} catch (UnsatisfiedLinkError err) {
4446
err.printStackTrace();
4547
}
@@ -49,7 +51,7 @@ public boolean hasSwitches() {
4951
@Override
5052
public boolean hasSwitch(String name) {
5153
try {
52-
return N_hasSwitch(name);
54+
return N_HasSwitch(getNativeRef(null), name);
5355
} catch (UnsatisfiedLinkError err) {
5456
err.printStackTrace();
5557
}
@@ -59,7 +61,7 @@ public boolean hasSwitch(String name) {
5961
@Override
6062
public String getSwitchValue(String name) {
6163
try {
62-
return N_getSwitchValue(name);
64+
return N_GetSwitchValue(getNativeRef(null), name);
6365
} catch (UnsatisfiedLinkError err) {
6466
err.printStackTrace();
6567
}
@@ -69,7 +71,7 @@ public String getSwitchValue(String name) {
6971
@Override
7072
public Map<String, String> getSwitches() {
7173
try {
72-
return N_getSwitches();
74+
return N_GetSwitches(getNativeRef(null));
7375
} catch (UnsatisfiedLinkError err) {
7476
err.printStackTrace();
7577
}
@@ -79,7 +81,7 @@ public Map<String, String> getSwitches() {
7981
@Override
8082
public void appendSwitch(String name) {
8183
try {
82-
N_appendSwitch(name);
84+
N_AppendSwitch(getNativeRef(null), name);
8385
} catch (UnsatisfiedLinkError err) {
8486
err.printStackTrace();
8587
}
@@ -88,7 +90,7 @@ public void appendSwitch(String name) {
8890
@Override
8991
public void appendSwitchWithValue(String name, String value) {
9092
try {
91-
N_appendSwitchWithValue(name, value);
93+
N_AppendSwitchWithValue(getNativeRef(null), name, value);
9294
} catch (UnsatisfiedLinkError err) {
9395
err.printStackTrace();
9496
}
@@ -97,7 +99,7 @@ public void appendSwitchWithValue(String name, String value) {
9799
@Override
98100
public boolean hasArguments() {
99101
try {
100-
return N_hasArguments();
102+
return N_HasArguments(getNativeRef(null));
101103
} catch (UnsatisfiedLinkError err) {
102104
err.printStackTrace();
103105
}
@@ -107,7 +109,7 @@ public boolean hasArguments() {
107109
@Override
108110
public Vector<String> getArguments() {
109111
try {
110-
return N_getArguments();
112+
return N_GetArguments(getNativeRef(null));
111113
} catch (UnsatisfiedLinkError err) {
112114
err.printStackTrace();
113115
}
@@ -117,7 +119,7 @@ public Vector<String> getArguments() {
117119
@Override
118120
public void appendArgument(String argument) {
119121
try {
120-
N_appendArgument(argument);
122+
N_AppendArgument(getNativeRef(null), argument);
121123
} catch (UnsatisfiedLinkError err) {
122124
err.printStackTrace();
123125
}
@@ -137,16 +139,16 @@ public String toString() {
137139
return result + "]";
138140
}
139141

140-
private final native void N_reset();
141-
private final native String N_getProgram();
142-
private final native void N_setProgram(String program);
143-
private final native boolean N_hasSwitches();
144-
private final native boolean N_hasSwitch(String name);
145-
private final native String N_getSwitchValue(String name);
146-
private final native Map<String, String> N_getSwitches();
147-
private final native void N_appendSwitch(String name);
148-
private final native void N_appendSwitchWithValue(String name, String value);
149-
private final native boolean N_hasArguments();
150-
private final native Vector<String> N_getArguments();
151-
private final native void N_appendArgument(String argument);
142+
private final native void N_Reset(long self);
143+
private final native String N_GetProgram(long self);
144+
private final native void N_SetProgram(long self, String program);
145+
private final native boolean N_HasSwitches(long self);
146+
private final native boolean N_HasSwitch(long self, String name);
147+
private final native String N_GetSwitchValue(long self, String name);
148+
private final native Map<String, String> N_GetSwitches(long self);
149+
private final native void N_AppendSwitch(long self, String name);
150+
private final native void N_AppendSwitchWithValue(long self, String name, String value);
151+
private final native boolean N_HasArguments(long self);
152+
private final native Vector<String> N_GetArguments(long self);
153+
private final native void N_AppendArgument(long self, String argument);
152154
}

0 commit comments

Comments
 (0)